diff --git a/rendering/src/main/java/de/staropensource/engine/rendering/RenderingSubsystemConfiguration.java b/rendering/src/main/java/de/staropensource/engine/rendering/RenderingSubsystemConfiguration.java index d0ac7fef3..5255d5646 100644 --- a/rendering/src/main/java/de/staropensource/engine/rendering/RenderingSubsystemConfiguration.java +++ b/rendering/src/main/java/de/staropensource/engine/rendering/RenderingSubsystemConfiguration.java @@ -338,7 +338,7 @@ public final class RenderingSubsystemConfiguration extends Configuration { renderingAdapter = RenderingAdapter.ANY; vsyncMode = VsyncMode.OFF; - maximumFramesPerSecond = 0; + maximumFramesPerSecond = 60; } /** {@inheritDoc} */ 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 563d4c069..768821e30 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 @@ -101,17 +101,22 @@ public final class Renderer { private static long frameCount = 0L; /** - * Contains the delta time, also - * known as the render time. + * Contains the delta time. *
- * Updated every second. + * Delta time is the time in seconds + * between the last and current frame. + *
+ * Updated every frame. * * @since v1-alpha9 * -- GETTER -- * Returns the delta time, also * known as the render time. *
- * Updated every second. + * Delta time is the time in seconds + * between the last and current frame. + *
+ * Updated every frame. * * @return delta time * @since v1-alpha9 @@ -140,6 +145,11 @@ public final class Renderer { * Contains the time it took * to calculate the last frame. *
+ * Note: The {@code Waiting} count may be + * negative if the renderer is lagging behind. + * No waiting will be performed internally if + * this count is {@code <0}. + *
* Updated every frame.
*
* @since v1-alpha9
@@ -187,15 +197,22 @@ public final class Renderer {
/** {@inheritDoc} */
@Override
public void run() {
- int offset = 2;
+ int offset = 7;
bgfx_dbg_text_clear(0, false);
- bgfx_dbg_text_printf(0, 0, 0x0f, "It's " + 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, "LFT.size(): " + lastFrameTime.size());
+ 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, 4, 0x0f, "V-Sync mode: " + RenderingSubsystemConfiguration.getInstance().getVsyncMode().name());
+ bgfx_dbg_text_printf(0, 6, 0x0f, "Rendering time:");
for (String item : lastFrameTime.keySet()) {
bgfx_dbg_text_printf(0, offset, 0x0f, item + ": " + lastFrameTime.get(item) + "ms");
offset += 1;
}
+ try {
+ Thread.sleep(0);
+ } catch (InterruptedException ignored) {}
}
});
@@ -271,11 +288,13 @@ public final class Renderer {
*/
@SuppressWarnings({ "InfiniteLoopStatement" })
private static void render() throws Throwable {
- long previousFrameCount = 0L; // Frame count one second ago
- LinkedList