From 75df797b41884a10a55f824004ec05b382271cba Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 16 Nov 2023 21:14:55 +0100 Subject: [PATCH] impr: Unlock framerate for the first few seconds to load UI quickly --- main/gui/source/window/window.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index c64583836..84cf18905 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -164,6 +164,7 @@ namespace hex { } void Window::loop() { + u64 frameCount = 0; while (!glfwWindowShouldClose(this->m_window)) { this->m_lastFrameTime = glfwGetTime(); @@ -179,7 +180,8 @@ namespace hex { TaskManager::getRunningTaskCount() > 0 || this->m_buttonDown || this->m_hadEvent || - !this->m_pressedKeys.empty(); + !this->m_pressedKeys.empty() || + frameCount < 100; // Calculate the time until the next frame const double timeout = std::max(0.0, (1.0 / 5.0) - (glfwGetTime() - this->m_lastFrameTime)); @@ -204,6 +206,7 @@ namespace hex { } this->fullFrame(); + frameCount += 1; // Limit frame rate // If the target FPS are below 15, use the monitor refresh rate, if it's above 200, don't limit the frame rate