From 45307ab842924c4dfac119fea0ff05154544b37d Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 26 Jul 2024 13:42:00 +0200 Subject: [PATCH] Move a few exceptions from glfw to graphics subsystem --- .../graphics/glfw/GlfwSubsystem.java | 2 +- .../glfw/classes/GlfwManagementClass.java | 2 +- .../graphics/glfw/classes/GlfwWindow.java | 4 +-- .../graphics/opengl/classes/OpenGlWindow.java | 5 ++-- .../exceptions/NoMonitorsFoundException.java | 28 +++++++++++++++++++ .../exceptions/NotOnMainThreadException.java | 2 +- .../WindowCreationFailureException.java | 2 +- graphics/src/main/java/module-info.java | 2 ++ 8 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NoMonitorsFoundException.java rename graphics/{glfw/src/main/java/de/staropensource/sosengine/graphics/glfw => src/main/java/de/staropensource/sosengine/graphics}/exceptions/NotOnMainThreadException.java (94%) rename graphics/{glfw/src/main/java/de/staropensource/sosengine/graphics/glfw => src/main/java/de/staropensource/sosengine/graphics}/exceptions/WindowCreationFailureException.java (95%) diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/GlfwSubsystem.java b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/GlfwSubsystem.java index 8d912ca..455fb20 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/GlfwSubsystem.java +++ b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/GlfwSubsystem.java @@ -30,7 +30,7 @@ import de.staropensource.sosengine.base.types.logging.LogIssuer; import de.staropensource.sosengine.base.utility.Miscellaneous; import de.staropensource.sosengine.graphics.events.GraphicsErrorEvent; import de.staropensource.sosengine.graphics.glfw.exceptions.GlfwInitializationException; -import de.staropensource.sosengine.graphics.glfw.exceptions.NotOnMainThreadException; +import de.staropensource.sosengine.graphics.exceptions.NotOnMainThreadException; import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFWErrorCallback; diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwManagementClass.java b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwManagementClass.java index ef566a2..995b377 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwManagementClass.java +++ b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwManagementClass.java @@ -25,7 +25,7 @@ import de.staropensource.sosengine.base.types.logging.LogIssuer; import de.staropensource.sosengine.base.utility.Miscellaneous; import de.staropensource.sosengine.graphics.classes.api.ApiManagementClass; import de.staropensource.sosengine.graphics.classes.Window; -import de.staropensource.sosengine.graphics.glfw.exceptions.NotOnMainThreadException; +import de.staropensource.sosengine.graphics.exceptions.NotOnMainThreadException; import lombok.Getter; import org.jetbrains.annotations.NotNull; diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java index fa973e5..eea8c51 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java +++ b/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/classes/GlfwWindow.java @@ -29,8 +29,8 @@ import de.staropensource.sosengine.graphics.events.GraphicsApiErrorEvent; import de.staropensource.sosengine.graphics.events.InputEvent; import de.staropensource.sosengine.graphics.glfw.callbacks.KeyCallback; import de.staropensource.sosengine.graphics.glfw.callbacks.MouseButtonCallback; -import de.staropensource.sosengine.graphics.glfw.exceptions.NotOnMainThreadException; -import de.staropensource.sosengine.graphics.glfw.exceptions.WindowCreationFailureException; +import de.staropensource.sosengine.graphics.exceptions.NotOnMainThreadException; +import de.staropensource.sosengine.graphics.exceptions.WindowCreationFailureException; import de.staropensource.sosengine.graphics.types.window.VsyncMode; import de.staropensource.sosengine.graphics.types.window.WindowMode; import lombok.Getter; diff --git a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/OpenGlWindow.java b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/OpenGlWindow.java index fe3815d..c809eb6 100644 --- a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/OpenGlWindow.java +++ b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/OpenGlWindow.java @@ -22,9 +22,8 @@ package de.staropensource.sosengine.graphics.opengl.classes; import de.staropensource.sosengine.base.exceptions.UnexpectedThrowableException; import de.staropensource.sosengine.base.types.vectors.Vec2i; import de.staropensource.sosengine.graphics.glfw.classes.GlfwWindow; -import de.staropensource.sosengine.graphics.glfw.exceptions.NotOnMainThreadException; -import de.staropensource.sosengine.graphics.glfw.exceptions.WindowCreationFailureException; -import de.staropensource.sosengine.graphics.types.window.VsyncMode; +import de.staropensource.sosengine.graphics.exceptions.NotOnMainThreadException; +import de.staropensource.sosengine.graphics.exceptions.WindowCreationFailureException; import de.staropensource.sosengine.graphics.types.window.WindowMode; import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL; diff --git a/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NoMonitorsFoundException.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NoMonitorsFoundException.java new file mode 100644 index 0000000..4259358 --- /dev/null +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NoMonitorsFoundException.java @@ -0,0 +1,28 @@ +/* + * STAROPENSOURCE ENGINE SOURCE FILE + * Copyright (c) 2024 The StarOpenSource Engine Contributors + * Licensed under the GNU Affero General Public License v3 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.staropensource.sosengine.graphics.exceptions; + +/** + * Thrown when trying to get one or multiple monitors but none are found. + * + * @since v1-alpha2 + */ +@SuppressWarnings({ "unused" }) +public final class NoMonitorsFoundException extends Exception {} diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/exceptions/NotOnMainThreadException.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NotOnMainThreadException.java similarity index 94% rename from graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/exceptions/NotOnMainThreadException.java rename to graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NotOnMainThreadException.java index 4decc51..54edab2 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/exceptions/NotOnMainThreadException.java +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/NotOnMainThreadException.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.staropensource.sosengine.graphics.glfw.exceptions; +package de.staropensource.sosengine.graphics.exceptions; /** * Thrown when trying to communicate with the Graphics API over a non-main thread. diff --git a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/exceptions/WindowCreationFailureException.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/WindowCreationFailureException.java similarity index 95% rename from graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/exceptions/WindowCreationFailureException.java rename to graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/WindowCreationFailureException.java index 85138b1..e637daf 100644 --- a/graphics/glfw/src/main/java/de/staropensource/sosengine/graphics/glfw/exceptions/WindowCreationFailureException.java +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/exceptions/WindowCreationFailureException.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.staropensource.sosengine.graphics.glfw.exceptions; +package de.staropensource.sosengine.graphics.exceptions; import org.jetbrains.annotations.NotNull; diff --git a/graphics/src/main/java/module-info.java b/graphics/src/main/java/module-info.java index 7aca7da..7182260 100644 --- a/graphics/src/main/java/module-info.java +++ b/graphics/src/main/java/module-info.java @@ -16,6 +16,7 @@ module sosengine.graphics { exports de.staropensource.sosengine.graphics.classes; exports de.staropensource.sosengine.graphics.classes.api; exports de.staropensource.sosengine.graphics.events; + exports de.staropensource.sosengine.graphics.exceptions; exports de.staropensource.sosengine.graphics.types.input; exports de.staropensource.sosengine.graphics.types.window; @@ -24,6 +25,7 @@ module sosengine.graphics { opens de.staropensource.sosengine.graphics.classes; opens de.staropensource.sosengine.graphics.classes.api; opens de.staropensource.sosengine.graphics.events; + opens de.staropensource.sosengine.graphics.exceptions; opens de.staropensource.sosengine.graphics.types.input; opens de.staropensource.sosengine.graphics.types.window; }