Color blending with OpenGL
in
Programming Questions
•
2 years ago
So, bit of an intro here (this is my first post): I'm a freshman computer science student taking a CS elective course called "Interactive and Generative Art." We're doing a lot of stuff in Processing, and for a project, I'm making a color blending program.
It'll be quicker to explain with screenshots:
http://img28.imageshack.us/i/ex2i.jpg/
(That's not my actual program; I made that in MS Paint)
I'm using the ellipse function to make the colored circles. So my red circle is:
"fill(255, 0, 0);
ellipse(redX, redY, diameter, diameter);" etc. etc.
The blend function I'm currently using is
"gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);"
That works perfectly for some combinations, for example:
It takes the red circle (255, 0, 0) and the blue circle (0, 0, 255) and comes up with a purple circle (like it should)(255, 0, 255).
But when I blend say, red (255, 0, 0) and yellow (255, 255, 0) I run into problems, because it produces (510, 255, 0). From my observations, it treats anything above 255 as 255, so the result is still yellow.
Does anyone have any suggestions? If the colors were (red, yellow, blue) instead of (red, green, blue) it seems like it'd work almost perfectly, but that's not the case.
Sorry if that's a bit unclear, I can clarify if needed.
Thanks in advance!
It'll be quicker to explain with screenshots:
http://img28.imageshack.us/i/ex2i.jpg/
(That's not my actual program; I made that in MS Paint)
I'm using the ellipse function to make the colored circles. So my red circle is:
"fill(255, 0, 0);
ellipse(redX, redY, diameter, diameter);" etc. etc.
The blend function I'm currently using is
"gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);"
That works perfectly for some combinations, for example:
It takes the red circle (255, 0, 0) and the blue circle (0, 0, 255) and comes up with a purple circle (like it should)(255, 0, 255).
But when I blend say, red (255, 0, 0) and yellow (255, 255, 0) I run into problems, because it produces (510, 255, 0). From my observations, it treats anything above 255 as 255, so the result is still yellow.
Does anyone have any suggestions? If the colors were (red, yellow, blue) instead of (red, green, blue) it seems like it'd work almost perfectly, but that's not the case.
Sorry if that's a bit unclear, I can clarify if needed.
Thanks in advance!
1