PDA

View Full Version : Textured Cube: Diff tex. on each side



Blaqb0x
06-23-2002, 09:42 PM
hi,

I was reading the textured cube tutorial on NEHE.gamedev.net lesson 6

He shows you how to a single textured cube. I tried to extend this to have 2 textures but it's not working. Only one texture works and the other faces of the cube are 'white'.

Im almost positive that the trouble is w/ the texture binding. here's a summary of what I did there.

#--------------

AUX_RGBImageRec *TextureImage[2]; // Storage space for our Texture


if ( TextureImage[0]=LoadBMP("data/crate.bmp"))
{
Status=TRUE;

//Here it looks like we are creating storage and type of texture then assigning the bitmap data to it.
glGenTextures(1, &texture[0]); // Create the texture
glBindTexture(GL_TEXTURE_2D, texture[0]); // Texture generation using data from the bitmap
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->data);

if( TextureImage[1]=LoadBMP("data/nehe.bmp") )
{
Status= TRUE;
glGenTextures(1, &texture[1]); // Create the texture
glBindTexture(GL_TEXTURE_2D, texture[1]); // Texture generation using data from the bitmap
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, TextureImage[1]->data);

}


#-------
Can anyone see what' going wrong here?

Blaqb0x
06-23-2002, 10:46 PM
Ok I found that I have an extra glGenTextures
and then I only created one texture. I fixed this by deleting the second glGenTextures
then editing the first w/
glGenTextures(2, &texture[0]); but that still didnt help.

anyone know why?

thanx

JML
06-23-2002, 11:01 PM
Check glGetError() for errors while creating the second texture.
Verify that the second texture has the right dimensions, color-depth etc.

Have you tried creating the second texture as an exact copy of the first one (should produce the same results as with using just one texture?

BTW, both of your solutions using glGenTextures() should work: it makes no difference asking for a single name twice or for two names once.

HTH

Jean-Marc