About glDrawElements and glVertexPointer

When we call glVertexPointer, will the vertex data be transferred to the card immediatly or wait for some other instruction like glDrawElements?

Lets say we have a vertex array with 500 vertices. And two calls to glDrawElements using different subsets of vertices, lets say 300 and 250.


How would this work?

a) 500 vertices will be transferred and the two meshes redered using a subset of this vertices?

b) 300 vertices will be transferred for the fist call of glDrawElements plus 250 for the second call?

c) the same 500 vertices will be transferred two times?

I think (b) is probably the way it works but I’m not confident. And depending on how it works my data structure may change a lot.


The driver doesn’t know how many vertices you are referencing in your drawelements call so it probably scans through the index array on the cpu and only copies the referenced range of indices.

If you use DrawRangeElements you provide the range implicitly and you should get better performance. For best performance use the ARB_vertex_buffer_object extension, or display lists.

So, glDrawElements will transfer all vertices specified in glVertexPointer? Even when “indices1” and “indices2” only point to a subset of vertices?

Is it worth to split the mesh in some smaller meshs??

No, if you have 500 vertices in your array, but reference only 250 in the indices, only those 250 are transformed.
The glVertexPointer alone doesn’t tell OpenGL how many vertices are behind the pointer.