From db482cf8b2bf2d557f6336c0b7745a7041ba544e Mon Sep 17 00:00:00 2001 From: wil Date: Mon, 16 Jun 2025 15:17:57 -0600 Subject: [PATCH 1/5] wl|support for changing the platform --- .../java/com/jme3/system/AppSettings.java | 35 ++++++++++++++++++- .../com/jme3/system/lwjgl/LwjglWindow.java | 14 +++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index d5653a5d71..02d10eae13 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -214,7 +214,7 @@ public final class AppSettings extends HashMap { * @see AppSettings#setAudioRenderer(java.lang.String) */ public static final String LWJGL_OPENAL = "LWJGL"; - + /** * Use the Android MediaPlayer / SoundPool based renderer for Android audio capabilities. *

@@ -295,6 +295,7 @@ public final class AppSettings extends HashMap { defaults.put("UseRetinaFrameBuffer", false); defaults.put("WindowYPosition", 0); defaults.put("WindowXPosition", 0); + defaults.put("NativePlatform", true); // defaults.put("Icons", null); } @@ -1507,4 +1508,36 @@ public int getDisplay() { public void setDisplay(int mon) { putInteger("Display", mon); } + + /** + * Sets the native platform to be used to create the GL context. + * + *

+ * This only affects Linux distributions or derivatives that use a Wayland session in conjunction + * with X11 via the XWayland bridge, which enables or disables GLX for window positioning and/or + * icon configuration. + *

+ * + *

+ * NOTE: Note that disabling this option uses GLX (native X11) instead of EGL (native WL). + *

+ * + * @param nplaf true when using EGL (native), otherwise false if you want to enable GLX + */ + public void setNativePlatform(boolean nplaf) { + put("NativePlatform", nplaf); + } + + /** + * Gets what type of platform is being used. + * + *

+ * Only valid on Linux distributions or derivatives that support Wayland, where it indicates whether GLX or EGL is enabled. + *

+ * + * @return returns true if used in EGL (native), otherwise false if GLX is enabled + */ + public boolean isNativePlatform() { + return getBoolean("NativePlatform"); + } } diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index 01e6ff760d..da88ab1871 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -273,7 +273,19 @@ public void invoke(int error, long description) { } } ); - + + if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) { + + /* + * Change the platform GLFW uses to enable GLX on Wayland as long as you + * have XWayland (X11 compatibility) + */ + if (!settings.isNativePlatform() && glfwPlatformSupported(GLFW_PLATFORM_X11)) { + glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); + } + + } + if (!glfwInit()) { throw new IllegalStateException("Unable to initialize GLFW"); } From 93f75bc9ef87db97111dc3d2ebb8df61d9ee5913 Mon Sep 17 00:00:00 2001 From: wil Date: Tue, 17 Jun 2025 17:02:05 -0600 Subject: [PATCH 2/5] update|x11 wayland --- .../main/java/com/jme3/system/AppSettings.java | 16 ++++++++-------- .../java/com/jme3/system/lwjgl/LwjglWindow.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 02d10eae13..6197f03ae0 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -214,7 +214,7 @@ public final class AppSettings extends HashMap { * @see AppSettings#setAudioRenderer(java.lang.String) */ public static final String LWJGL_OPENAL = "LWJGL"; - + /** * Use the Android MediaPlayer / SoundPool based renderer for Android audio capabilities. *

@@ -295,7 +295,7 @@ public final class AppSettings extends HashMap { defaults.put("UseRetinaFrameBuffer", false); defaults.put("WindowYPosition", 0); defaults.put("WindowXPosition", 0); - defaults.put("NativePlatform", true); + defaults.put("X11PlatformPreferred", false); // defaults.put("Icons", null); } @@ -1522,10 +1522,10 @@ public void setDisplay(int mon) { * NOTE: Note that disabling this option uses GLX (native X11) instead of EGL (native WL). *

* - * @param nplaf true when using EGL (native), otherwise false if you want to enable GLX + * @param nplaf true if you want to enable GLX, otherwise false when using EGL (native) */ - public void setNativePlatform(boolean nplaf) { - put("NativePlatform", nplaf); + public void setX11PlatformPreferred(boolean nplaf) { + put("X11PlatformPreferred", nplaf); } /** @@ -1535,9 +1535,9 @@ public void setNativePlatform(boolean nplaf) { * Only valid on Linux distributions or derivatives that support Wayland, where it indicates whether GLX or EGL is enabled. *

* - * @return returns true if used in EGL (native), otherwise false if GLX is enabled + * @return returns true if GLX is enabled, otherwise false if used in EGL (native) */ - public boolean isNativePlatform() { - return getBoolean("NativePlatform"); + public boolean isX11PlatformPreferred() { + return getBoolean("X11PlatformPreferred"); } } diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index da88ab1871..d4b0767873 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -280,7 +280,7 @@ public void invoke(int error, long description) { * Change the platform GLFW uses to enable GLX on Wayland as long as you * have XWayland (X11 compatibility) */ - if (!settings.isNativePlatform() && glfwPlatformSupported(GLFW_PLATFORM_X11)) { + if (settings.isX11PlatformPreferred() && glfwPlatformSupported(GLFW_PLATFORM_X11)) { glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); } From 3ee74bec219d970731c2448bd0795dc3c9684ac5 Mon Sep 17 00:00:00 2001 From: wil Date: Tue, 17 Jun 2025 17:06:58 -0600 Subject: [PATCH 3/5] update|format --- .../src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index 393597f526..db4160cafe 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -273,7 +273,7 @@ public void invoke(int error, long description) { } } ); - + if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) { /* From 7442eda9beb77e4095e8838c1ca7e5e51d5b8708 Mon Sep 17 00:00:00 2001 From: wil Date: Wed, 18 Jun 2025 11:53:59 -0600 Subject: [PATCH 4/5] update|javadoc --- .../java/com/jme3/system/AppSettings.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 6197f03ae0..a8aba1935e 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -1510,32 +1510,24 @@ public void setDisplay(int mon) { } /** - * Sets the native platform to be used to create the GL context. - * + * Sets the preferred native platform for creating the GL context on Linux distributions. *

- * This only affects Linux distributions or derivatives that use a Wayland session in conjunction - * with X11 via the XWayland bridge, which enables or disables GLX for window positioning and/or - * icon configuration. - *

+ * This setting is relevant for Linux distributions or derivatives that utilize a Wayland session alongside an X11 via the XWayland bridge. + * Enabling this option allows the use of GLX for window positioning and/or icon configuration. * - *

- * NOTE: Note that disabling this option uses GLX (native X11) instead of EGL (native WL). - *

- * - * @param nplaf true if you want to enable GLX, otherwise false when using EGL (native) + * @param preferred true to prefer GLX (native X11) for the GL context, false to prefer EGL (native Wayland). */ - public void setX11PlatformPreferred(boolean nplaf) { - put("X11PlatformPreferred", nplaf); + public void setX11PlatformPreferred(boolean preferred) { + put("X11PlatformPreferred", preferred); } /** - * Gets what type of platform is being used. - * + * Determines which native platform is preferred for GL context creation on Linux distributions. *

- * Only valid on Linux distributions or derivatives that support Wayland, where it indicates whether GLX or EGL is enabled. - *

- * - * @return returns true if GLX is enabled, otherwise false if used in EGL (native) + * This setting is only valid on Linux distributions or derivatives that support Wayland, + * and it indicates whether GLX (native X11) or EGL (native Wayland) is enabled for the GL context. + * + * @return true if GLX is preferred, otherwise false if EGL is preferred (native Wayland). */ public boolean isX11PlatformPreferred() { return getBoolean("X11PlatformPreferred"); From 84b8a9c7bbc75314511de2809d3d7dd8720b390a Mon Sep 17 00:00:00 2001 From: wil Date: Thu, 19 Jun 2025 11:21:35 -0600 Subject: [PATCH 5/5] update|put() --- jme3-core/src/main/java/com/jme3/system/AppSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index a8aba1935e..2db7f8d702 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -1518,7 +1518,7 @@ public void setDisplay(int mon) { * @param preferred true to prefer GLX (native X11) for the GL context, false to prefer EGL (native Wayland). */ public void setX11PlatformPreferred(boolean preferred) { - put("X11PlatformPreferred", preferred); + putBoolean("X11PlatformPreferred", preferred); } /**