View Full Version : Fading entire screen
07-06-2010, 11:46 PM
I require to fade out the entire screen(a gtk window that occupies the entire screen) to black/some color and fade in the content for the window back again.
Opengl does this by alpha texture blending I believe but really don't understand the procedure in detail regarding swapping buffers etc.
Can anybody please provide me with workable sample code so that I could be able to pick it up from there?
07-07-2010, 01:28 AM
The simplest is to simply draw a large black quad covering the whole window, and play with alpha to fade gradually.
Searching on these forums you will see code.
EDIT : here it is :
07-09-2010, 01:47 AM
I did as suggested but the window turns black immediately with no fade effect.
07-09-2010, 03:16 AM
Then you are doing it wrong.
Are you really sure you enabled blending ? And drawing the black quad last ? With alpha going from 1 to 0 ?
Show your code.
07-12-2010, 12:17 AM
float alpha = 1.0f;
//Draw Quad that fits the screen
//(found the coords with try-and-error principle;))
//INSERT YOUR FUNCTION THAT SWAPS
alpha -= 0.01f ;
if (alpha <= 0.0f)
07-12-2010, 02:12 AM
You totally forgot to draw your scene for each iteration.
You know the step I called "-draw scene (render the "window")" ?
07-12-2010, 02:55 AM
I saw the steps (Step 1 you had mentioned about)
-draw scene (render the "window")
-enable blending :
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-alpha goes from 1.0f to 0.0f for a fade to black
-draw full screen quad
But still do not know what GL API is to be called for it. My strong point is only GTK and not GL.
07-12-2010, 03:47 AM
Can you please add the missing pieces to the code and publish the same?
07-12-2010, 09:40 AM
OK I think I misread your original post.
Do you want to mix GTK and OpenGL rendering on the same window ?
This is probably not possible. You will have to somehow draw the GTK content on a GL texture.
So you have to :
- take some screenshot of the GTK content
- create a GL texture with this content
- draw a textured quad with this texture in the "draw scene" step
07-12-2010, 11:14 PM
Any sample code for this, any pointers would do a lot of help. kind of stuck.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.