2
votes

I started picking up OpenGL by using http://www.opengl-tutorial.org.
It uses following code to load and compile shaders (Linked because code is too long for this post and I think it's something with my shaders)

When running this code, it prints out "ERROR: Compiled Vertex Shader is corrupt" and "ERROR: Compiled Fragment Shader is corrupt". My shaders are following

Vertex Shader

#version 330 core
out vec3 color;

void main(){
    color = vec3(1,0,0);
}

Fragment shader

#version 330

layout (location = 0) in vec3 position;

void main()
{
    gl_Position.xyz = position;
    gl_Position.w = 1.0;
}

I'm using XCode 5.1.1 , OpenGL 3.3 and GLSL 3.30.

It would be awesome if you guys could help me past this point. I got stuck on a YouTube tutorial that didn't use VAO's, so I went to learn these things myself so I could write the tutorial in my own code.

Thanks in advance

1
I guess it's just the way you've copied them in your question, but you have the vertex and fragment shaders the wrong way round. - GuyRT

1 Answers

1
votes

This is a common problem that shows up with XCode and is usually caused by text encoding or improperly null-terminated strings. There could be non-printing characters at the end of both of them.

You can look through the VertexShaderCode and FragmentShaderCode strings in a debugger and find out if there are any erroneous chars or if they're not null-terminated.

I found people running into the same errors here and here.

To fix them, open your GLSL files with text edit, text mate, or sublime text (some really basic text editor) and convert them to text only and save them as new files.