From d33465a56c74faeac06f65b53b3889270611b40f Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 14 Apr 2013 10:48:42 +0200 Subject: [PATCH] Better framerate throttling in UI --- Core/Core.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index 3c0b3d54b1..c71893d5f5 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -107,6 +107,7 @@ void Core_RunLoop() { while (!coreState) { time_update(); + double startTime = time_now_d(); UpdateScreenScale(); { { @@ -129,10 +130,13 @@ void Core_RunLoop() EndInputState(&input_state); } NativeRender(); + time_update(); // Simple throttling to not burn the GPU in the menu. #ifdef _WIN32 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(); } else if (!Core_IsStepping()) { GL_SwapBuffers();