From 485b813853fb34d05607ad4f2cb54751f21dd592 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Mon, 25 Nov 2024 02:29:00 +0100 Subject: [PATCH] Fix FPS calculation --- .../de/staropensource/engine/rendering/renderer/Renderer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rendering/src/main/java/de/staropensource/engine/rendering/renderer/Renderer.java b/rendering/src/main/java/de/staropensource/engine/rendering/renderer/Renderer.java index 768821e..e73d2f2 100644 --- a/rendering/src/main/java/de/staropensource/engine/rendering/renderer/Renderer.java +++ b/rendering/src/main/java/de/staropensource/engine/rendering/renderer/Renderer.java @@ -203,7 +203,7 @@ public final class Renderer { bgfx_dbg_text_printf(0, 0, 0x0f, "Time: " + NumberUtil.padNumbers(LocalTime.now().getHour(), 2) + ":" + NumberUtil.padNumbers(LocalTime.now().getMinute(), 2) + ":" + NumberUtil.padNumbers(LocalTime.now().getSecond(), 2)); bgfx_dbg_text_printf(0, 1, 0x0f, "Frames: " + Renderer.getFrameCount()); bgfx_dbg_text_printf(0, 2, 0x0f, "Frames/s: " + Renderer.getFramesPerSecond()); - bgfx_dbg_text_printf(0, 3, 0x0f, "Delta: " + Renderer.getDeltaTime()); + bgfx_dbg_text_printf(0, 3, 0x0f, "Delta: " + Renderer.getDeltaTime() + "s"); bgfx_dbg_text_printf(0, 4, 0x0f, "V-Sync mode: " + RenderingSubsystemConfiguration.getInstance().getVsyncMode().name()); bgfx_dbg_text_printf(0, 6, 0x0f, "Rendering time:"); for (String item : lastFrameTime.keySet()) { @@ -366,7 +366,7 @@ public final class Renderer { // Perform per-second operations if (System.currentTimeMillis() >= timesPSO) { // Calculate FPS count - framesPerSecond = 1 / deltaTime; + framesPerSecond = 1 / NumberUtil.calculateMeanDouble(deltaTimes); // Log frame count if (RenderingSubsystemConfiguration.getInstance().isDebugFrames())