cube map question
I''m learning cg and i''m reading the cg tutorial. I''m up to the bit on bump mapping and i was wondering for
uniform samplerCUBE normalizeCube
could you use the same cubemap for every object you want to render?
If so can you point me somewhere where i can get one. I''ve never used cubemaps before. is there anything you have to do in opengl to set them up?
Hi,
heres how you set up a cube map...
But before you do, you should check if it is availeable:
And you enable disable it just like GL_TEXTURE_2D:
heres how you set up a cube map...
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, SkyCubeMap);glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);gluBuild2DMipmaps(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, GL_RGB8, SkyBoxTexture[0].Width,SkyBoxTexture[0].Height,GL_RGB, GL_UNSIGNED_BYTE, SkyBoxTexture[0].Data);gluBuild2DMipmaps(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, GL_RGB8, SkyBoxTexture[1].Width,SkyBoxTexture[1].Height,GL_RGB, GL_UNSIGNED_BYTE, SkyBoxTexture[1].Data);gluBuild2DMipmaps(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, GL_RGB8, SkyBoxTexture[2].Width,SkyBoxTexture[2].Height,GL_RGB, GL_UNSIGNED_BYTE, SkyBoxTexture[2].Data);gluBuild2DMipmaps(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, GL_RGB8, SkyBoxTexture[3].Width,SkyBoxTexture[3].Height,GL_RGB, GL_UNSIGNED_BYTE, SkyBoxTexture[3].Data);gluBuild2DMipmaps(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, GL_RGB8, SkyBoxTexture[4].Width,SkyBoxTexture[4].Height,GL_RGB, GL_UNSIGNED_BYTE, SkyBoxTexture[4].Data);gluBuild2DMipmaps(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, GL_RGB8, SkyBoxTexture[5].Width,SkyBoxTexture[5].Height,GL_RGB, GL_UNSIGNED_BYTE, SkyBoxTexture[5].Data);
But before you do, you should check if it is availeable:
const GLubyte* str = glGetString(GL_EXTENSIONS);if(strstr((const char*)str, "GL_ARB_texture_cube_map") == NULL){MessageBox(NULL,"Your OpenGL Implementation Doesn''t Support Cube-Mapping!","Extension Missing!",MB_OK); return false;}
And you enable disable it just like GL_TEXTURE_2D:
glEnable(GL_TEXTURE_CUBE_MAP_ARB);glDisable(GL_TEXTURE_CUBE_MAP_ARB);
it means use an internal buffer format of Reg-Green-Blue with 8 bits per color channel, used to enforce 32bit color on textures (older ATI drivers for one seemed to select 16bit mode when only told to give GL_RGB, even if the window was in 32bit mode)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement