i have a strange and at my eyes inexplicable trouble with opengl:
I am worlking on the nutty cubemap tutorial. I managed to construct correctly the skybox. Next to that i try to render the six projections of the skyobx, and print em on the cubemap stuff.
Now i am using these transformations:
float CubeMapRots[6][4] = { //4, cos it’s angle, then XYZ component of that angle.
{ -90.0f, 0.0f, 1.0f, 0.0f },
{ 90.0f, 0.0f, 1.0f, 0.0f },
{ -90.0f, 1.0f, 0.0f, 0.0f },
{ 90.0f, 1.0f, 0.0f, 0.0f },
{ 180.0f, 1.0f, 0.0f, 0.0f },
{ 180.0f, 0.0f, 0.0f, 1.0f },
};
(just copied from nutty’s page)
in this piece of code:
void DynamycCubeMap()
{
glViewport(0,0,128,128);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90,1.0,1,5000);
glMatrixMode(GL_MATRIX_MODE);
for (int keel=0;keel<6;keel++)
{
glClear(GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(CubeMapRots[keel][0], CubeMapRots[keel][1], CubeMapRots[keel][2], CubeMapRots[keel][3]);
if(keel==0| |keel==1)
{
glRotatef(180,0,0,1);
}
RenderSkyBox();
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, global.texID);
glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_CUBE_MAP_EXT,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT+keel,0,GL_RGB8,0,0,128,128,0);
glFinish();
glDisable(GL_TEXTURE_CUBE_MAP_EXT);
}}
Reshape(global_width,global_height);
}
looking at it , i see no problem in theory, but when i use it, it just renders on the cube map 6 times the first face of the skybox. This is impossible! Even if the xfoms aren’t correct, the should at least change view when i rendere the scene on the back buffer. If i comment the glLoadIdentity, the image in the cubemap changes. It loads the six images (in a wrong way,c ause if i don’t reser the MODELVIEW matrix i can’t find the right rotation angles. Just why it can’t work this way??? Where am i doing The Wrong Thing?