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?
Can’t you preprocess these texture and store in a file with an OpenGL friendly format ?
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.
If your implementation supported SGIS_texture_color_mask , 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.