Problem with blending in openGL (Color bar example)
Can anyone give some clues as to why when I try to render the color bar quad below
It appears like this:
Here is my rendering code:
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_ONE, GL.GL_ZERO);
gl.glBlendEquation(GL.GL_FUNC_ADD);
gl.glEnable(GL.GL_ALPHA_TEST);
gl.glAlphaFunc(GL.GL_GREATER, 0.01f);
// do the drawing...
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_开发者_JAVA技巧ALPHA_TEST);
I'm sure the solution is simple and I'm just having a brainfart but it's just one of those days! Thanks for the help!
What kind of blending are you trying to perform? To simply draw something without any color mixing or alpha channels you don't even have to play around with GL_BLEND
or GL_ALPHA_TEST
(leave both disabled). GL_BLEND
is used to define how to add different "layers" of color (usually on how to apply alpha channels) while GL_ALPHA_TEST
decides what alpha values to respect/ignore. Also check your vertex colors when rendering the quad (try to render a unicolor quad without texture, e.g. using magenta).
However looking at your images I'd guess you somehow disabled drawing to your red color channel (glColorMask()
) - although there's yellow, which confuses me.
There was a problem with RGBA getting swapped around when I imported the PNG file.
精彩评论