Jump to content
  • Advertisement
Sign in to follow this  
StPapyna

How to load CUBEMAP from single picture file ?

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!