Hi,
I’m trying to do a simple sample of cube mapping.
Here is the code:
void init() {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
glGenTextures(1, &cubeMapId);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapId);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
const char* name[6] = {
"xpos.jpg",
"xneg.jpg",
"ypos.jpg",
"yneg.jpg",
"zpos.jpg",
"zneg.jpg"
};
img::Image2D *textureImage;
for(int i = 0; i < 6; ++i) {
textureImage = new img::Image2D(name[i]);
gluBuild2DMipmaps(
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
GL_RGB8,
textureImage->width,
textureImage->height,
GL_RGB,
GL_UNSIGNED_BYTE,
textureImage->pixels
);
delete textureImage;
}
glEnable(GL_TEXTURE_CUBE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
}
void display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidTeapot(0.8);
glutSwapBuffers();
}
Here, all work fine, but when i use glTexImage2D in place of gluBuild2DMipmaps, it dosen’t work, there is no texturing. I use square textures of size 256x256, or 64x64. What’s wrong ?
thx.