Are OpenGL indices and locations the same for uniforms and vertex attributes?

In the OpenGL man pages, some functions are marked as being used by uniform locations, and others are marked as being used as uniform indexes. It is the same?

Likewise, for vertex attributes, some functions are flagged as in-use vertex attribute indices and others are flagged as in-use vertex positioning attributes. Are they the same?

+3


source to share


1 answer


In your first case, the location of the uniform is different from the zip used for glGetActiveUniform()

.

In the case, the glGetActiveUniform()

index is just a value between 0 and the value you get from glGetProgram( GL_ACTIVE_UNIFORMS,...)

minus one. This API allows you to request any program resources, and you can iterate over all active forms using this method. Single locations may not start at 0 and cannot be sequential.



In your second example glGetAttribLocation()

, glEnableVertexAttribArray()

both both refer to the same index. GL has a set of common attributes, which are usually referenced by their indices starting at 0. However, to make things a little more interesting, there is also glGetActiveAttrib()

one that is similar glGetActiveUniform()

: here the index only refers to the list of active attributes (in the range 0 to the value you get from glGetProgram( GL_ACTIVE_ATTRIBUTES,...)

minus one, not the actual index of the attribute / location Again, this API allows you to iterate over all the attributes that are present (and active).

+4


source







All Articles