PDA

View Full Version : Dynamic cube map generation and rendering



brucemangy
06-15-2004, 01:59 PM
hi,
I succefully obtained a cube map at runtime
but in 6 GL_TEXTURE_2D only.
it looks correct on a textured cube.

I'm trying to use them with GL_TEXTURE_CUBE_MAP_ARB.
found some examples but i don't know where i am wrong. :confused:
if you seen any error, notify me please :D
any comment is welcome.

/* UpdateCubeMap()*/

for (i=0;i<6;i++)
{
glLoadIdentity();
/* appropriate call to glulookat(); */
glPushMatrix();
glViewport(0,0,256,256);

glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );

RenderScene();

glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, WP->textures[52] /*cube map texture*/);

glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X _ARB+i, 0, 0, 0, 0, 0, 256, 256);
glTexParameteri(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB +i,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB +i,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB +i,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB +i,GL_TEXTURE_WRAP_T,GL_CLAMP);
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
}
/* rendering */


glPushMatrix();

glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, WP->textures[52] /*cube map texture*/);

glTranslatef(...);
glRotatef(...);
glScalef(...);

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);

glutSolidTeapot(1.0);

glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_CUBE_MAP_ARB);

glPopMatrix();thx

--
brucemangy :cool:

Tom Nuydens
06-15-2004, 10:55 PM
Maybe if you were to explain what goes wrong? Dropping a few glGetError() calls in there should also go a long way.

-- Tom

plasmonster
06-15-2004, 10:59 PM
yeah, this has been discussed at length in the beginners forum...

Tom Nuydens
06-15-2004, 11:16 PM
Ah! In that case...