Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ECKILLER

OpenGL opengl tex coords

This topic is 6736 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

Hey, I''m very confused with texture coordinates. I got something to work but its not 100% how i want it. I added textures to the surfaces of my cubes but the problem is, is that the top and bottom of it arnet getting the textures. Heres what the texture part of my code looks like: /* GLOBALS */ // Array containing the eight vertices of the cube static GLfloat corners[] = { -1.0f, 1.0f, 1.0f, // 0 1.0f, 1.0f, 1.0f, // 1 1.0f, -1.0f, 1.0f, // 2 -1.0f, -1.0f, 1.0f, // 3 -1.0f, 1.0f, -1.0f, // 4 1.0f, 1.0f, -1.0f, // 5 1.0f, -1.0f, -1.0f, // 6 -1.0f, -1.0f, -1.0f };// 7 // Array of indexes to create the cube, static GLubyte indexes[] = { 0, 3, 1, 1, 3, 2, 1, 2, 6, 1, 6, 5, 0, 7, 3, 4, 7, 0, 5, 7, 4, 6, 7, 5, 3, 7, 2, 2, 7, 6, 4, 0, 1, 4, 1, 5}; static GLfloat tex_corners[] ={-1.0f, 1.0f, // 0 1.0f, 1.0f, // 1 1.0f, -1.0f, // 2 -1.0f, -1.0f, // 3 -1.0f, 1.0f, // 4 1.0f, 1.0f, // 5 1.0f, -1.0f, // 6 -1.0f, -1.0f}; // 7 static GLubyte tex_indexes[] = { 0, 3, 1, 1, 3, 2, 1, 2, 6, 1, 6, 5, 0, 7, 3, 4, 7, 0, 5, 7, 4, 6, 7, 5, 3, 7, 2, 2, 7, 6, 4, 0, 1, 4, 1, 5}; // holds the texture GLuint tex; /* END GLOBALS */ /* In my init function */ // load the textures Load_Texture("texT.bmp", &tex); /************************/ /* in my display function */ // Enable the vertex array glEnableClientState(GL_VERTEX_ARRAY); // enable the texture array glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, corners); glTexCoordPointer(2, GL_FLOAT, 0, tex_corners); // draw the arrays glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indexes); glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, tex_indexes); Please help ECKILLER

Share this post


Link to post
Share on other sites
Advertisement
Check out http://nate.scuzzy.net/docs/texture.html, it should help you.

Nate
http://nate.scuzzy.net

Share this post


Link to post
Share on other sites

  • 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!