Hello there.
I want to fade what i already have accumulated in my frame buffer to specific color.
For starters, simple fade to black.
So each frame i draw a quad big enough to fill the screen, with glColor4f(0.0f,0.0f,0.0f, fade ), where fade is set to a low value (0.001, for example), and i do not clear the frame buffer.
My understanding is that the blending is performed with the following formula:
result = sfactor * source + dfactor * destination
Where source is pixel RGB value of incoming data, destination is pixel RGB value of data present in framebuffer and sfactor and dfactor are defined in glBlendFunc( GLenum sfactor, GLenum dfactor ).
Since what i really want is to just reduce all pixel RGB values to 0, i thought i could just set glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA), which would give me 0 * source + 0.999 * destination (i know the fading process would actually ‘slow down’ with such setting, but nevermind that for now).
Here are my init settigs:
glEnable(GL_BLEND);
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDisable(GL_ALPHA_TEST);
Well, it doesnt work. The whole screen becomes black immediately. However, it kind of works with glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA). Kind of, because for pixel of RGB 255,255,255, for some odd reason it stops at 63,63,63. This confuses me even more. Why would GL_ONE matter, since the RGB values of source are all 0 anyway? And why does it stop at 63,63,63?
Thanks.