hi folks,
i am making some experiments with cubemaps… can anyone tell me why my cubemap looks upside down??? ok i can flip textures, but i’d like a more “scientific” explanation.
Here is my code:
generation:
GLubyte data[2562563];
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
for(int i=0;i<6;i++)
{
GENERATE THE PIXELS DATA
glTexParameterf(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if(i==4)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+5, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
if(i==5)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+4, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
else
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
// glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i,0,GL_RGB8,0,0,256,256,0);
}
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
}
and here is the rendering:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,texture);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
gluSphere(sphere, 3.0f, 64, 64);
glutSwapBuffers();
glutPostRedisplay();
nothing too exotic… I use GL_REFLECTION_MAP, cause if i try to set the texture generation to GL_SPHERE_MAP, it just craps all the textures… And that is anothere interesting topic… Why a spherical generated tex mapping won’t work on a simple sphere? In the afternoon i’ll try to build the same stuff with a “custom” sphere, and hand made normals… meanwhile…
thanks for any advice