tags:

views:

27

answers:

1

Exposition:

1) My viewport is 800x600
2) I have tex1 = frame buffer object; rendered to a texture, 800x600
3) I have tex2 = frame buffer object; rendered to a texture, 800x600

Now, I want to create the following image on the screen:

tex1 _on top of_ tex2.

Where tex1 is black, display tex2's pixel.
Else, display tex1's pixel.

Is there a way I can do this last step entirely on the GPU (it seems like just bit twiddling + displaying to screen). My current solution involves 1) reading tex1 & tex2 back to CPU's memory 2) doing the array ops on the CPU and 3) sending it back to the GPU, then display it. However, it seems like I should be able to do this entirely on the GPU.

Thanks!

+1  A: 

If you're on a recent-enough version of OpenGL, this sounds like trivial work for a fragment shader program.

unwind
I'd prefer something that does not require I rewrite my own shaders (as I do use the fixed functionality matrix manipulation/lighting schemes).
anon