NitroPye
2005.04.27, 12:24 PM
I am having a problem using multiple textures.
Let say I was to create a skybox and load in 6 textures, one for each face, the code would be this:
int textureID[6], i;
glGenTextures(6, textureID);
// load in all the textures here
// the object texture contains -width, -height, bpp, -bitmap
for ( i = 0; i < 6; i++ ) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, [textures[i] width]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, textureID[i]);
gluBuild2DMipmaps(GL_TEXTURE_2D,
[textures[i] bpp],
[textures[i] width],
[textures[i] height],
[textures[i] bpp],
[textures[i] datatype],
[[textures[i] bitmap] bitmapData]);
}
Then i were to do
glBegin(GL_QUADS);
// Right face
glBindTexture(GL_TEXTURE_2D, textureID[0]);
// --- draw here
// Left Face
glBindTexture(GL_TEXTURE_2D, textureID[1]);
// --- draw here
The very last texture I loaded in and bound would be on every face. I cannot see what I am missing. Any thoughts?
Let say I was to create a skybox and load in 6 textures, one for each face, the code would be this:
int textureID[6], i;
glGenTextures(6, textureID);
// load in all the textures here
// the object texture contains -width, -height, bpp, -bitmap
for ( i = 0; i < 6; i++ ) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, [textures[i] width]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, textureID[i]);
gluBuild2DMipmaps(GL_TEXTURE_2D,
[textures[i] bpp],
[textures[i] width],
[textures[i] height],
[textures[i] bpp],
[textures[i] datatype],
[[textures[i] bitmap] bitmapData]);
}
Then i were to do
glBegin(GL_QUADS);
// Right face
glBindTexture(GL_TEXTURE_2D, textureID[0]);
// --- draw here
// Left Face
glBindTexture(GL_TEXTURE_2D, textureID[1]);
// --- draw here
The very last texture I loaded in and bound would be on every face. I cannot see what I am missing. Any thoughts?