Cube map help
i use this code to create a cube map:
/**********************/
pImage = LoadJPG(filename);
glGenTextures(1, &CubeMap);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, CubeMap);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,0, GL_RGBA8, pImage->sizeX,pImage->sizeY, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,0, GL_RGBA8, pImage->sizeX,pImage->sizeY, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,0, GL_RGBA8, pImage->sizeX,pImage->sizeY, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,0, GL_RGBA8, pImage->sizeX,pImage->sizeY, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,0, GL_RGBA8, pImage->sizeX,pImage->sizeY, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,0, GL_RGBA8, pImage->sizeX,pImage->sizeY, 0, textureType, GL_UNSIGNED_BYTE, pImage->data);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
/**********************/
now,please, could someone tell me why the cube map is ALWAYS displayed in b/w ?!?!?!?!
have you loaded that JPG image into a normal GL_TEXTURE2D & displayed it?
I noticed you are loading it as a GL_RGBA8, which means that each pixel has an 8bit alpha chanel, is this correct?
I guess what I'm asking is...
have you verified the correct operation of this line:
pImage = LoadJPG(filename);
& that the image is actually a 4byte per pixel image
I wasn't aware that JPG images had an alpha channel, you might start with that, I would recommend using "GL_RGB" instead :)
I noticed you are loading it as a GL_RGBA8, which means that each pixel has an 8bit alpha chanel, is this correct?
I guess what I'm asking is...
have you verified the correct operation of this line:
pImage = LoadJPG(filename);
& that the image is actually a 4byte per pixel image
I wasn't aware that JPG images had an alpha channel, you might start with that, I would recommend using "GL_RGB" instead :)
Whatsoever you do, do it heartily as to the Lord, and not unto men.
Also, as I don't see you creating/uploading any mipmaps, you should only use:
I don't see why you set those values twice as you do now.
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
I don't see why you set those values twice as you do now.
Luke already pointed it out, but please let me ask it again : Have you tried uploading the textures as six independent 2D textures and see what is rendered when you map them to six different surfaces ?
Ya, do what vincoof said. also...
Tell me that "CubeMap" is declared as an "unsigned int"
Have you specified these 3 things:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
Or maybe these 3 instead:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
& then these after either one of the above groups of 3:
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
so basically... make sure you are specifying the texture generation parameter for texture coordinate generation mode (for S,T, & R) & be sure you enable those texture coordinate generation modes too ALL BEFORE YOU make any calls to glTexImage2D(). that might help.
also... I don't know why you are bothering to generate a texture with GL_RGBA8 when you'll never find a JPG that has an alpha channel, or am I delerious here? just try it with GL_RGB even if its only to humor me. :)
Tell me that "CubeMap" is declared as an "unsigned int"
Have you specified these 3 things:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
Or maybe these 3 instead:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
& then these after either one of the above groups of 3:
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
so basically... make sure you are specifying the texture generation parameter for texture coordinate generation mode (for S,T, & R) & be sure you enable those texture coordinate generation modes too ALL BEFORE YOU make any calls to glTexImage2D(). that might help.
also... I don't know why you are bothering to generate a texture with GL_RGBA8 when you'll never find a JPG that has an alpha channel, or am I delerious here? just try it with GL_RGB even if its only to humor me. :)
Whatsoever you do, do it heartily as to the Lord, and not unto men.
Quote: Original post by Luke Miklos
also... I don't know why you are bothering to generate a texture with GL_RGBA8 when you'll never find a JPG that has an alpha channel, or am I delerious here? just try it with GL_RGB even if its only to humor me. :)
Obviously JPG pictures don't benefit any alpha channel, but it could be useful to specify an internal format with an alpha channel in case the texture is sub-copied later.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement