I am using quite large RGB texture:
glTexImage2D(GL_TEXTURE_2D, 0, 3, 8192, 8192, 0, GL_LUMINANCE, GL_BYTE, NULL);
This texture is used to visualize live data from special HW scanner, which provides the data continuously (usually couple of scan lines every 10-50 ms). I am collecting the scans in buffer and then updating the texture in visualization thread by:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, currentScanLine, 8192, numScanLines, GL_LUMINANCE, GL_BYTE, scans);
currentScanLine = (currentScanLine + numScanLines) % 8192;
It works perfectly.
As a next step I wanted to visualize data from two or three scanners at the same time. My Idea was to use RGB texture and update individual RGB components (each component for one scanner). So, I created RGB texture:
glTexImage2D(GL_TEXTURE_2D, 0, 3, 8192, 8192, 0, GL_RGB, GL_BYTE, NULL);
and updated it:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, currentScanLine, 8192, numScanLines, GL_RED, GL_BYTE, scans);
The problem is that even I am updating only one component (RED), the other components (GREEN and BLUE) are overwritten by zeros. I was playing with
glPixelTransferf(GL_GREEN_SCALE, 0.0f);
glPixelTransferf(GL_BLUE_SCALE, 0.0f);
but it doesn’t help. The othter components are always overwritten. I want them to stay untouched. Is there any way to do accomplish that?
I know can use separate texturue for each scanner and combine them in pixel shader but it is more complicated and probably more GPU time consuming solution.
Any help appreciated.