/* something like this is inside the glm.c file */ typedef struct _GLMmodel { ... GLuint numvertices; /* number of vertices in model */ GLfloat* vertices; /* array of vertices */ GLuint numnormals; /* number of normals in model */ GLfloat* normals; /* array of normals */ GLuint numtexcoords; /* number of texcoords in model */ GLfloat* texcoords; /* array of texture coordinates */ ... GLuint numtriangles; /* number of triangles in model */ GLMtriangle* triangles; /* array of triangles */ ... } GLMmodel; GLMmodel *reallyBigDragon; GLuint *dragonIndices; void init( void ) { ... reallyBigDragon = glmReadOBJ( "myDragon.obj" ); glmUnitize( reallyBigDragon ); glmVertexNormals( reallyBigDragon, 90.0 ); ... SetupDragonIndices(); } void SetupDragonIndices( void ) { dragonIndices = (GLuint *)malloc( 3 * reallyBigDragon->numtriangles * sizeof( GLuint ) ); ... iterate through the GLMgroups in the model ... ... for each group, look at each triangle -- which gives 3 indices ... ... reallyBigDragon->groups->triangle[i]->vindices[0..2] contain ... ... the 3 vertex indices for triangle i (in the group) ... ... this should be the same as the normal index ->nindices[0..3] ... ... (if it isn't you'll need to specifically set up the normal and ... ... vertex arrays as well), reallBigDragon->groups->next points to ... ... the next triangle group (if it exists) ... } void display( void ) { // ... standard setup stuff, like clear screen... // Setup the location of the sphere // Setup the color of the sphere. if (usingDisplayList) glCallList( sphereListID ); else if (usingVertexArray) { glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glNormalPointer( 3, GL_FLOAT, 0, reallyBigDragon->normals ); glVertexPointer( 3, GL_FLOAT, 0, reallyBigDragon->vertices ); glDrawElements( GL_TRIANGLES, 3*reallyBigDragon->numTriangles, GL_UNSIGNED_INT, dragonIndices ); glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_NORMAL_ARRAY ); } else CreateSphere( 1.0, 10 ); // ... do standard per-frame cleanup ... }