View Full Version : how to mask out colors I need?

04-28-2004, 09:35 PM
I have an OpenGL DC with a picture drawn on it. The picture has backgroud color BgColor. I want to draw on this DC a polygon with color PolyColor, so that any pixel under this polygon which is equal to BgColor, will PolyColor. If a pixel color is equal to PolyColor, it must be inversed. The picture is a some lines and rectangles drawn on BgColor. The problem, that I get ready image, and do not draw it myself. So I can't use any buffers (stensil, accumulate, etc.). And I can't find any function, which converts any color to a color I need. Only color's components, that doesn't much for me. In short, if somebody knows how to help me or where I can ask this question or find any usefull info, please tell me.

04-29-2004, 11:45 AM
Depending on the hardware and performance wanted, I see 2 solutions :

1) basic hardware, no need for great performance :
use glReadPixels to retrieve the framebuffer pixels into an array. Do your color conversions with the CPU. Then draw the array with glDrawPixels.

2) hardware with fragment shader support :
do it with a shader with the GPU.

Hope it helps.