In OpenGL for achieving a proper transparency effect I should use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
but with that blending function an alpha parameter in glClearColor
becomes meaningless. When I change an alpha parameter in glClearColor
I still get the same effect. When can I use the alpha parameter in glClearColor
? What kind of effects Can I achieve?
glClearColor
sets the color (and alpha value) a RGBA framebuffer will be cleared to with glClear(GL_COLOR_BUFFER_BIT)
. The framebuffer alpha value would be taken into account with GL_DST_ALPHA
or GL_ONE_MINUS_DST_ALPHA
blend functions.
However your regular on-screen window framebuffer usually doesn't carry an alpha value. Notable exceptions exist of course, for example transparent windows with the background shining through, but they're a bit tedious to set up, and will still receive all mouse events, even if over "transparent" areas.
Framebuffers with an alpha channel are mostly of interest als render to texture targets.
So in your case, the clear color is of no particular interest for you. You're much more likely interested in the 4th parameter of glColor4f
or textures with an alpha channel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With