Fading with OpenGL is very easy. In this code snippet I will show you how to fade from the current image on the screen to any other color. This function will also be cpu speed indepentent which means that the fade will take allways the same time whatever processor you have.
I use the STimer class from the code section to calculate the time. You could also use any other time function or class.
So this function will generate a fade to black that will take exactly 'delay' milliseconds. You can use this function everywhere in your code. Notice that the screen won't be updated/animated during the fade. The screen that is in the window when the fade starts will be "overdrawn" until it has reached the desired color. You can also fade to white or red or whatever you want. You only have to specify the color in the code.
If you want the screen being updated during the fade, insert the appropriate drawing function before the quad is drawn. Also don't forget to add winmm.lib to your project if you are using STimer. Otherwise there might be some problems ..
That's all! If you have problems or questions simply m@il me. Happy Coding!