I have couple questions regarding glDrawElements… I’ve got it succesfully working, but it’s slower than glDrawArrays AND also slower than immediate mode. This shouldn’t be the case, should it?
And what does glDrawElements’ 2nd parameter ‘count’ actually mean? The number n of faces to be drawn or the number of vertex indices used in drawing n number of faces?
also as michail used ‘indices’ is the correct term which is very differnt to face
eg to draw 2 faces/triangles
using GL_TRIANGLES u need 6 indices
but using GL_TRIANGLE_STRIP u need 4 indices.
2 triangles but one uses 6 indices and the other only 4
You are doing a call to glDrawElements that exactly mirrors calling glDrawArrays. Unless you are using Vertex_Array_Range (or perhaps CVA’s), you aren’t going to get better performance out of glDrawElements.
I would suggest downloading nVidia’s stripper. Except for a few cases where it gives odd results with quads, it works very well. Use it to transform your face data into strips and draw them that way with glDrawElements. It will likely be faster than glDrawArrays.
You will also need to compress your vertex data. Remove redundant array entries (where a unique vertex is the same as another) and adjust the face array to compensate, before you use the stripper.
Originally posted by Korval: You will also need to compress your vertex data. Remove redundant array entries (where a unique vertex is the same as another) and adjust the face array to compensate, before you use the stripper.
I already have an initialization code where i get rid off those duplicate vertices…
Well, i guess i gotta test those CVA’s if they make a difference.
> You are doing a call to glDrawElements
> that exactly mirrors calling glDrawArrays.
> Unless you are using Vertex_Array_Range
> (or perhaps CVA’s), you aren’t going to
> get better performance out of
> glDrawElements.
You don’t know that – that depends on his definition of “face”. If there is vertex re-use among the faces (i e more than one face uses the same vertex index) then he’s using DrawElements correctly.
I’ve found that on TNT2, putting an unused float after the x,y,z (so the stride is 16) and aligning the vertex array on a 32-byte boundary leads to a noticeable speed-up. Perhaps this is just a lucky cache interaction, or perhaps they have a fast path (say, using MOVAPS instead of MOVUPS in places, or something).