Sign in to follow this  
StPapyna

How to load CUBEMAP from single picture file ?

Recommended Posts

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 [QUOTE] 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); }; [/QUOTE] The picture is actually wrong,but how to correct ? Thanks your reply.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this