PDA

View Full Version : About glDrawElements and glVertexPointer



NOAH IV
10-17-2003, 03:53 AM
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.

glVertexPointer(...,...,...,...);
glDrawElements(...,...,...,indices1);
glDrawElements(...,...,...,indices2);

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.

Thanks!

harsman
10-17-2003, 05:50 AM
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.

NOAH IV
10-21-2003, 05:16 AM
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??

Relic
10-22-2003, 03:30 AM
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.