Reputation: 23334
In the OpenGL Reference Pages, some functions are marked as using uniform locations, while other functions are marked as using uniform indices. Are these the same thing?
Similarly for vertex attributes, some functions are marked as using vertex attribute indices, while other functions are marked as using vertex attribute locations. Are these the same?
Upvotes: 3
Views: 437
Reputation: 45322
In your first case, the location for an Uniform is different from the index used for glGetActiveUniform()
.
For glGetActiveUniform()
case, index is just a value between 0 and the value you get from glGetProgram( GL_ACTIVE_UNIFORMS,...)
minus one. This API allows you to query any resources of the program, and you can iterate over all active uniforms with that method. The uniform locations may not start at 0, and may not be consecutive at all.
In your second example, glGetAttribLocation()
and glEnableVertexAttribArray()
both refer to the same index. The GL has a set of generic attributes, which are generally referenced by their indices, starting from 0. However, to make things a little bit more interesting, there is also glGetActiveAttrib()
which is similiar to the glGetActiveUniform()
one: here, the index refers just to the list of active attributes (in the range 0 to the value you get from glGetProgram( GL_ACTIVE_ATTRIBUTES,...)
minus one, and not to the actual attribute index/location. Again, this API allows you to iterate over all attributes which are present (and active).
Upvotes: 5