I am new to FBOs and this issue has been driving me nuts for hours. I am interested in finding a solution to what I'm asking rather than an alternative. This is on Android.
I'm creating a framebuffer, then I'm drawing a circle to the texture attached to it. Then I'm drawing that texture to the default framebuffer like it's a regular texture. All is wonderful and displays as expected...
... except for the fact that the texture is completely opaque not only where I'm drawing the circle. I want all other areas to be transparent and only the circle part of the texture to be visible. More precisely, what I want to 'fill' my texture with transparent pixels, then draw my circle over them, then render this texture to the default framebuffer and be able to see what's behind it. How can I do that? Is it even possible? Or maybe there's a way to keep my texture opaque and tell OpenGL not to render, say, the black pixels from it?
I found a similar question, but the checked answer doesn't help. The comment underneath it suggests using glClear
(I assume it refers to glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
), but I did that after every glBindFramebuffer
and it still did nothing. I also read about enabling alpha blending, so I did glEnable(GL_BLEND)
and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
after every glBindFramebuffer
and my texture stayed opaque.
The other answer suggests it's platform dependent, so I'm looking for an Android solution.