Jump to content
  • Advertisement
Sign in to follow this  
ajm113

How can you UV map with glVertexPointer?

This topic is 3256 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'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. :)

Share this post


Link to post
Share on other sites
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+.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!

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!