Jump to content
  • Advertisement
Sign in to follow this  
NoahKlabo

OpenGL (MD5mesh parser) Opengl glVertexPointer to glCallList ?

This topic is 2219 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been modifying this md5mesh loader/parser to comply with my engine and I would like to switch the display function to use OpenGL call lists as opposed to glVertex pointers
[source lang="cpp"]
//original display function

/* Draw each mesh of the model */
for (i = 0; i < md5file.num_meshes; ++i)
{
PrepareMesh (&md5file.meshes, skeleton);

glVertexPointer (3, GL_FLOAT, 0, vertexArray);

glDrawElements (GL_TRIANGLES, md5file.meshes.num_tris * 3,
GL_UNSIGNED_INT, vertexIndices);
}[/source]

[source lang="cpp"]
//My function
/* Draw each mesh of the model */
for (i = 0; i < md5file.num_meshes; ++i)
{
PrepareMesh (&md5file.meshes, skeleton);

glVertexPointer (3, GL_FLOAT, 0, vertexArray);

do
{
//glColor4f /*if transparent*/
glBegin(GL_TRIANGLES);

//gltexcoord2f()
//times = times + 1;
glVertex3f(vertexArray[times][0],vertexArray[times][1],vertexArray[times][2]);

//gltexcoord2f()
times = times + 1;
glVertex3f(vertexArray[times][0],vertexArray[times][1],vertexArray[times][2]);

//gltexcoord2f()
times = times + 1;
glVertex3f(vertexArray[times][0],vertexArray[times][1],vertexArray[times][2]);
glEnd();

times = times + 1;
}while(times < md5file.meshes.num_tris);

}

glutSwapBuffers ();
glutPostRedisplay ();
}[/source]
. When I compiled it the outline of the model looks fine but the triangles of it are not correct.

Share this post


Link to post
Share on other sites
Advertisement
Something I noticed was your 'times' counter is going up every vertex but is then checked against the number of tris. Obviously it should be getting checked against the number of verts? Maybe just use the num_tris * 3?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!