From 773f86216ab4df433c3ce02d416a3139da4a7a91 Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:23:04 +0100 Subject: [PATCH 1/3] Put process to sleep when minimized until it receives an event --- engine/system/win/sys_main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/system/win/sys_main.cpp b/engine/system/win/sys_main.cpp index 3a01cdd..8974a85 100644 --- a/engine/system/win/sys_main.cpp +++ b/engine/system/win/sys_main.cpp @@ -842,14 +842,16 @@ bool sys_main_c::Run(int argc, char** argv) // Run frame loop while (exitFlag == false) { - glfwPollEvents(); + if (minimized) + glfwWaitEventsTimeout(); // while minimized, puts process to sleep until it receives an event + else + glfwPollEvents(); auto wnd = (GLFWwindow*)video->GetWindowHandle(); if (glfwWindowShouldClose(wnd)) { Exit(); break; } - if (minimized == false) - core->Frame(); + core->Frame(); if (threadError) { Error(threadError); From 8e0f9cd960b841891af48f8cbdb73b5ea7281fc3 Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:31:47 +0100 Subject: [PATCH 2/3] glfwWaitEvents is the right one --- engine/system/win/sys_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/system/win/sys_main.cpp b/engine/system/win/sys_main.cpp index 8974a85..6f5c72b 100644 --- a/engine/system/win/sys_main.cpp +++ b/engine/system/win/sys_main.cpp @@ -843,7 +843,7 @@ bool sys_main_c::Run(int argc, char** argv) // Run frame loop while (exitFlag == false) { if (minimized) - glfwWaitEventsTimeout(); // while minimized, puts process to sleep until it receives an event + glfwWaitEvents(); // while minimized, puts process to sleep until it receives an event else glfwPollEvents(); auto wnd = (GLFWwindow*)video->GetWindowHandle(); From a5ed67d8e80b29042398f97737cddff0c2c68b82 Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Thu, 28 Mar 2024 16:31:58 +0100 Subject: [PATCH 3/3] Allow lua to process some calculations --- engine/system/win/sys_main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/system/win/sys_main.cpp b/engine/system/win/sys_main.cpp index 6f5c72b..bd9ff4f 100644 --- a/engine/system/win/sys_main.cpp +++ b/engine/system/win/sys_main.cpp @@ -842,10 +842,12 @@ bool sys_main_c::Run(int argc, char** argv) // Run frame loop while (exitFlag == false) { - if (minimized) - glfwWaitEvents(); // while minimized, puts process to sleep until it receives an event - else + if (minimized) { + glfwWaitEventsTimeout(0.1); + } + else { glfwPollEvents(); + } auto wnd = (GLFWwindow*)video->GetWindowHandle(); if (glfwWindowShouldClose(wnd)) { Exit();