-
tex coordinates
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
Frank
-
Re: tex coordinates
So you can't see the top and bottom faces at all? Maybe your face vertices are not in counter clockwise order. If back face culling is enabled, it means that if the vertices are not in correct order, you can't see the faces.
Btw, the tex coords should be in range 0-1. Oh yes, and it would be easier to draw quads (GL_QUADS) in the case of cube 
[This message has been edited by Hude (edited 03-12-2000).]
-
Re: tex coordinates
No, no, I can see the top and bottom, theres just no textures on the top and bottom.
Sorry for the confusions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules