From 3900bdcf0f398905b86b9f4a6480046002a0d072 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Fri, 14 Feb 2025 21:22:53 +0530 Subject: [PATCH] match drawn fps to tick rate always, except for when vsync --- src/Main.hx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Main.hx b/src/Main.hx index c2388f72..ecfe4ee6 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -145,7 +145,10 @@ class Main extends hxd.App { // }); } + static var updateDT:Float; + override function update(dt:Float) { + updateDT = dt; super.update(dt); if (loaded) { ProfilerUI.begin(); @@ -177,6 +180,19 @@ class Main extends hxd.App { ProfilerUI.end(); } super.render(e); + + #if hl + static var dtAccumulator; + dtAccumulator += updateDT; + if (Settings.optionsSettings.fpsLimit <= 0) { + e.driver.present(); + } else { + if (dtAccumulator >= 1.0 / Settings.optionsSettings.fpsLimit) { + e.driver.present(); + dtAccumulator = 0.0; + } + } + #end } static function main() {