Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opengl invert framebuffer pixels

I was wondering was the best way to invert the color pixels in the frame buffer is. I know it's possible to do with glReadPixels() and glDrawPixels() but the performance hit of those calls is pretty big.

Basically, what I'm trying to do is have an inverted color cross-hair which is always visible no matter what's behind it. For instance, I'd have an arbitrary alpha mask bitmap or texture, have it render without depth test after the scene is drawn, and all the frame buffer pixels under the masked (full alpha) pixels of the texture would be inverted.

I've been trying to do this with a texture, but I'm getting some strange results, also all the blending options I still find confusing.

like image 519
jay.lee Avatar asked Apr 17 '10 01:04

jay.lee


2 Answers

Give something like this a try:

glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
// render geometry
glDisable(GL_COLOR_LOGIC_OP);
like image 61
genpfault Avatar answered Nov 06 '22 04:11

genpfault


how about:

glEnable (GL_BLEND); 
glBlend (GL_ONE_MINUS_DST_COLOR, GL_ZERO);
like image 24
Nils Pipenbrinck Avatar answered Nov 06 '22 03:11

Nils Pipenbrinck