From 8fe75cf6cbc5f270b8a6c8f5c91bb62f9e6c1185 Mon Sep 17 00:00:00 2001 From: 493msi <493msi@gmail.com> Date: Thu, 24 Sep 2020 02:52:21 +0200 Subject: [PATCH] Minor cleanup in Display and DisplayBuilder --- NEXT_RELEASE_DRAFT.md | 10 +++++++--- UPDATE_NOTES.md | 1 + .../tefek/pluto/engine/display/Display.java | 19 ++++++++++++++----- .../pluto/engine/display/DisplayBuilder.java | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/NEXT_RELEASE_DRAFT.md b/NEXT_RELEASE_DRAFT.md index c128521..41bc15f 100644 --- a/NEXT_RELEASE_DRAFT.md +++ b/NEXT_RELEASE_DRAFT.md @@ -29,10 +29,14 @@ * The stage manager should be relatively low-overhead and allow multiple instances * Allow stages to be inherited from, creating a stack-like structure -* The initial release of `[PlutoCommandParser]` - +* The initial minimal release of `[PlutoCommandParser]` + ## Features targeted for 20.2.0.0-alpha.3 * `[PlutoLib]` Completely redo the ModLoader system * The current implementation is a result of 5 years of feature creep - * Large scale API changes \ No newline at end of file + * Large scale API changes, however the general idea should stay the same + * Rethink the class loader system. +* `[PlutoAudio]` Integrate the Audio API with the Stage API +* Improve upon the support of thread-local Pluto instances + * The long term goal is to allow an unlimited amount of Pluto applications at any given time diff --git a/UPDATE_NOTES.md b/UPDATE_NOTES.md index 95c0ad9..fc1582f 100644 --- a/UPDATE_NOTES.md +++ b/UPDATE_NOTES.md @@ -16,6 +16,7 @@ can now only be modified only through public setters * `[PlutoLib]` Added the `ThreadSensitive` annotation * `[PlutoCore]` Refactored `InputBus` and added several convenience methods * `[PlutoCore]` Refactored input callbacks +* `[PlutoStatic]` Slight cleanup in the `Display` and `DisplayBuilder` classes ## 20.2.0.0-alpha.1 * `[PlutoLib#cz.tefek.pluto.io.logger]` Refactored the Logger subsystem diff --git a/plutostatic/src/main/java/cz/tefek/pluto/engine/display/Display.java b/plutostatic/src/main/java/cz/tefek/pluto/engine/display/Display.java index 3ee7221..465a506 100644 --- a/plutostatic/src/main/java/cz/tefek/pluto/engine/display/Display.java +++ b/plutostatic/src/main/java/cz/tefek/pluto/engine/display/Display.java @@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL33; import org.lwjgl.opengl.GLDebugMessageARBCallback; import org.lwjgl.system.MemoryUtil; +import cz.tefek.pluto.annotation.ThreadSensitive; import cz.tefek.pluto.engine.gl.GLDebugInfo; import cz.tefek.pluto.io.logger.Logger; import cz.tefek.pluto.io.logger.SmartSeverity; @@ -17,6 +18,7 @@ import cz.tefek.pluto.io.logger.SmartSeverity; * @author 493msi * @since 0.2 */ +@ThreadSensitive public class Display { int width; @@ -30,7 +32,7 @@ public class Display private long windowPointer; - private GLFWErrorCallback glfwErrorCallback; + private final GLFWErrorCallback glfwErrorCallback; private GLFWWindowSizeCallback resizeCallback; @@ -51,10 +53,17 @@ public class Display if (this.windowPointer == MemoryUtil.NULL) { this.destroy(); - throw new IllegalStateException("Failed to create the GLFW window..."); + throw new IllegalStateException("Failed to create a window..."); } GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); + + if (vidmode == null) + { + this.destroy(); + throw new IllegalStateException("Failed to detect the primary monitor."); + } + GLFW.glfwSetWindowPos(this.windowPointer, (vidmode.width() - this.width) / 2, (vidmode.height() - this.height) / 2); GLFW.glfwMakeContextCurrent(this.windowPointer); @@ -194,10 +203,10 @@ public class Display { this.glDebugCallback = new GLDebugMessageARBCallback() { @Override - public void invoke(int source, int type, int id, int severity, int length, long message, long userParam) + public void invoke(int source, int type, int id, int severity, int length, long messagePtr, long userParam) { - var mes = GLDebugMessageARBCallback.getMessage(length, message); - Logger.log(SmartSeverity.WARNING, mes); + var message = GLDebugMessageARBCallback.getMessage(length, messagePtr); + Logger.log(SmartSeverity.WARNING, message); } }; diff --git a/plutostatic/src/main/java/cz/tefek/pluto/engine/display/DisplayBuilder.java b/plutostatic/src/main/java/cz/tefek/pluto/engine/display/DisplayBuilder.java index 0212fb2..c4fe319 100644 --- a/plutostatic/src/main/java/cz/tefek/pluto/engine/display/DisplayBuilder.java +++ b/plutostatic/src/main/java/cz/tefek/pluto/engine/display/DisplayBuilder.java @@ -4,7 +4,7 @@ import org.lwjgl.glfw.GLFW; public class DisplayBuilder { - private Display display; + private final Display display; public DisplayBuilder() {