Hi,
I’m trying to make a program that loads and renders an md2 model. I’m getting a blank screen however when everything should look good. I can’t see a problem but maybe you guys can. Here’s my function to render it, which gets called by my main render function. Also my arrays in the function contain valid data, as my friend gave me the model data to help me debug(he rendered it w/ DX), and i tested the array values against his data print off. here it is:
bool RenderMD2Model( MD2MODEL *model )
{
int i,j;
GLfloat *verts = new GLfloat[model->NumVerts*3];
// array to hold entire model vertices
int vc1=0, vc2=1, vc3=2;
for(i=0; i < model->NumVerts; i++)
{
verts[vc1] = model->Frames[0].Verts[i].x;
verts[vc2] = model->Frames[0].Verts[i].y;
verts[vc3] = model->Frames[0].Verts[i].z;
vc1+=3;vc2+=3;vc3+=3;
}
int nTotalNumIndices = 0;
for(i =0; i < model->NumPrimitives; i++)
{
nTotalNumIndices += model->Primitives[i].NumFaceIndices;
}
GLubyte *indices = new GLubyte[nTotalNumIndices];
// big array to hold all the indices
int ic1 = 0;
for(i=0; i < model->NumPrimitives; i++)
{
for(j=0; j < model->Primitives[i].NumFaceIndices; j++)
{
indices[ic1] = model->Primitives[i].FaceIndices[j].index;
ic1++;
}
}
// draw it!
// Enable the vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, verts);
glDrawElements(GL_TRIANGLE_STRIP, nTotalNumIndices, GL_UNSIGNED_BYTE, indices);
delete [] verts; verts = NULL;
delete [] indices; indices = NULL;
return true;
}