2
\$\begingroup\$

Does glBindAttribLocation silently ignore names that are not found? For example, in a shader:

// Some vertex shader
in vec3 position;
in vec3 normal;
// ...

And in some set up code:

// While setting up shader
GLuint program = glCreateProgram();
glBindAttribLocation(program, 0, "position");
glBindAttribLocation(program, 1, "normal");
glBindAttribLocation(program, 2, "color"); // What about this one?
glLinkProgram(program);
\$\endgroup\$
1
  • \$\begingroup\$ You can collect OpenGL errors and see what's silent and what's not. \$\endgroup\$
    – House
    Commented Jun 25, 2013 at 15:35

1 Answer 1

3
\$\begingroup\$

I did a test for that and the short answer is openGL didn't return any error.

OpenGL documentation also states:

glBindAttribLocation can be called before any vertex shader objects are bound to the specified program object. It is also permissible to bind a generic attribute index to an attribute variable name that is never used in a vertex shader.

If name was bound previously, that information is lost. Thus you cannot bind one user-defined attribute variable to multiple indices, but you can bind multiple user-defined attribute variables to the same index.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for pointing out. I completely missed that sentence. \$\endgroup\$
    – rwols
    Commented Jun 26, 2013 at 1:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .