generic vertex attributes question

Started by
2 comments, last by nts 17 years, 5 months ago
Hello, i have a problem understanding generic vertex attributes. Have some questions i can't find answers to etc. I enable a vertex attrib array with: glEnableVertexAttribArray(index); Then i set the pointer with: glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, tangents); When i set the current gpu program in my renderer i change the generic vertex attribute bindings for the attribute variables in the program: glBindAttribLocation(program, index, "my_Tangent"); And everything works ok...however i noticed that the vertex attribute array with index 0 is used by the vertex position. On the other hand when i check if vertex attribute array with index 0 is enabled i get false. Allso the vertex attribute bindings automaticaly assigned by the gpu program linker start from index 3 when i'm sending position, normal and 1 texture coord to the VGA. So the questions are: How can i be sure that the custom vertex attribute array i'm using is not in use by something else...like position, normal or texture coordinates? Are the things enabled by: glEnableClientState(...) considered vertex attribute arrays etc. Or with other words how can i handle vertex attributes safely?
Advertisement
Are you using GLSL or ARB_vertex_program/ARB_fragment_program? That changes the answer.
I'm not using the ARB extensions...i'm using the OpenGL core methods (the ones promoted from the ARB extensions in OpenGL 2.0). However i'm not sure that this is GLSL but i think so.
See the spec

Quote:
Implementations may, but do not necessarily, use the same storage for the
current values of generic and certain conventional vertex attributes.

When any generic vertex attribute other than zero is specified, the
current values for the corresponding conventional attribute in Table X.1
become undefined. Additionally, when a conventional vertex attribute is
specified, the current values for the corresponding generic vertex
attribute in Table X.1 become undefined. For example, setting the current
normal will leave generic vertex attribute 2 undefined, and vice versa.
    Generic    Attribute   Conventional Attribute       Conventional Attribute Command    ---------   ------------------------     ------------------------------         0      vertex position              Vertex         1      vertex weights 0-3           WeightARB, VertexWeightEXT         2      normal                       Normal         3      primary color                Color         4      secondary color              SecondaryColorEXT         5      fog coordinate               FogCoordEXT         6      -                            -         7      -                            -         8      texture coordinate set 0     MultiTexCoord(TEXTURE0, ...)         9      texture coordinate set 1     MultiTexCoord(TEXTURE1, ...)        10      texture coordinate set 2     MultiTexCoord(TEXTURE2, ...)        11      texture coordinate set 3     MultiTexCoord(TEXTURE3, ...)        12      texture coordinate set 4     MultiTexCoord(TEXTURE4, ...)        13      texture coordinate set 5     MultiTexCoord(TEXTURE5, ...)        14      texture coordinate set 6     MultiTexCoord(TEXTURE6, ...)        15      texture coordinate set 7     MultiTexCoord(TEXTURE7, ...)       8+n      texture coordinate set n     MultiTexCoord(TEXTURE0+n, ...)

Table X.1, Generic and Conventional Vertex Attribute Mappings. For each
row, the current value of the conventional attribute becomes undefined
when the corresponding generic attribute is set, and vice versa.
Attribute zero corresponds to the vertex position and has no current
state.

This topic is closed to new replies.

Advertisement