Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glBlendFunc and glClearColor alpha parameter

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?

like image 303
Irbis Avatar asked Dec 26 '22 22:12

Irbis


1 Answers

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.

like image 173
datenwolf Avatar answered Jan 11 '23 13:01

datenwolf