PDA

View Full Version : OpenGL and alpha masks



klaus1983_2
06-26-2009, 05:18 AM
Hey,

i have a problem. I would like to set an alpha mask to the whole screen and the mask should stay over all my linux apps like gnome, firefox and so on ...

how can i do this? can anybody paste an short code? thx a lot
klaus

SoulCollector
07-29-2009, 02:27 AM
I have the same problem too. Is there any way to change the alpha value for the entire framebuffer?

Haven't found any solution yet.

Dark Photon
07-29-2009, 05:38 AM
I have the same problem too. Is there any way to change the alpha value for the entire framebuffer?
A number of solutions are possible given your somewhat vague description.

What do you want differently than what this gives you?:

glClearColor( 0,0,0, 0.12345 );
glClear( GL_COLOR_BUFFER_BIT );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE );

Specifically, what in your shading math do you want to work out differently?

SoulCollector
07-29-2009, 08:11 AM
Ok, i'll try to explain it.

I'm working on my diploma thesis and i'm writing an application that can simulate graphics from a special embedded system on my pc. I'm using OpenGL for graphic functions, and so far everything worked fine except for one small problem.

In the embedded application, there is a function


fade( fadingvalue )

which basically multiplies every color pixel in the framebuffer with "fadingvalue". This function is called repeatedly in a loop and so i can use it to fade the screen in or out.

My problem is that i don't know how to do this in OpenGL. What i need is a way to multiply every pixel's color and alpha value by a factor.

I already tried using glReadPixels and multiplying every pixel in a loop, but it slows the application down, so i would only use it if there is no alternative.

Ilian Dinev
07-29-2009, 08:46 AM
Multiplicative blending or alpha-blending, draw a black fullscreen quad with specified alpha.

SoulCollector
07-30-2009, 07:11 AM
Yes, that helped a lot.

Thanks.