0

I call

    gl.glClearColor(*[ 0., 0., 0.0, a])
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

Then I draw my scene.

If a is zero, it appears that nothing is cleared and the buffer appears to be stuff from other framebuffers. If a is one, the buffer appears clear, but when I blend in rectangles, I start to see stuff from other framebuffers.

Why is this and how can I fix it?

I have specified 0 depht buffer bits and 8 alpha buffer bits:

gl_format = QSurfaceFormat()
gl_format.setVersion(4, 1)
gl_format.setAlphaBufferSize(8)
gl_format.setDepthBufferSize(0)
gl_format.setProfile(QSurfaceFormat.CoreProfile)
gl_format.setSamples(8)
Neil G
  • 32,138
  • 39
  • 156
  • 257
  • 1
    I don't see what you need any alpha bits in the color buffer for. You only use blending based on the source alpha, never the destination alpha. However, your description sounds like you are in a scenario where the destination alpha seems to have some effect, by blending the whole framebuffer against something else. If so, you should make sure you write alpha 1.0 to every pixel of your color buffer. – derhass May 08 '16 at 13:18
  • 1
    I strongly suspect that the actual problem is not what's shown in the question here. I could only speculate, but for example you might not have the right framebuffer bound when `glClear()` is called. – Reto Koradi May 08 '16 at 17:36
  • @derhass: you got it, having alpha bits in the color buffer was for some reason letting other windows that are behind my application leak through. Removing those bits fixed everything. Feel free to add an answer for the benefit of other people. – Neil G May 10 '16 at 01:34
  • @RetoKoradi Nice idea, but I'm using Qt, and I am drawing immediately after clearing into the framebuffer bound by Qt. – Neil G May 10 '16 at 01:35

0 Answers0