Reputation: 411
I am building an iOS app with Open GL ES 2.0. Simple drawing application.
If I draw on top of a clear framebuffer with some opacity value less than one, what exactly am I blending WITH?
Some setup:
If I have a framebuffer cleared with absolute clear color...
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT)
With blending set as such:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
[self render]
glDisable(GL_BLEND);
And then I draw a simple quad over that with 50% opacity. Say...
gl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);
What color would I expect out?
The real application of this question is that I would like to draw some things into a translucent view. That is to say, I really want my GL code to to blend with the view UNDERNEATH my view in iOS. If anybody has more specific advice on that, I'd love to hear it, too!
Upvotes: 4
Views: 1333
Reputation: 57149
The resulting color would be the one you drew with—red, with 50% opacity. If your GL view is sitting on top of another view (and isn’t opaque), the result will be identical to what you’d get with any other red-with-50%-opacity content on top of the other view. glBlendFunc
and the like only affect GL drawing in your view; they don’t affect how your it gets composited with other views.
Upvotes: 1