Advertisement

opengl tex coords

Started by March 11, 2000 07:31 PM
1 comment, last by ECKILLER 25 years ago
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
ECKILLER
need help please!



ECKILLER
ECKILLER
Advertisement
Check out http://nate.scuzzy.net/docs/texture.html, it should help you.

Nate
http://nate.scuzzy.net

This topic is closed to new replies.

Advertisement