I have been trying to make a function that slowly fades to black once the player dies. I have everything setup (fading, etc…), but I don’t know how to make an OpenGL color mask or whatever it takes to actually fade the screen to black.
I have tried using glClearColor and then glClear, but the results were just completely black. I know that it would technically be possible to do so by editing each color attribute of my code dynamically, but I’m wondering if there is a simpler way.
A simple way might be to draw a single quad over the entire viewport after drawing everything else. You could draw it black with an alpha value and use a blend function to let the alpha value determine how much of the black to use. You would probably want to disable depth testing.