1
votes

When I try to bind an attribute to an index of 0, the shader program fails at linking and the only information the infolog gives is:

Vertex shader(s) failed to link, Fragment shader(s) linked.

According the the opengl docs

This command makes it possible for vertex shaders to use descriptive names for attribute variables rather than generic variables that are numbered from 0 to GL_MAX_VERTEX_ATTRIBS -1.

So binding an attribute to index 0 should work. Though it is not very important, I am curious as to why I cannot bind an attribute to index 0. Any suggestions are welcome.

1
Are you calling glBindAttribLocation before or after attaching the vertex shader to the program object? Also, have you checked glGetError immediately after glBindAttribLocation?Damon
I am calling it after. glGetError returns no error. glBindAttribLocation works for other indices. (edit: after attaching, before linking)Jonathan
Hmm sounds like it should work :(Damon
I tried on another computer with a nVidia graphics card. Same result. It might be something with my shader. If its not and inconvenience for you, you could try yourself and see if you get the same result.Jonathan
I found the problem(this was causing other problems): in my vertex shader I had switched from using gl_Vertex to using my own attribute, "vertex", but at one place in my shader I had forgotten to change the variable name, and since gl_Vertex uses the 0 index...Jonathan

1 Answers

0
votes

Quoting OP commentary, because it saved me:

I found the problem(this was causing other problems): in my vertex shader I had switched from using gl_Vertex to using my own attribute, "vertex", but at one place in my shader I had forgotten to change the variable name, and since gl_Vertex uses the 0 index...