View Full Version : Loading textures from separate channels

12-10-2004, 09:59 AM
I am loading a 3D texture but the data is stored on the computer in separate contiguous channels. Right now I am creating a temporary buffer and filling up its red, green, and blue channels, then passing that to OpenGL. This is inefficient, though. It would be nice if I could just point OpenGL at the raw memory. I don't think this can be done with pixel packing or the GL_RED, GL_GREEN, and GL_BLUE pixel formats.

Am I wrong? Is there some way to do load a texture to OpenGL, with an RGB internal format, one channel at a time?

12-10-2004, 03:29 PM
Can't you preprocess these texture and store in a file with an OpenGL friendly format ?

12-10-2004, 04:13 PM
Unfortunately, no. This is a scientiffic application with a lot of other functionality. I am thinking I may just go with separate textures and sampling all n textures in a fragment program. That would reduce runtime performance slightly but give a gain in setup speed and memory usage. Runtime performance would also scale better with the number of channels in use.


12-13-2004, 11:07 AM
If your implementation supported SGIS_texture_color_mask (http://oss.sgi.com/projects/ogl-sample/registry/SGIS/texture_color_mask.txt) , you could do it. You would call TexImage2D with a NULL data pointer, then loop over setting the mask and calling TexSubImage2D for each color component. However, I don't think any non-SGI implementation ever supported that extension. :(