Remove unused methods, finalize class

This commit is contained in:
JeremyStar™ 2024-09-28 21:47:15 +02:00
parent 5e829771a7
commit 3bd6a26e59
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -50,7 +50,7 @@ import static org.lwjgl.glfw.GLFW.*;
* @since v1-alpha2 * @since v1-alpha2
*/ */
@SuppressWarnings({ "JavadocDeclaration" }) @SuppressWarnings({ "JavadocDeclaration" })
public class GlfwWindow extends Window { public final class GlfwWindow extends Window {
/** /**
* Contains the {@link #identifier} used by GLFW. * Contains the {@link #identifier} used by GLFW.
* *
@ -105,26 +105,16 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected final void initializeWindow() throws Exception { protected void initializeWindow() {
createGlfwWindow(); // Create the GLFW window createGlfwWindow(); // Create the GLFW window
initializeGlfwWindow(); // Call GLFW window initialization method
} }
/**
* Allows the windowing API to initialize the window.
*
* @throws Throwable throwable
* @since v1-alpha2
*/
@SuppressWarnings("RedundantThrows") // done on purpose
protected void initializeGlfwWindow() throws Exception {}
/** /**
* (Re-)Creates the associated GLFW window. * (Re-)Creates the associated GLFW window.
* *
* @since v1-alpha2 * @since v1-alpha2
*/ */
public final void createGlfwWindow() throws WindowCreationFailureException { public void createGlfwWindow() throws WindowCreationFailureException {
// Ensure running on the main thread // Ensure running on the main thread
if (!Miscellaneous.onMainThread()) if (!Miscellaneous.onMainThread())
throw new NotOnMainThreadException(); throw new NotOnMainThreadException();
@ -137,7 +127,6 @@ public class GlfwWindow extends Window {
} }
// Set window hints // Set window hints
setWindowHints();
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // The window's visibility is later changed in setWindowState, this is just for setting up the window glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // The window's visibility is later changed in setWindowState, this is just for setting up the window
glfwWindowHint(GLFW_POSITION_X, getPosition().getX()); glfwWindowHint(GLFW_POSITION_X, getPosition().getX());
glfwWindowHint(GLFW_POSITION_Y, getPosition().getY()); glfwWindowHint(GLFW_POSITION_Y, getPosition().getY());
@ -180,20 +169,12 @@ public class GlfwWindow extends Window {
setWindowMode(getWindowMode()); setWindowMode(getWindowMode());
} }
/**
* Allows the windowing API to set custom
* window hints during window creation.
*
* @since v1-alpha2
*/
protected void setWindowHints() {}
/** /**
* Closes the associated GLFW window. * Closes the associated GLFW window.
* *
* @since v1-alpha2 * @since v1-alpha2
*/ */
public final void closeGlfwWindow() throws WindowCreationFailureException { public void closeGlfwWindow() throws WindowCreationFailureException {
// Ensure running on the main thread // Ensure running on the main thread
if (!Miscellaneous.onMainThread()) if (!Miscellaneous.onMainThread())
throw new NotOnMainThreadException(); throw new NotOnMainThreadException();
@ -207,7 +188,7 @@ public class GlfwWindow extends Window {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public final void terminate() { public void terminate() {
setTerminated(true); setTerminated(true);
closeGlfwWindow(); closeGlfwWindow();
} }
@ -219,7 +200,7 @@ public class GlfwWindow extends Window {
* @since v1-alpha2 * @since v1-alpha2
*/ */
@Override @Override
public final void updateState() { public void updateState() {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -268,23 +249,12 @@ public class GlfwWindow extends Window {
super.setResizable(Miscellaneous.getBooleanizedInteger(glfwGetWindowAttrib(identifierLong, GLFW_RESIZABLE))); super.setResizable(Miscellaneous.getBooleanizedInteger(glfwGetWindowAttrib(identifierLong, GLFW_RESIZABLE)));
super.setOnTop(Miscellaneous.getBooleanizedInteger(glfwGetWindowAttrib(identifierLong, GLFW_FLOATING))); super.setOnTop(Miscellaneous.getBooleanizedInteger(glfwGetWindowAttrib(identifierLong, GLFW_FLOATING)));
super.setTransparent(Miscellaneous.getBooleanizedInteger(glfwGetWindowAttrib(identifierLong, GLFW_TRANSPARENT_FRAMEBUFFER))); super.setTransparent(Miscellaneous.getBooleanizedInteger(glfwGetWindowAttrib(identifierLong, GLFW_TRANSPARENT_FRAMEBUFFER)));
// Make windowing API update it's state
updateGlfwState();
} }
/**
* Allows the windowing API to update it's state.
*
* @throws Throwable throwable
* @since v1-alpha2
*/
protected void updateGlfwState() {}
// ------------------------------------------------ [ Rendering ] ------------------------------------------------ // // ------------------------------------------------ [ Rendering ] ------------------------------------------------ //
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void render() throws NotOnMainThreadException { public void render() throws NotOnMainThreadException {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -305,14 +275,14 @@ public class GlfwWindow extends Window {
* *
* @since v1-alpha2 * @since v1-alpha2
*/ */
public final void ownContext() { public void ownContext() {
glfwMakeContextCurrent(identifierLong); glfwMakeContextCurrent(identifierLong);
} }
// ------------------------------------------------ [ Information/Action methods ] ------------------------------------------------ // // ------------------------------------------------ [ Information/Action methods ] ------------------------------------------------ //
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final boolean isClosureRequested() { public boolean isClosureRequested() {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return false; return false;
@ -322,7 +292,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final boolean isFocused() { public boolean isFocused() {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return false; return false;
@ -331,7 +301,7 @@ public class GlfwWindow extends Window {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public final void focus() { public void focus() {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -340,7 +310,7 @@ public class GlfwWindow extends Window {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public final void requestAttention() { public void requestAttention() {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -352,7 +322,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setName(@NotNull String name) { public void setName(@NotNull String name) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -363,7 +333,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setTitle(@NotNull String title) { public void setTitle(@NotNull String title) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -374,7 +344,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setSize(@NotNull Vec2i size) { public void setSize(@NotNull Vec2i size) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -385,7 +355,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setMinimumSize(@NotNull Vec2i minimumSize) { public void setMinimumSize(@NotNull Vec2i minimumSize) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -396,7 +366,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setMaximumSize(@NotNull Vec2i maximumSize) { public void setMaximumSize(@NotNull Vec2i maximumSize) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -407,7 +377,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setPosition(@NotNull Vec2i position) { public void setPosition(@NotNull Vec2i position) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -418,7 +388,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setWindowMode(@NotNull WindowMode windowMode) { public void setWindowMode(@NotNull WindowMode windowMode) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -454,7 +424,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setResizable(boolean resizable) { public void setResizable(boolean resizable) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -464,7 +434,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setBorderless(boolean borderless) { public void setBorderless(boolean borderless) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -474,7 +444,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setFocusable(boolean focusable) { public void setFocusable(boolean focusable) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -484,7 +454,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setOnTop(boolean onTop) { public void setOnTop(boolean onTop) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;
@ -494,7 +464,7 @@ public class GlfwWindow extends Window {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void setTransparent(boolean transparent) { public void setTransparent(boolean transparent) {
// Ensure the window is not terminated // Ensure the window is not terminated
if (isTerminated()) if (isTerminated())
return; return;