Greetings:
I am trying to set up a cubemap skybox in fixed-function. Code is below. All I see are white and black rectangles - textures don’t seem to draw at all. I know my getbmp function to read in the 6 cube textures is ok, because I tried it in a different (regular texture, not cubemap) program.
Btw, the texture coords are just a test to see one face of the cube (I know they need to be rotated for a practical skybox).
Any pointers as to what I am doing wrong?
Thanks in advance,
Sam
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
glGenTextures(1, &texture);
glEnable(GL_TEXTURE_CUBE_MAP);
BitMapFile *image[6];
image[0] = getbmp("../Textures/ForestCubemapTextures/posx.bmp");
image[1] = getbmp("../Textures/ForestCubemapTextures/negx.bmp");
image[2] = getbmp("../Textures/ForestCubemapTextures/posy.bmp");
image[3] = getbmp("../Textures/ForestCubemapTextures/negy.bmp");
image[4] = getbmp("../Textures/ForestCubemapTextures/posz.bmp");
image[5] = getbmp("../Textures/ForestCubemapTextures/negz.bmp");
glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
glTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_RGBA, 2048, 2048, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
for (int face = 0; face < 6; face++)
{
int target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
glTexSubImage2D(target, 0, 0, 0, 2048, 2048, GL_RGBA, GL_UNSIGNED_BYTE, image[face]);
}
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
void drawscene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBindTexture(GL_TEXTURE_CUBE_MAP, texture);
glBegin(GL_POLYGON);
glTexCoord3f(-1.0, -1.0, -1.0); glVertex3f(-100.0, -100.0, -99.0);
glTexCoord3f(1.0, -1.0, -1.0); glVertex3f(100.0, -100.0, -99.0);
glTexCoord3f(1.0, 1.0, -1.0); glVertex3f(100.0, 100.0, -99.0);
glTexCoord3f(-1.0, 1.0, -1.0); glVertex3f(-100.0, 100.0, -99.0);
glEnd();
glutSwapBuffers();
}