1

I know that when glDrawElements is called it uses a buffer of indices to determine what vertices to draw in what order. My question is how those indices are applied to texture, normal, and color attributes. Is it possible to set another index array for what texture coordinates and normals are supposed to be used for each vertex. Or do I have to create the normal and texture coordinate buffers so that they align with the vertices being drawn?

dagronlund
  • 1,612
  • 3
  • 13
  • 15
  • possible duplicate of [Using more than one index list in a single VAO](http://stackoverflow.com/questions/8206144/using-more-than-one-index-list-in-a-single-vao) – Nicol Bolas Jun 21 '12 at 21:44

1 Answers1

5

Is it possible to set another index array for what texture coordinates and normals are supposed to be used for each vertex.

No. For a good reason:

Or do I have to create the normal and texture coordinate buffers so that they align with the vertices being drawn?

Don't try to see vertex, normal, texture coordinate and so on as different vectors assigned to a vertex (-position). A vertex is actually a compound vector, which covers all those attributes. The old terminology stems from the fixed function pipeline. Modern OpenGL only knows generic vertex attributes.

So every index refers to exactly one specific vertex vectors. If there is a difference in any attribute, then it's a different vertex and hence is to be given a different index.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • 1
    So when an index is used for a vertex to refer to a specific vector, if there are enabled color buffers, normal buffers, or texture buffers, the index refers to the same position in those buffers as it did in the vertex buffer? – dagronlund Jun 21 '12 at 21:49
  • @dagronlund: Yes. Because all the different buffers just contain elements of a larger vector. Think of `Vertex_i = (pos_i, normal_i, texccords[]_i, attribs[]_i)`. – datenwolf Jun 22 '12 at 06:56