In a game I'm working on I have a pretty "normal" setup, with a main loop that calls a draw() function at the bottom. The game uses delta timing, and can run as fast as it likes without messing up the game timing.
The problem is that this loads the CPU a lot, and that's bad if you are running something in the background or have a laptop and don't want to drain the battery.
There is an option in the game to wait for the monitor, this adds a simple VWait before the draw() function is called. I thought using this would also prevent the game from using up all CPU, but I was wrong. If I use a VWait the CPU load goes up to almost 100%. If I add a timer it still goes up that high. But if I keep the timer and remove the VWait, it does NOT go up! FPS is stable at 75 at all times, but if I add the VWait the CPU load goes up to 100%. What is this?? Has anybody run into this problem?
--
Martin Gunnarsson
The problem is that this loads the CPU a lot, and that's bad if you are running something in the background or have a laptop and don't want to drain the battery.
There is an option in the game to wait for the monitor, this adds a simple VWait before the draw() function is called. I thought using this would also prevent the game from using up all CPU, but I was wrong. If I use a VWait the CPU load goes up to almost 100%. If I add a timer it still goes up that high. But if I keep the timer and remove the VWait, it does NOT go up! FPS is stable at 75 at all times, but if I add the VWait the CPU load goes up to 100%. What is this?? Has anybody run into this problem?
--
Martin Gunnarsson