So usually during gameplay, through every run of the game loop I draw loads of new stuff onto the screen
However, I just implemented a pause feature
It’s exactly what you expect: press “P”, the screen darkens, and it says “Game Paused”. Press “P” again and the game play resumes. Nothing special.
All I did was encapsulate the rendering/updating block in an “if(paused){…}” and make a basic method to update whether “paused” should be true or not. You get the idea
Now, here’s the weird part. I only draw the pause screen ONCE, when the game is initially paused, not every step. It seems like a bit of a waste to draw the same thing over and over again when it’s not changing.
The drawing works, but the screen jitters a lot. What I mean is that, if the player character is moving while “P” is pressed, through the darkened screen you can see the game world jolt back and forth very quickly.
Also, the “pause screen” (which is the darkened screen and the text) flickers on and off very quickly.
Now, why should this happen? I’m 100% sure that there’s no rendering code that escaped the “if(paused){…}” and I only draw the paused screen ONCE (when the played initially hits “P”)
So why is this happening? Is this a peculiarity of OpenGL? How can it be fixed?
Thanks