0

I'm trying to make simple shading for a 2D OpenGL scene by placing semi-transparent black quads over the scene, but in certain places instead of darkening the scene it completely blacks it out. I'm using glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA) for the shader quads, and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) for all the other drawing underneath.

This normally works, dimming the area under the semi-transparent quad, but in certain situations it behaves oddly. When the area under the semi-transparent quad has only had one quad drawn behind it, it behaves normally. When another quad (or multiple quads) are drawn on top of the back quad, it sometimes behaves normally, sometimes blacks out the quad entirely, or sometimes blacks out everything beneath the last-drawn quad (e.g. if I had a red texture with a blue dot on top of it, the red beneath would be blacked out, but the blue dot would remain unchanged).

I thought this looked like the quads drawing in the wrong order, but I have GL_DEPTH_TEST disabled, so I'm not sure if this is odd behavior from the blending, misorder, or something else entirely. Any ideas as to what could be causing this?

tenorsax
  • 21,123
  • 9
  • 60
  • 107
  • At first blush, it sounds to me like a problem in the driver, not your code. – Jerry Coffin Aug 18 '12 at 03:45
  • What are your 'shader quads' ? Are these the ones supposed to darken their backgrounds ? – rotoglup Aug 18 '12 at 10:43
  • Yes. They're simple quads with `glColor4f(r, g, b, a)` used to darken. No textures. – user1607575 Aug 18 '12 at 13:45
  • @user1607575 Why such a 'complicated' blendFunc for darkening ? Wouldn't the classical `(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)` have been enough ? What is the color you're giving to your quads ? Moreover, use @ to reply, this sends a notification of your answers. – rotoglup Aug 18 '12 at 21:55

0 Answers0