Best Data Structure

I’m asking myself wich is the best data structure to hold/render geometrical data for an object in OpenGL.

I mean, one signle structure for all the model data ?

Classes ? Structures ?

One structure for the model and “substructure” for Faces and Vertex ?

Does exist the “perfect data structure for OpenGL” ?

For a game is better to have an “easy to use” structure or a better “high performance - low API calls to get rendered” structure ?


I don’t think that there is one “Best data structure (DS)”. For every purpose and rendering method you must make a diffrent structure:
For example, If you render with Vertex Array your structure have to store the vertices in a array. But sometimes, you want the hirarchy Face->vertex.

Actually, I am working on a full 3D-Engine with editor, and we (I and the two other team members) had to decide what DS we are going to use.

We wanted both the Vertex-Array and the hierarchical structure (Face[]->Vertex[]->Vertex_Information), but without storing the information twice.

We decided to use a interleaved vertex array, and a hirarchy that will store pointer to a specific place in the array.

I have three arrays per object:
-Vertex array (with texcoords, normal, xyz, etc per vertex)
-Face array (with material, normal and three indices into the vertex array, for triangle vertices 1,2 and 3).
-Strip array (each strip has a material and a list of indices into the vertex array).

This is because sometimes its faster to render triangles than strips (depending on the model.

[This message has been edited by coco (edited 01-25-2001).]