From 1843db91af6cc46207a854e830ae1eebb7117a92 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 6 Jun 2021 19:16:53 +0200 Subject: [PATCH] fix: Drastically reduce CPU usage when using FPS limit --- source/window.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/window.cpp b/source/window.cpp index d28d1f2df..210d4228a 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -410,8 +410,7 @@ namespace hex { glfwSwapBuffers(this->m_window); - while (glfwGetTime() < this->m_lastFrameTime + 1 / (ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) ? this->m_targetFps : 5.0)) - std::this_thread::sleep_for(500us); + std::this_thread::sleep_for(std::chrono::milliseconds(u64((this->m_lastFrameTime + 1 / (ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) ? this->m_targetFps : 5.0) - glfwGetTime()) * 1000))); this->m_lastFrameTime = glfwGetTime(); }