Minor cleanup in Display and DisplayBuilder

This commit is contained in:
493msi 2020-09-24 02:52:21 +02:00
parent 93ef85f804
commit 8fe75cf6cb
4 changed files with 23 additions and 9 deletions

View File

@ -29,10 +29,14 @@
* The stage manager should be relatively low-overhead and allow multiple * The stage manager should be relatively low-overhead and allow multiple
instances instances
* Allow stages to be inherited from, creating a stack-like structure * 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 ## Features targeted for 20.2.0.0-alpha.3
* `[PlutoLib]` Completely redo the ModLoader system * `[PlutoLib]` Completely redo the ModLoader system
* The current implementation is a result of 5 years of feature creep * The current implementation is a result of 5 years of feature creep
* Large scale API changes * 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

View File

@ -16,6 +16,7 @@ can now only be modified only through public setters
* `[PlutoLib]` Added the `ThreadSensitive` annotation * `[PlutoLib]` Added the `ThreadSensitive` annotation
* `[PlutoCore]` Refactored `InputBus` and added several convenience methods * `[PlutoCore]` Refactored `InputBus` and added several convenience methods
* `[PlutoCore]` Refactored input callbacks * `[PlutoCore]` Refactored input callbacks
* `[PlutoStatic]` Slight cleanup in the `Display` and `DisplayBuilder` classes
## 20.2.0.0-alpha.1 ## 20.2.0.0-alpha.1
* `[PlutoLib#cz.tefek.pluto.io.logger]` Refactored the Logger subsystem * `[PlutoLib#cz.tefek.pluto.io.logger]` Refactored the Logger subsystem

View File

@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL33;
import org.lwjgl.opengl.GLDebugMessageARBCallback; import org.lwjgl.opengl.GLDebugMessageARBCallback;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import cz.tefek.pluto.annotation.ThreadSensitive;
import cz.tefek.pluto.engine.gl.GLDebugInfo; import cz.tefek.pluto.engine.gl.GLDebugInfo;
import cz.tefek.pluto.io.logger.Logger; import cz.tefek.pluto.io.logger.Logger;
import cz.tefek.pluto.io.logger.SmartSeverity; import cz.tefek.pluto.io.logger.SmartSeverity;
@ -17,6 +18,7 @@ import cz.tefek.pluto.io.logger.SmartSeverity;
* @author 493msi * @author 493msi
* @since 0.2 * @since 0.2
*/ */
@ThreadSensitive
public class Display public class Display
{ {
int width; int width;
@ -30,7 +32,7 @@ public class Display
private long windowPointer; private long windowPointer;
private GLFWErrorCallback glfwErrorCallback; private final GLFWErrorCallback glfwErrorCallback;
private GLFWWindowSizeCallback resizeCallback; private GLFWWindowSizeCallback resizeCallback;
@ -51,10 +53,17 @@ public class Display
if (this.windowPointer == MemoryUtil.NULL) if (this.windowPointer == MemoryUtil.NULL)
{ {
this.destroy(); 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()); 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.glfwSetWindowPos(this.windowPointer, (vidmode.width() - this.width) / 2, (vidmode.height() - this.height) / 2);
GLFW.glfwMakeContextCurrent(this.windowPointer); GLFW.glfwMakeContextCurrent(this.windowPointer);
@ -194,10 +203,10 @@ public class Display
{ {
this.glDebugCallback = new GLDebugMessageARBCallback() { this.glDebugCallback = new GLDebugMessageARBCallback() {
@Override @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); var message = GLDebugMessageARBCallback.getMessage(length, messagePtr);
Logger.log(SmartSeverity.WARNING, mes); Logger.log(SmartSeverity.WARNING, message);
} }
}; };

View File

@ -4,7 +4,7 @@ import org.lwjgl.glfw.GLFW;
public class DisplayBuilder public class DisplayBuilder
{ {
private Display display; private final Display display;
public DisplayBuilder() public DisplayBuilder()
{ {