In case glLockArraysEXT is unavailable

Hello,

excuse my noob question, I have tried to figure out an indices array to use for drawing a quad mesh to avoid multiple transformations of the indices and multiple calls to glDrawElements ( BTW, does glDrawElements issue a kernel entering? ). Suppose I have the mesh presented in the picture,

0-1-2-3
| | | |
4-5-6-7
| | | |
8-9-10-11

I want to draw it from one single glDrawElements. I propose the following indices, using GL_QUAD_STRIP:

4,0,5,1,6,2,7,3, 7,7 7,11,6,10,5,9,4,8 .

Please, note the 7,7 line added when finishing the first quad strip and moving to the next. The card will end up with 2 additional quads: 7,3,7,7 and 7,7,7,11 which should produce no drawing objects since they are quads having 3 vertexes identical and should be discarded very quick. I want to know if my sequence is right and whether would work. Would glMultiDrawElementsEXT render faster?

Thank you.

Don’t use GL_QUAD_STRIP, use GL_TRIANGLES instead. Hardware that supports efficient rendering of indexed triangles has been on the market for a decade now; you no longer need to worry about strips, restarting primitives, degenerate primitives or any of that rubbish. Also, triangles are native to your GPU whereas quads are not and will need to be further broken down before they can be rendered. This is one of the reasons why quads were deprecated as a primitive type in GL 3.x+ core (and never existed at all in D3D).

Essential reading: http://home.comcast.net/~tom_forsyth/blog.wiki.html (look for the article titled “strippers”).

mhagain,

did you mean GL_TRIANGLE_STRIP or just GL_TRIANGLES?

Strip the _STRIP’s and just use GL_TRIANGLES. As mhagain says, providing vertices and indices is a very fast way of drawing geometry these days and modern GPU’s use efficient caching mechanisms for storing multiply indexed transformed vertices.

Yes, this.

The only possible reason I can think of to do otherwise is if you’re explicitly targetting hardware that was current in 1998.