Hello,
I have six images and I would like to use them to make a skybox in a cube that I am calling from a display list.
Right now, only the 6th face is textured on all faces .
Here’s the code that initialises texturing :
void generateTextures(){
int i = 0;
//load an image to an SDL surface (i.e. a buffer)
texture[0] = IMG_Load("skybox_images/neg_z.bmp");
texture[1] = IMG_Load("skybox_images/neg_x.bmp");
texture[2] = IMG_Load("skybox_images/pos_z.bmp");
texture[3] = IMG_Load("skybox_images/pos_x.bmp");
texture[4] = IMG_Load("skybox_images/pos_y.bmp");
texture[5] = IMG_Load("skybox_images/neg_y.bmp");
/* if(texture == NULL)
{
printf("bad image
");
exit(1);
}*/
//create an OpenGL texture object
glGenTextures(6, textureObjSkyBox);
for(i = 0; i < 6; i++){
//select the texture object you need
glBindTexture(GL_TEXTURE_2D, textureObjSkyBox[i]);
//define the parameters of that texture object
//how the texture should wrap in s direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
//how the texture should wrap in t direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
//how the texture lookup should be interpolated when the face is smaller than the texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//how the texture lookup should be interpolated when the face is bigger than the texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//send the texture image to the graphic card
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture[i]->w, texture[i]->h, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[i]-> pixels);
//clean the SDL surface
SDL_FreeSurface(texture[i]);
}
}
After doing this, I have a display list in my cube where I want to texture each face.
How would I go about it ?
Thanks,
Manojo