From 051f3eaacc0bbe4e856b585cba07d8d35f92f4bd Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 21 Jul 2024 16:45:28 +0200 Subject: [PATCH] Add ApiInternalClass and OpenGL equivalent --- .../graphics/opengl/OpenGlInternalApi.java | 33 ++++++++++++++++ .../graphics/opengl/OpenGlSubsystem.java | 14 +++++++ .../graphics/classes/ApiInternalClass.java | 38 +++++++++++++++++++ .../graphics/classes/ApiMainClass.java | 12 +++++- 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlInternalApi.java create mode 100644 graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiInternalClass.java diff --git a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlInternalApi.java b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlInternalApi.java new file mode 100644 index 0000000..233d128 --- /dev/null +++ b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlInternalApi.java @@ -0,0 +1,33 @@ +/* + * 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.opengl; + +import de.staropensource.sosengine.graphics.classes.ApiInternalClass; +import de.staropensource.sosengine.graphics.classes.Window; +import org.jetbrains.annotations.NotNull; + +public class OpenGlInternalApi implements ApiInternalClass { + /** {@inheritDoc} */ + @Override + @NotNull + public Class getWindowClass() { + return de.staropensource.sosengine.graphics.opengl.classes.Window.class; + } +} diff --git a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java index 860fb57..a34e994 100644 --- a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java +++ b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/OpenGlSubsystem.java @@ -31,6 +31,7 @@ import de.staropensource.sosengine.base.types.EventPriority; import de.staropensource.sosengine.base.types.logging.LogIssuer; import de.staropensource.sosengine.base.utility.Miscellaneous; import de.staropensource.sosengine.graphics.GraphicsSubsystem; +import de.staropensource.sosengine.graphics.classes.ApiInternalClass; import de.staropensource.sosengine.graphics.classes.ApiMainClass; import de.staropensource.sosengine.graphics.classes.ApiManagementClass; import de.staropensource.sosengine.graphics.events.GraphicsApiErrorEvent; @@ -74,6 +75,18 @@ public final class OpenGlSubsystem implements ApiMainClass { */ private final LoggerInstance logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE)); + /** + * The Graphics API's internal API class. + * + * @see ApiInternalClass + * @since v1-alpha0 + * + * -- GETTER -- + * {@inheritDoc} + */ + @Getter + private ApiInternalClass internalApi; + /** * The Graphics API's management class. * @@ -133,6 +146,7 @@ public final class OpenGlSubsystem implements ApiMainClass { logger.crash("Unable to initialize GLFW"); // Initialize management class + internalApi = new OpenGlInternalApi(); management = new OpenGlManagement(); }); diff --git a/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiInternalClass.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiInternalClass.java new file mode 100644 index 0000000..f93fcea --- /dev/null +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiInternalClass.java @@ -0,0 +1,38 @@ +/* + * 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.classes; + +import org.jetbrains.annotations.NotNull; + +/** + * The interface for internal API access, used by the graphics subsystem. + * + * @since v1-alpha2 + */ +@SuppressWarnings({ "unused" }) +public interface ApiInternalClass { + /** + * Returns the {@link Window} class. + * + * @return {@link Window} class + */ + @NotNull + Class getWindowClass(); +} diff --git a/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiMainClass.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiMainClass.java index 5a84fc3..fbb0f53 100644 --- a/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiMainClass.java +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/ApiMainClass.java @@ -50,7 +50,17 @@ public interface ApiMainClass extends SubsystemMainClass { String getApiName(); /** - * Returns the API's management class. + * Returns the Graphics API's internal API access class. + * + * @return a {@link ApiInternalClass} + * @see ApiInternalClass + * @since v1-alpha2 + */ + @NotNull + ApiInternalClass getInternalApi(); + + /** + * Returns the Graphics API's management class. * * @return a {@link ApiManagementClass} * @see ApiManagementClass