How to mask out colors I need?

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.
Thanks!

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.