1
0
mirror of synced 2025-02-20 04:01:01 +01:00

fix: Drastically reduce CPU usage when using FPS limit

This commit is contained in:
WerWolv 2021-06-06 19:16:53 +02:00
parent eaacb4d102
commit 1843db91af

View File

@ -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();
}