Sign in to follow this  
ajm113

How can you UV map with glVertexPointer?

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[i], zSkeleton);

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

      glDrawElements (GL_TRIANGLES, md5file.meshes[i].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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this