Heya, I just wanted some help with using vertex arrays. I wrote a Q3BSP map loader and this is the code that does the rendering, and it works as intended:
glBegin(GL_TRIANGLES);
for (int i = 0; i < curFace.meshVertexCount; i++) {
int meshIndex = meshvertices[curFace.meshVertexOffset + i].offset;
glVertex3fv(vertices[curFace.vertexOffset + meshIndex].position);
}
glEnd();
But when I switch to vertex array for speed, the screen shows up blank:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), vertices[curFace.vertexOffset].position);
glDrawElements(GL_TRIANGLES, curFace.meshVertexCount, GL_INT, &meshvertices[curFace.meshVertexOffset].offset);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_INDEX_ARRAY);
Also, here would be the relevant headers:
// 10 - Vertex
struct Vertex {
float position[3];
float texCoord[2][2];
float normal[3];
unsigned char colour[4];
};
// 11 - MeshVertex
struct MeshVertex {
int offset;
};
std::vector<Vertex> vertices;
std::vector<MeshVertex> meshvertices;
I could post the entire code if you'd like, but most of that might be irrelevant.