How to load CUBEMAP from single picture file ?

Started by
-1 comments, last by StPapyna 17 years, 9 months ago
I found some HDR scene picture to make IBL effect,but whatever HDRShop or PS ,makes out the single cube map contained 6 faces,so how to load it ? Just a BMP ? My code is below,thanks
void CPixel::LoadTextureFromHorCUBEMAP(const char* szFileName,GLuint& id) { GLenum cube[6] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; glGenTextures(1,&id); glBindTexture(GL_TEXTURE_CUBE_MAP, id); 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_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_REPEAT); AUX_RGBImageRec *TextureImage; TextureImage = auxDIBImageLoad(szFileName); if(!TextureImage){ cout<<"Error Load Hor CubeMap"<<endl; exit(-1); } GLsizei XUnit = TextureImage->sizeX / 4; GLsizei YUnit = TextureImage->sizeY / 3; GLsizei Section = XUnit*YUnit*sizeof; glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 3,XUnit, YUnit, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data + Section*1); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 3,XUnit, YUnit, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data + Section*3); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 3,XUnit, YUnit, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data + Section*4); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 3,XUnit, YUnit, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data + Section*5); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 3,XUnit, YUnit, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data + Section*6); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 3,XUnit, YUnit, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data + Section*8); }; The picture is actually wrong,but how to correct ? Thanks your reply.

This topic is closed to new replies.

Advertisement