hi,
i want to have a sphere which reflects the environment. im generate the cubemaps and try to use them as a secondary texture for the sphere (sphere also has a 2d-texture). however, the sphere turns completely black. maybe someone can tell me where my mistake is?
here’s what id do:
//init cubemap (once)
glGenTextures(1,&g_uiCubemap);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,g_uiCubemap);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S,GL_MIRRORED_REPEAT_ARB);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T,GL_MIRRORED_REPEAT_ARB);
for (int p=0; p<6; p++)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+p, 0, GL_RGB8,g_CubeMapSize, g_CubeMapSize, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
//generate cubemap (once each frame)
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,g_uiCubemap);
glViewport(0,0,g_CubeMapSize,g_CubeMapSize);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0,1,0.2,4000.0);
glMatrixMode(GL_MODELVIEW);
for (int p=0; p<6; p++)
{
glLoadIdentity();
gluLookAt(/one of six directions startiong from origin/);
DrawScene();
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+p,0,GL_RGB8,0,0,g_CubeMapSize,g_CubeMapSize,0);
}
//render the sphere:
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, theTextures[0]); //the normal 2d texture
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,cubeMap);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
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);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
gluSphere(…);
thanks a lot for the help!