Fade In / Out effect on 2D

Hi there,

I am trying to make a fade in & out effect on 2D elements I show on the screen, whether it’s text I show or simply a 2D Quad with a texture on it.

Is there an easy trick to put an alpha value before showing the element and get something semi-transparent or invisible? Color blending?

Thanks.

Is there an easy trick to put an alpha value before showing the element and get something semi-transparent or invisible? Color blending?

Yes.
Enable blending and use GL_SOURCE_ALPHA,GL_ONE_MINUS_SOURCE_ALPHA for the blend equation.
Then just before you draw the UI element, use glColor4f (1,1,1, Alpha) where alpha is the transparency value between 0.0 -> 1.0.
if you are using a shader or GL 3.x core profile, then you’d need to send the alpha value in as a uniform instead.

Ha thanks!

Having worked a little bit with color functions, I was on the right track for this. That work.