From 6e57f72ac22f66eaad181641955711857bf40406 Mon Sep 17 00:00:00 2001 From: Speiger Date: Thu, 30 Sep 2021 14:09:03 +0200 Subject: [PATCH] Added some extra new features -Added: Clearing Depth Buffer before UI Renders. -Added: Rotation reference into facing. -Added: Access to the currentFrame -Code Cleanup --- .../src/coreengine/application/Application.java | 16 ++++++++++++++-- .../speiger/src/coreengine/math/misc/Facing.java | 7 +++++++ .../src/coreengine/rendering/gui/GuiManager.java | 1 + .../utils/tasks/MainThreadTaskProcessor.java | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/speiger/src/coreengine/application/Application.java b/src/main/java/speiger/src/coreengine/application/Application.java index b1966b9..093b8b9 100644 --- a/src/main/java/speiger/src/coreengine/application/Application.java +++ b/src/main/java/speiger/src/coreengine/application/Application.java @@ -47,7 +47,7 @@ public abstract class Application protected FontManager fonts = new FontManager(); protected ProjectionBuffer projectionBuffer; protected GuiManager uiManager; - + public void run() { GLFWErrorCallback.createPrint(System.err).set(); @@ -110,12 +110,14 @@ public abstract class Application public abstract Window createWindow(WindowProvider provider) throws Exception; public void preinit() {} public abstract void init(File file); + public void preUpdate() {} public abstract void update(); public abstract void render(float particalTicks); public abstract void destroy(); protected final void updateInternal() { + preUpdate(); if(uiManager != null) { clientProfiler.start("UI"); @@ -178,6 +180,11 @@ public abstract class Application return timer; } + public FontManager getFonts() + { + return fonts; + } + public GuiManager getUiManager() { return uiManager; @@ -192,4 +199,9 @@ public abstract class Application { return gpuProfiler; } -} + + public long getFrame() + { + return executor.frame; + } +} \ No newline at end of file diff --git a/src/main/java/speiger/src/coreengine/math/misc/Facing.java b/src/main/java/speiger/src/coreengine/math/misc/Facing.java index 332b74f..d67953a 100644 --- a/src/main/java/speiger/src/coreengine/math/misc/Facing.java +++ b/src/main/java/speiger/src/coreengine/math/misc/Facing.java @@ -20,6 +20,7 @@ public enum Facing final Axis axis; final Vec2i offset; final boolean positive; + final Rotation rotation; private Facing(int direction, int rotation, String display, Axis axis, Vec2i offset) { @@ -29,6 +30,7 @@ public enum Facing this.axis = axis; this.offset = offset; positive = index < 2; + this.rotation = Rotation.fromFacing(this); } public int getIndex() @@ -88,6 +90,11 @@ public enum Facing return getRotation(); } + public Rotation toRotation() + { + return rotation; + } + public Facing rotate(int amount) { return byIndex(index + amount); diff --git a/src/main/java/speiger/src/coreengine/rendering/gui/GuiManager.java b/src/main/java/speiger/src/coreengine/rendering/gui/GuiManager.java index 478b1bd..1b262df 100644 --- a/src/main/java/speiger/src/coreengine/rendering/gui/GuiManager.java +++ b/src/main/java/speiger/src/coreengine/rendering/gui/GuiManager.java @@ -156,6 +156,7 @@ public abstract class GuiManager implements IWindowListener protected Vec2i start() { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GLUtils.DEBTH_TEST.push(false); GLUtils.CULL_FACE.push(false); GLUtils.BLEND.setFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA).push(true); diff --git a/src/main/java/speiger/src/coreengine/utils/tasks/MainThreadTaskProcessor.java b/src/main/java/speiger/src/coreengine/utils/tasks/MainThreadTaskProcessor.java index 61a269a..acc7670 100644 --- a/src/main/java/speiger/src/coreengine/utils/tasks/MainThreadTaskProcessor.java +++ b/src/main/java/speiger/src/coreengine/utils/tasks/MainThreadTaskProcessor.java @@ -69,7 +69,7 @@ public class MainThreadTaskProcessor ITask task = tasks.dequeue(); try { - task.execute(); + task.execute(); } catch(InterruptedException e) {