Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Opacity is the Alpha, not transparency It means you can not see it at all when it's 0. When it is 1 you can fully see it. You can see it at half power, if it's 0.5f.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top