If I make a blue rectangle with a certain transparency, and a red rectangle on top of it with the same transparency
I get a purple rectangle where the two rectangles are on top of each other.
(See image below)
Now I need the blue and red rectangle without the purple part.
They should have the same transparency. So my tought was to write this to a buffer without transparency, so the blue rectangle isn’t visible.
And write the buffer with the transparency at once to the screen.
Each rectangle is from a Rectangle-class. The Rectangle-Class holds the function Draw.
This function has the following code
I’m unclear on whether or not you want the purple region to be blue, red or black.
Depth testing, as ZbuffeR suggested could do the trick. If you plan on using the depth buffer to cull out one of the quads you should draw your quads from nearest to farthest.
–
I see this as glass.
If I place Blue glass with Red glass on top of it it become purple.
Now I need stained glass, so the colors are next to each other instead of overlaying.
With depth testing it would work on reverse order only.
You can’t have “blend with black but not with color”.
If you want to simply erase previous color data, just disable blending, and tweak colors accordingly.
@ZbuffeR
That’s why I first need to write to a buffer / variable. After adding all graphics I have a buffer with solid colors.
With the right overlaying colors, and after that write it at once with transparency to the screen so OpenGL could blend the buffer.
Greetings
EDIT:
I read the colors from an XML-file so manually mixing the colors manually is no option
Kind of got the problem.
It work at least.
I use multi sampling on my project. So if I need a transparency it draws a part of the pixels.
When I draw 2 graphics with the same transparency the drawn pixels are exact on top of each other.
After all the buffer wasn’t needed at all,
Everyone thanks of their support.
Greetings