PDA

View Full Version : texturing problem



eckiller
03-12-2000, 09:31 AM
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(just a wierd purple solid color which seems to be a blend of the texture colors. Heres what the texture part of my code looks like:

/* GLOBALS */

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

MattS
03-23-2000, 05:15 AM
Texture coordinates should usually go from 0.0 to 1.0 (if textures not wrapped), this looks to the problem.

dmy
03-23-2000, 06:17 AM
why do you render two times the same geometry?

try to change the index size from UBYTE to UINT: i had some problem with colors in the UBYTE format...

Dolo/\/\ightY