color masking a glTexSubImage2D call

I’ve got a pbo that exceeds the max texture dimension. The data is actually 3d voxel data. I’m processing the data in Cuda via a pbo binding… but also need access to the same data in glsl for display. I could easily fit the data in 2 separate textures… and that’s probably the route I’ll end up taking… but I wanted to try if I could use a multi channel texture to stuff it all into one texture id;

I want to copy a chunk of data to the RED channel and then copy the next chunk of data to the green channel. By default this doesn’t work, and it’s in the spec; If you copy just the GL_RED component to an RGB texture it will set the other components to 0. So I’m looking for the equivalent of say glColorMask… if glColorMask worked on glTexSubImage2D I would do this;

glBindBufferARB(); // bind very large pbo
glTexSubImage2D(…, GL_RED, GL_FLOAT, 0);

glTexSubImage2D(…, GL_GREEN, GL_FLOAT, offset);

Any ideas other than using multiple textures?

render to texture :
draw textured quad with red texture
draw textured quad with green texture
get the resulting texture.
red and green can be deleted.

Yes that would certainly work in theory… I’m a little concerned about memory footprint and performance… the texture I’m rendering to will be 8192x8192… I’ve never tried pulling off setting up an fbo that large. My past experience makes me doubtfull. If this ends this up doubling or tripling the memory footprint then I’m shot out of the water…

Still seems that if you can copy to a certain region of a texture you should be able to copy to a certain channel…

Anyway I’ll give this a shot… Thanks --vmh

Bind the texture, you try to fill with glTexImage2D, onto an FBO.
Use glColorMask() to mask the appropriate channels.
You can then use glDrawPixels to fill the bound texture with the data stored in the PBO.
That should do the trick.