I drew several different colored polygons on the screen, now I need to draw another polygon of a different color, but this polygon should be drawn only on those pixels that have a certain color.
I draw each of the different colored polygons at the same time in my "layers" (= one color at a time). They can cover each other; a new layer covers all previous layers. The black color in the image is the "no polygons" area: empty space, and it should also be ignored.
So basically I just give out the polygons, and then the N'th (not the first) polygon layer should be masked by the next polygonal layer, and nothing else beneath it should be touched.
Image of the required method:

What method can I use to achieve OpenGL? I would prefer a non-shader solution for this, if possible (?).
The only way I can do at this time is to make each of the layers separately in memory, and then go through the pixels and merge the layers manually, but this seems like a very slow method, however, speed is important here.
source
share