Jump to content
  • Advertisement
Sign in to follow this  
zoret

OpenGL How create a cube texture 2 channels 16b

This topic is 4132 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

Hi, I need to create a 2 channels (16b) cube texture. This is equivalent to this D3D format : D3DFMT_G16R16 Any ideas how to do that ? Do I need to use a specific extension ? FYI it's for my opengl implemenation of virtual shadow depth cube texture (working on D3D9 only for now) Thank you for any help

Share this post


Link to post
Share on other sites
Advertisement
Well, after some searching on MSDN, I found that there's indeed a format called GL_LUMINANCE16_ALPHA16, which should give you two 16-bit channels.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc03_16jo.asp

I'm using GLEW for cube mapping support, but there's probably better ways if all you need is cube mapping. ;)
The MSDN link contains info on all kinds of texture formats, so I'd take a closer look at that article.


//Untested for actual use..
GLint width, height;
GLint *pos_x_ptr, *neg_x_ptr, *pos_y_ptr, *neg_y_ptr, *pos_z_ptr, *neg_z_ptr;
GLuint texobj;
texobj = glGenTextures(1, &texobj);
glBindTexture(GL_TEXTURE_CUBE_MAP, texobj);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_LUMINANCE16_ALPHA16, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pos_x_ptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_LUMINANCE16_ALPHA16, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, neg_x_ptr);

glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_LUMINANCE16_ALPHA16, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pos_y_ptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_LUMINANCE16_ALPHA16, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, neg_y_ptr);

glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_LUMINANCE16_ALPHA16, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pos_z_ptr);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_LUMINANCE16_ALPHA16, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, neg_z_ptr);


Share this post


Link to post
Share on other sites
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!