I seem to be having some problems getting glDrawElements to work. Using the fixed function implementation below, I try to draw my mesh object:
int numIndicies = mesh->GetNumIndicies();
float* verts = mesh->GetVertexBuffer();
int* indicies = mesh->GetIndexBuffer();
glPushMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
for(int i=0; i<numIndicies; i+=3)
{
glVertex3f(verts[indicies],verts[indicies[i+1]],verts[indicies[i+2]]);
}
glEnd();
glPopMatrix();
The code above renders the mesh without any problems. Unfortunately, I am unable to render the mesh using (what I think is) a comparable implementation using glDrawElements:
glPushMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, mesh->GetVertexBuffer());
glDrawElements(GL_TRIANGLES, mesh->GetNumIndicies(), GL_INT,mesh->GetIndexBuffer());
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
I've been staring at this for a while, but I can't seem to find the missing piece. Any help is greatly appreciated.