From f2fdc2ff0774ad464b0f671590a8a14e4694c961 Mon Sep 17 00:00:00 2001 From: Demorome Date: Mon, 12 Jan 2026 20:30:18 -0400 Subject: [PATCH] Process system events once per timestep interval --- src/Game.cs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Game.cs b/src/Game.cs index b2f2fcb..24be06f 100644 --- a/src/Game.cs +++ b/src/Game.cs @@ -299,20 +299,6 @@ private void Tick(bool processEvents) // Wait for the swapchain before event processing to minimize input latency. GraphicsDevice.WaitForSwapchain(MainWindow); - if (processEvents) - { - // Now that we are going to perform an update, let's handle SDL events. - // We'll process the system events immediately, and the input events before updating. - GatherSDLEvents(); - ProcessSystemEvents(); - } - - // Quit event came in, bail immediately. - if (QuitRequested) - { - return; - } - // Do not let the accumulator go crazy. var maxUpdateTime = FramePacingSettings.MaxUpdatesPerTick * FramePacingSettings.Timestep; if (AccumulatedUpdateTime > maxUpdateTime) @@ -337,6 +323,19 @@ private void Tick(bool processEvents) // Step once on the timestep interval. if (firstIteration) { + if (processEvents) + { + // Process system events once per timestep interval. + // SDL events were already gathered above. + ProcessSystemEvents(); + } + + // Quit event came in, bail immediately. + if (QuitRequested) + { + return; + } + Step(); firstIteration = false; }