• Advertisement

Archived

This topic is now archived and is closed to further replies.

Multiple vertex arrays

This topic is 5500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
OpenGL1.4 introduces the multi draw arrays. Even though I''ve never been into the details I think it would do the trick.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 - |

Share this post


Link to post
Share on other sites

  • Advertisement