1
0
mirror of synced 2024-12-01 02:37:18 +01:00

impr: Unlock framerate for the first few seconds to load UI quickly

This commit is contained in:
WerWolv 2023-11-16 21:14:55 +01:00
parent 1136556a0d
commit 75df797b41

View File

@ -164,6 +164,7 @@ namespace hex {
} }
void Window::loop() { void Window::loop() {
u64 frameCount = 0;
while (!glfwWindowShouldClose(this->m_window)) { while (!glfwWindowShouldClose(this->m_window)) {
this->m_lastFrameTime = glfwGetTime(); this->m_lastFrameTime = glfwGetTime();
@ -179,7 +180,8 @@ namespace hex {
TaskManager::getRunningTaskCount() > 0 || TaskManager::getRunningTaskCount() > 0 ||
this->m_buttonDown || this->m_buttonDown ||
this->m_hadEvent || this->m_hadEvent ||
!this->m_pressedKeys.empty(); !this->m_pressedKeys.empty() ||
frameCount < 100;
// Calculate the time until the next frame // Calculate the time until the next frame
const double timeout = std::max(0.0, (1.0 / 5.0) - (glfwGetTime() - this->m_lastFrameTime)); const double timeout = std::max(0.0, (1.0 / 5.0) - (glfwGetTime() - this->m_lastFrameTime));
@ -204,6 +206,7 @@ namespace hex {
} }
this->fullFrame(); this->fullFrame();
frameCount += 1;
// Limit frame rate // 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 // If the target FPS are below 15, use the monitor refresh rate, if it's above 200, don't limit the frame rate