effects of alpha in clear colour

Started by
6 comments, last by aleks_1661 22 years, 5 months ago
please hold the abuse throwing for a few seconds * what is the point of the alpha value in glClearColor()? * what effects can it have if used correctly? * is it a dud? you may now start throwing abuse if you think it is necesary to the cause "For Queen and Country!" Edited by - aleks_1661 on November 18, 2001 10:22:03 PM

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

Advertisement
> what is the point of the alpha value in glClearColor()?

To clear the alpha buffer ?

Hum it does sound a pretty st... range question

Y.
Well the color buffer is not just RGB, it can be RGBA, so you can assign a value to A too. As for the effects, well, you can do stuff with the alpha test, the blend function ...
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
im not stupid. when you make a call to glClear() it fills the buffer with the specified colour but alpha seems to have no effect.


To clear the alpha buffer ? it makes no difference, in every test i have done.

In every book i have read it has not been used i thought it might be able to fade a scene, by clearing with less alpha each time, but it just clears the damn thing to black anyway. i need some usefull information.


"For Queen and Country!"

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

Ah, but then you have to change your blending function so that the alpha in the image masks the alpha of the pixels you render instead of the opposite.

glBlendFunc( src, dst )

src is used as a multiplier to the color of the pixel you are rendering, and dst as a multiplier to the color already in the image buffer

The "usual" :
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA )

Only the alpha of the pixel you are drawing matters (*_SRC_ALPHA). High alpha increases the weight of the pixel you are drawing, hence the opacity.

For a fadein, (never tried, but ...)

glBlendFunc( GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA );

Only the alpha of the pixel already in the image matters (*_DST_ALPHA). High alpha increases the weight of the pixel already in the image, hence its opacity.

There are more combos you can play with. Check the Blue Book, pages 112-115
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
cheers im going to experiment. thanks.


"there is no spoon"

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

Tell me if you get results.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Here''s something to try...

In your PIXELFORMATDESCRIPTOR, set it to overlay.
Then give a clear alpha.
See what it does.

This topic is closed to new replies.

Advertisement