Hello everyone,
I’ve been making a small 2D game for a few years now in Windows XP. I recently bought a new laptop with Vista included and continued development on Vista instead. I have been running into a timing issue that I did not encounter in XP. From what I have read, a high resolution timer is enabled in Vista whenever a “multi-media” application is open. I’ve noticed that Internet Explorer counts as such an application.
I use a loop in a separate thread to call a draw method that draws everything. This loop has a Thread.sleep(x) to limit the cpu use. If I use x = 10 and have no other applications open, my game runs fine with around 8% cpu use on average (In reality, the above line sleeps for about 16 milliseconds). But when I open up IE to enable the high resolution timer, the cpu use goes up to 25%.
Ok, so its sleeping for 10 milliseconds instead of 16, meaning its drawing more often, so of course the performance would be more demanding. However I tried x = 16, 15, 17, etc, but the cpu usage is still abnormally high when the high resolution timer is on. Also, the FPS counter that I keep in my draw method reports an inconsistant and higher rate when the high resolution timer is on compared to when it is off. The only way to really fix this was to have x = 100, but of course the framerate becomes unacceptable for a simple 2D game in this case.
Has anyone run into this issue? Should I be handling the drawing differently? Any suggestions are appreciated.
Thank you.
I still have no idea whats causing the difference in cpu though, or how to do anything about it, so hopefully one of the other members here will have some insight.