I’ve been running into a problem I don’t know how to sort out. Here’s the point:
I have arrays containing vertices, normals and texcoords. The problem is that these arrays are not indexed the same way :s
I mean: vertices are indexed as absolute index with respect to the current object, the object contains an array with polygons, each containing the indices of the vertices used to build the polygon. In every polygon there is also an array with UV coordinates, but indexed the same way the INDICES to vertices are indexed, not vertices temselves! Here’s the code
glVertexPointer(3, GL_FLOAT, sizeof(dmf_vector3_t), &(objPtr->vertices)); glTexCoordPointer(2, GL_FLOAT, sizeof(dmf_vector2_t), &(polyPtr->texcoords.vertices)); glDrawElements(GL_TRIANGLES, polyPtr->numVertices, GL_UNSIGNED_INT, &(polyPtr->indices) );
objPtr->vertices points to the vertices
polyPtr->indices contains the indices of the vertices needed
polyPtr->texcoords.vertices contains UV coordinates… BUT polyPtr->texcoords.vertices, for instance, refers to the vertex designated by polyPtr->indices, NOT to objPtr->vertices…
Could someone provide enlightment about this matter? Thanks alot!