PDA

View Full Version : Efficiency: Vertex arrays



Structural
12-02-2002, 02:51 AM
I got my book this Saturday (the one from Gamedev.net) and I've been reading over vertex arrays for a while now.
What I've been wondering how I can best render/store an object that consists out of different primitives (QUADS or TRIANGLES or POLYGON). I've been thinking of making a whole set of different arrays in my object (one for QUADS, one for TRIANGLES, etc etc) but I'm not quite sure this is the most efficient or even most understandable way to do this. Any suggestions on this?

Also doesn't the book mention the use of the index array (I read about that in some other thread) but it does seem to be in their example code. Can anyone provide me with an clear example of how to use it most efficiently?

Thank you!


And how can I define the size of an array in an object AFTER I have made it, I now have to define the size of the array in the definition of the object... I currently use vectors to get around this problem


[This message has been edited by Structural (edited 12-02-2002).]

MickeyMouse
12-02-2002, 04:45 AM
I got my book this Saturday (the one from Gamedev.net) and I've been reading over vertex arrays for a while now.
What I've been wondering how I can best render/store an object that consists out of different primitives (QUADS or TRIANGLES or POLYGON). I've been thinking of making a whole set of different arrays in my object (one for QUADS, one for TRIANGLES, etc etc) but I'm not quite sure this is the most efficient or even most understandable way to do this. Any suggestions on this?


I see no reason why you would like to have so many representations of your geometry at the same time.



Also doesn't the book mention the use of the index array (I read about that in some other thread) but it does seem to be in their example code. Can anyone provide me with an clear example of how to use it most efficiently?


Indexed arrays representation usually needs less memory, since common verts can be reused for many polys.

Quake3 BSP for instance uses geometry representation where verts are stored in triangle-fan-like order (GL_TRIANGLE_FAN), but elements point to verts in triangle-like order.
This way however they don't reuse verts, so they need to send more data to card (Hmmm...why they choosed this way then??).



And how can I define the size of an array in an object AFTER I have made it, I now have to define the size of the array in the definition of the object... I currently use vectors to get around this problem


LOL http://www.opengl.org/discussion_boards/ubb/smile.gif, code:
float* values;
values = new float[number_of_values];