Slowly fading to death

I am trying to make a function that slowly fades to black when the player dies. I have all the settings (attenuation, etc.), but I don’t know how to make an OpenGL color mask or something that is required to actually fade the screen to black.

I tried using glClearColor and then glClear, but the results were completely black. I know that it would be technically possible to do this by changing each color attribute of my code dynamically, but I wonder if there is an easier way.

+4
source share
1 answer

A simple way would be to draw one small square over the entire viewing window after drawing everything else. You can draw it black with an alpha value and use the blend function so that the alpha value determines how many blacks to use. You probably want to disable depth testing.

+6
source

Source: https://habr.com/ru/post/1448049/


All Articles