Better framerate throttling in UI

This commit is contained in:
Henrik Rydgard 2013-04-14 10:48:42 +02:00
parent 422f08721d
commit d33465a56c

View file

@ -107,6 +107,7 @@ void Core_RunLoop()
{ {
while (!coreState) { while (!coreState) {
time_update(); time_update();
double startTime = time_now_d();
UpdateScreenScale(); UpdateScreenScale();
{ {
{ {
@ -129,10 +130,13 @@ void Core_RunLoop()
EndInputState(&input_state); EndInputState(&input_state);
} }
NativeRender(); NativeRender();
time_update();
// Simple throttling to not burn the GPU in the menu. // Simple throttling to not burn the GPU in the menu.
#ifdef _WIN32 #ifdef _WIN32
if (globalUIState != UISTATE_INGAME) { if (globalUIState != UISTATE_INGAME) {
Sleep(15); double sleepTime = 16.666 - (time_now_d() - startTime) * 1000.0;
if (sleepTime > 0.0)
Sleep((int)sleepTime);
GL_SwapBuffers(); GL_SwapBuffers();
} else if (!Core_IsStepping()) { } else if (!Core_IsStepping()) {
GL_SwapBuffers(); GL_SwapBuffers();