How can you UV map with glVertexPointer?

Started by
2 comments, last by ajm113 14 years, 8 months ago
I'm trying to understand how I can UV map with glVertexPointer. I was reading on MD5meshes work and I got my own md5mesh loader. It reads in the UVs so, I'm just figuring out how to UV map with this:

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

      glVertexPointer (3, GL_FLOAT, 0, m_md5Loader.ReturnVertex());

      glDrawElements (GL_TRIANGLES, md5file.meshes.num_tris * 3,
		  GL_UNSIGNED_INT, m_md5Loader.ReturnIndices());
    }

  glDisableClientState (GL_VERTEX_ARRAY);


Thank you hope to get some help, any questions are welcomed as well if you have any about the code. :)
Check out my open source code projects/libraries! My Homepage You may learn something.
Advertisement
Just to clarify that:

glVertexPointer is for vertex coordinates, nothing else.

To load texture coordinates (UV) you'd need to use glTexCoordPointer - or the generic glAttribPointer with OpenGL 3+.

If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
glTexCoordPointer()

It takes the same parameters as glVertexPointer (but you point it at your texcoords instead!).

Also note: "To enable and disable a texture coordinate array, call glEnableClientState and glDisableClientState with the argument GL_TEXTURE_COORD_ARRAY."

Also for future reference, http://www.opengl.org/sdk/docs/man/ should be pretty helpful to you. (The see-also section at the bottom is very helpful if you're not quite sure what it is you need)

cheers,
Dan

EDIT: beaten, also TexCoord not Texcoord, doh!
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Great, thanks guys! I got textures to work on my characters and I got the UVs to work correctly!


Thanks again I appreciate your help!

Check out my open source code projects/libraries! My Homepage You may learn something.

This topic is closed to new replies.

Advertisement