From 294314112d3d1876ed4cb5fb09dc6d866aeb6b58 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Tue, 23 Apr 2024 15:42:03 +0800 Subject: [PATCH] Properly terminate when the window is closed by the user --- main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.cpp b/main.cpp index 482edbe..b1ec654 100644 --- a/main.cpp +++ b/main.cpp @@ -32,6 +32,11 @@ int main() { App *app = app_NewApp(); app->window = win; while (!app->wantQuit) { + // Check if the window is still open + // On Windows/MinGW, the loop stucks open when the window is closed + if (!IsWindow(win)) + break; + if (time_Since(frameCounter).microseconds >= 1000000) { // 1 sec /* Duration d = */ time_Reset(&frameCounter); char buf[128];