From 34b9ac0d05c743bdbd86c173f7479b70a170247b Mon Sep 17 00:00:00 2001 From: okseby Date: Mon, 29 May 2023 03:31:31 -0400 Subject: [PATCH] Add Project Lombok to remove all getters and setters. --- pom.xml | 7 +++ src/main/java/com/okseby/core/Launcher.java | 13 +--- .../java/com/okseby/core/WindowManager.java | 63 ++++--------------- .../java/com/okseby/core/entity/Model.java | 14 ++--- 4 files changed, 26 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index 8e81f09..0a566b9 100644 --- a/pom.xml +++ b/pom.xml @@ -405,6 +405,13 @@ joml ${joml.version} + + + org.projectlombok + lombok + 1.18.28 + provided + \ No newline at end of file diff --git a/src/main/java/com/okseby/core/Launcher.java b/src/main/java/com/okseby/core/Launcher.java index a9730f0..258767e 100644 --- a/src/main/java/com/okseby/core/Launcher.java +++ b/src/main/java/com/okseby/core/Launcher.java @@ -2,12 +2,13 @@ package com.okseby.core; import com.okseby.core.test.TestGame; import com.okseby.core.utils.Constants; +import lombok.Getter; import org.lwjgl.Version; public class Launcher { - private static WindowManager window; - private static TestGame game; + @Getter private static WindowManager window; + @Getter private static TestGame game; public static void main(String[] args) { System.out.println("LWJGL Version: " + Version.getVersion()); @@ -23,12 +24,4 @@ public class Launcher { e.printStackTrace(); } } - - public static WindowManager getWindow() { - return window; - } - - public static TestGame getGame() { - return game; - } } diff --git a/src/main/java/com/okseby/core/WindowManager.java b/src/main/java/com/okseby/core/WindowManager.java index 1704586..0c3afca 100644 --- a/src/main/java/com/okseby/core/WindowManager.java +++ b/src/main/java/com/okseby/core/WindowManager.java @@ -1,5 +1,7 @@ package com.okseby.core; +import lombok.Getter; +import lombok.Setter; import org.joml.Matrix4f; import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFWErrorCallback; @@ -13,20 +15,17 @@ public class WindowManager { public static final float Z_NEAR = 0.01f; public static final float Z_FAR = 1000f; - private String title; + @Getter private long window; + @Getter private int width, height; + @Getter @Setter private String title; + @Getter @Setter private boolean resizeable, vsync; + @Getter private final Matrix4f projectionMatrix; - private int width, height; - private long window; - - private boolean resizeable, vSync; - - private final Matrix4f projectionMatrix; - - public WindowManager(String title, int width, int height, boolean vSync) { + public WindowManager(String title, int width, int height, boolean vsync) { this.title = title; this.width = width; this.height = height; - this.vSync = vSync; + this.vsync = vsync; projectionMatrix = new Matrix4f(); } @@ -73,12 +72,14 @@ public class WindowManager { GLFW.glfwMaximizeWindow(window); else { GLFWVidMode vidMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); + + assert vidMode != null; GLFW.glfwSetWindowPos(window, (vidMode.width() - width) / 2, (vidMode.height() - height) / 2); } GLFW.glfwMakeContextCurrent(window); - if (isvSync()) + if (isVsync()) GLFW.glfwSwapInterval(1); GLFW.glfwShowWindow(window); @@ -113,46 +114,6 @@ public class WindowManager { return GLFW.glfwWindowShouldClose(window); } - public String getTitle() { - return title; - } - - public void setTitle(String title) { - GLFW.glfwSetWindowTitle(window, title); - } - - public boolean isResizeable() { - return resizeable; - } - - public boolean isvSync() { - return vSync; - } - - public void setvSync(boolean vSync) { - this.vSync = vSync; - } - - public void setResizeable(boolean resizeable) { - this.resizeable = resizeable; - } - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - public long getWindow() { - return window; - } - - public Matrix4f getProjectionMatrix() { - return projectionMatrix; - } - public Matrix4f updateProjectionMatrix() { float aspectRatio = (float) width / height; return projectionMatrix.setPerspective(FOV, aspectRatio, Z_NEAR, Z_FAR); diff --git a/src/main/java/com/okseby/core/entity/Model.java b/src/main/java/com/okseby/core/entity/Model.java index 12084e7..754d02c 100644 --- a/src/main/java/com/okseby/core/entity/Model.java +++ b/src/main/java/com/okseby/core/entity/Model.java @@ -1,19 +1,13 @@ package com.okseby.core.entity; +import lombok.Getter; + public class Model { - private int id; - private int vertexCount; + @Getter private int id; + @Getter private int vertexCount; public Model(int id, int vertexCount) { this.id = id; this.vertexCount = vertexCount; } - - public int getId() { - return id; - } - - public int getVertexCount() { - return vertexCount; - } }