I am learning OpenGL and try to do some simple texturing. Therefore I supply my texture coordinates as attributes.
I have a strange error with my vertex shader:
#version 150
in vec2 position;
in vec3 color;
in vec2 texcoord;
out vec3 Color;
out vec2 Texcoord;
void main()
{
Color = color;
Texcoord = vec2 (1.0, 0.5); /* just for debugging hardcode texcords */
gl_Position = vec4( position, 0.0, 1.0 );
}
The shader compiles fine but when I try to link the program to which the shader belongs glGetProgramInfoLog() log says:
ERROR: Compiled vertex shader was corrupt.
When I remove
in vec2 texcoord;
The error disappears. It does not matter how I name the attribute. As soon as I add the third one I get this error.
There are no compilation errors. Just this link error.
I use a OpenGL 3.2 Core Context on OS X 10.8.3. I use GLEW.
Update:
Now I can link this:
#version 150
in vec2 position;
in vec3 color;
in vec2 texcoord;
out vec3 Color;
out vec2 Texcoord;
void main()
{
Color = color;
gl_Position = vec4( position, 0.0, 1.0 );
}
but as soon I add
Texcoord = texcoord;
to the main function the shader becomes corrupt. Im desperate. What is this?
in vec2 Texcoordin your fragment shader ? (i'm not sure, but probably is is a problem that the name is equal except the case of the letters, i alway choose different names) while compiling unused variables are removed, which will prevent the linking error. - t.niese#150and I can't see anything wrong with just your vertex shader. - Hydronium