Multiple vertex arrays

Started by
7 comments, last by Leroy1891 21 years, 2 months ago
how would i go about specifying more than one vertex array? would i have to make one huge array for everything and keep track of where each object,level,etc starts or is there a way to store more than one array?
Advertisement
OpenGL1.4 introduces the multi draw arrays. Even though I''ve never been into the details I think it would do the trick.
You can only have one Vertex array in OpenGL currently.

What you can do, is place all of your vertices into this array and call a drawing fuction that points to just the vertices you need to render.

Using:


  void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);  


Where the *indices is an array of ints that point to an element in your vertex array. Thus you can build many of these ''pointer'' arrays for different objects, but keep the vertices in one big array.

Hope this helps, if you need more info, try page 74 in the Redbook. Or look it up online.


Llew
Please don''t listen to Silverhand. He''s totaly off here. You can have as many VA as you like. just call the appropriate glVertexPointer, glNormalPointer... before calling glDrawElements/glDrawArrays

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Hey Mirko, please don''t be so rude with him. He''s new here

I''ve read OpenGL1.4 specifications again and I''m sorry but multi draw arrays is not the solution of your problem. So, you have to do as _DarkWIng_ proposed : keep different pointers and switch them by calling glVertexPointer everytime you need to "bind" a vertex array for a mesh you''re going to render.
Silverhand : Sorry for being rude. I t wasn''t my intention. I just pointed out an error. I didn''t see you just joined today. Wellcome!

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Sweet, just learning OpenGL here, the Pointer switching thing may come in handy.

And no offense taken, I''ve seen much worse

I do have a question then. From what I understand, vertex arrays give a performance increase because of how the graphics hardware can handle them. Is it possible to lock multiple arrays, and still point to different ones? ( Is locking the main portion of the performance increase? ) If I am totally off, go ahead and correct me.

Llew
If you mean "lock" as in "compiled vertex arrays", then actually not.
I would strongly reccommend that you don''t use glLockArrays, simply because it''s a very outdated call, and wasn''t designed for modern hardware. My experiments have shown to suggest that most current generation hardware will fall back to software transform and lighting when using this extension, which is understandable, as vertex caches aren''t huge.
I tired it just now, in a fill rate intensive situation, where even my d3d renderer (which is capable of pretty insane tris/sec rates) can only manage maybe 1.3 million tris sec... using lockArrays, triangle/sec throughput of my gl renderer fell to around 500,000 tris/sec, which is about what you get when not taking advantage of hardware T&L.
In a day where even budget cards are capable of 20 million tris/sec, 500k is a pretty significant step backwards.

Optimize for vertex caching, (both by index ordering and with the use of the likes of triangle strips) and consider the up comming ARB vertex array object extension (FINALLY ).. you will do _SIGNIFICANTLY_ better than glLockArrays.

| - Project-X - my mega project.. yup, still cracking along - | - adDeath - an ad blocker I made - | - email me - |

This topic is closed to new replies.

Advertisement