mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-01-27 15:08:55 -06:00
fix: Crash when framerate falls below 5 FPS (#359)
* This could work * Testing shows this to work fine, with the added benefit of lower CPU usage * This should do the trick then
This commit is contained in:
@@ -279,13 +279,15 @@ namespace hex {
|
||||
}
|
||||
|
||||
void Window::loop() {
|
||||
double timeout;
|
||||
this->m_lastFrameTime = glfwGetTime();
|
||||
while (!glfwWindowShouldClose(this->m_window)) {
|
||||
if (!glfwGetWindowAttrib(this->m_window, GLFW_VISIBLE) || glfwGetWindowAttrib(this->m_window, GLFW_ICONIFIED))
|
||||
glfwWaitEvents();
|
||||
else
|
||||
glfwWaitEventsTimeout(ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId) ? 0 : (this->m_lastFrameTime - glfwGetTime() + 1 / 5.0));
|
||||
|
||||
timeout = (1.0 / 5.0) - (glfwGetTime() - this->m_lastFrameTime);
|
||||
timeout = timeout > 0 ? timeout : 0;
|
||||
glfwWaitEventsTimeout(ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId) ? 0 : timeout);
|
||||
|
||||
this->frameBegin();
|
||||
this->frame();
|
||||
|
||||
Reference in New Issue
Block a user