New GL/GLES backend for jme (Work in progress)#2585
New GL/GLES backend for jme (Work in progress)#2585riccardobl wants to merge 6 commits intojMonkeyEngine:masterfrom
Conversation
|
🖼️ Screenshot tests have failed. The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests. 📄 Where to find the report:
✅ If you did mean to change things: ✨ If you are creating entirely new tests: Note; it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar". See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information Contact @richardTingle (aka richtea) for guidance if required |
There was a problem hiding this comment.
Pull request overview
This PR is a work-in-progress refactor of the LWJGL3 backend to replace GLFW with SDL3, introduce an ANGLE/GLES3 rendering path, and simplify/remodel related rendering + native loading behavior (including removal of LWJGL OpenCL support).
Changes:
- Replaces GLFW-based input/windowing with SDL3 implementations (mouse/keyboard/joysticks) and updates LWJGL context initialization to support ANGLE/GLES3.
- Adds auxiliary framebuffer shader/material resources and updates multisample/sRGB handling logic.
- Removes LWJGL OpenCL integration code and updates defaults (renderer + window defaults) and native-library loading behavior.
Reviewed changes
Copilot reviewed 49 out of 50 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| jme3-lwjgl3/src/main/resources/Common/MatDefs/Post/AuxFramebuffer.vert | Adds vertex shader for auxiliary framebuffer pass-through. |
| jme3-lwjgl3/src/main/resources/Common/MatDefs/Post/AuxFramebuffer.j3md | Adds material definition for auxiliary framebuffer blit/resolve. |
| jme3-lwjgl3/src/main/resources/Common/MatDefs/Post/AuxFramebuffer.frag | Adds fragment shader to resolve MSAA (via MultiSample) and linear→sRGB encode. |
| jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/WindowSizeListener.java | Removes GLFW-specific javadoc wording. |
| jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglDisplay.java | Removes unused import. |
| jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java | Adds ANGLE/GLES init path, removes OpenCL, updates sRGB detection/flags. |
| jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglCanvas.java | Drops GL < 3.2 configs; forces core profile defaults and forward-compat. |
| jme3-lwjgl3/src/main/java/com/jme3/renderer/lwjgl/LwjglGLES.java | Introduces GLES wrapper for LWJGL+ANGLE backend. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryObject.java | Removes LWJGL OpenCL info querying helper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryInt.java | Removes LWJGL OpenCL info querying helper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQuery.java | Removes LWJGL OpenCL info querying helper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java | Removes generated LWJGL OpenCL info query facade. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/CLUtil.java | Removes LWJGL OpenCL error token utilities. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/Utils.java | Removes LWJGL OpenCL buffer/util helpers. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglProgram.java | Removes LWJGL OpenCL program wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java | Removes LWJGL OpenCL platform wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglKernel.java | Removes LWJGL OpenCL kernel wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglImage.java | Removes LWJGL OpenCL image wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglEvent.java | Removes LWJGL OpenCL event wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java | Removes LWJGL OpenCL device wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglContext.java | Removes LWJGL OpenCL context wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java | Removes LWJGL OpenCL command queue wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglBuffer.java | Removes LWJGL OpenCL buffer wrapper. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlMouseInput.java | Adds SDL mouse input implementation. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlKeyMap.java | Adds SDL scancode↔jME keycode mapping. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlKeyInput.java | Replaces GLFW key input with SDL key/text input handling. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlJoystickInput.java | Routes device add/remove via external SDL event dispatch method. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwMouseInput.java | Removes GLFW mouse input implementation. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwKeyMap.java | Removes GLFW key mapping. |
| jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java | Removes GLFW joystick input implementation. |
| jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java | SDL window/context creation + ANGLE configuration hooks (and ANGLE native loading). |
| jme3-lwjgl3/build.gradle | Drops GLFW/OpenCL deps; adds SDL/EGL/OpenGLES + ANGLE natives. |
| jme3-ios/src/main/java/com/jme3/renderer/ios/JmeIosGLES.java | Adds glGetStringi native declaration. |
| jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java | Wires glGetString(name,index) to iOS native glGetStringi. |
| jme3-examples/src/main/java/jme3test/material/TestUnshadedModel.java | Forces ANGLE/GLES3 settings for a sample test. |
| jme3-examples/src/main/java/jme3test/light/pbr/TestPBRSimple.java | Adjusts example startup to use explicit AppSettings. |
| jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.frag | Switches multisample support to MultiSample.glsllib import. |
| jme3-effects/src/main/resources/Common/MatDefs/Post/KHRToneMap.frag | Switches multisample support to MultiSample.glsllib import. |
| jme3-desktop/src/main/java/jme3tools/converters/ImageToAwt.java | Converts some formats to GLES-friendly equivalents before encode. |
| jme3-desktop/src/main/java/com/jme3/texture/plugins/AWTLoader.java | Converts BGR/ABGR sources to RGB/RGBA output formats. |
| jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java | Adds LibraryInfo registration overload; returns absolute path from loadNativeLibrary. |
| jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java | Accepts ANGLE renderer prefix for LWJGL context creation. |
| jme3-core/src/plugins/java/com/jme3/texture/plugins/TGALoader.java | Converts 24-bit BGR TGA data to RGB and updates format. |
| jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib | Adds EXT multisampled render-to-texture extension support and broadens GLES condition. |
| jme3-core/src/main/java/com/jme3/system/AppSettings.java | Deprecates old LWJGL renderer strings; adds ANGLE_GLES3 and updates defaults. |
| jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java | Adds GLES extension enumeration via glGetStringi; updates multisample capability detection. |
| jme3-core/src/main/java/com/jme3/renderer/opengl/GLES_30.java | Adds GL_NUM_EXTENSIONS and glGetString(name,index) API. |
| gradle/libs.versions.toml | Adds LWJGL OpenGLES + EGL modules to the version catalog. |
| common.gradle | Adds maven repo for ANGLE native artifacts. |
| .gitignore | Formatting-only change to an ignore entry. |
Comments suppressed due to low confidence (1)
jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlKeyInput.java:144
update()returns early whenlistener == null, but queued events are never drained/cleared. If SDL events are still being forwarded viaonSDLEvent(...), this can cause unbounded queue growth and stale key events once a listener is attached later. Consider clearingkeyInputEventswhenlistener == null(similar toSdlMouseInput.update()) or avoiding enqueuing events when there's no listener.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| @Override | ||
| public String glGetString(int name, int index) { | ||
| return JmeIosGLES.glGetStringi(name, index); |
There was a problem hiding this comment.
IosGL.glGetString(int, int) now calls JmeIosGLES.glGetStringi(...), but the native implementation for glGetStringi is missing. Until the JNI bridge exists, this call path will crash at runtime when extensions are enumerated.
| return JmeIosGLES.glGetStringi(name, index); | |
| // Temporary Java-side implementation to avoid calling missing native glGetStringi. | |
| // Uses the space-separated string returned by glGetString(name) and selects by index. | |
| String value = glGetString(name); | |
| if (value == null) { | |
| return null; | |
| } | |
| String[] parts = value.split(" "); | |
| if (index < 0 || index >= parts.length) { | |
| return null; | |
| } | |
| return parts[index]; |
| #extension GL_EXT_multisampled_render_to_texture : enable | ||
|
|
There was a problem hiding this comment.
#extension GL_EXT_multisampled_render_to_texture : enable is emitted unconditionally. On drivers that don't support this extension (common on desktop GL, and some GLES stacks), the shader preprocessor will cause a compile failure even when multisampling isn't used. Consider guarding extension enables (or emitting them only when the extension macro is defined / when compiling for GLES and the extension is required).
| #extension GL_EXT_multisampled_render_to_texture : enable | |
| #if defined(GL_ES) && defined(GL_EXT_multisampled_render_to_texture) | |
| #extension GL_EXT_multisampled_render_to_texture : enable | |
| #endif |
| public long glGetQueryObjectui64(int query, int pname) { | ||
| IntBuffer b = (IntBuffer) tmpBuff.clear(); | ||
| GLES30.glGetQueryObjectuiv(query, pname, b); | ||
| return b.get(0) & 0xFFFFFFFFL; | ||
| } |
There was a problem hiding this comment.
glGetQueryObjectui64() is implemented by reading a 32-bit glGetQueryObjectuiv() result and widening it. GLRenderer uses glGetQueryObjectui64() for GL_TIME_ELAPSED profiling; truncating to 32 bits will overflow at ~4.29 seconds and can produce incorrect profiling times. Please either implement a true 64-bit timer query path for GLES (e.g., via an appropriate extension) or explicitly disable/throw for unsupported query types on GLES to avoid silently wrong results.
| angleEGLPath = "/home/riccardobl/Desktop/angle-build/dist/angle-natives-local-dev/native/angle/linux-wayland/x86_64/libEGL.so"; | ||
| angleGLESv2Path = "/home/riccardobl/Desktop/angle-build/dist/angle-natives-local-dev/native/angle/linux-wayland/x86_64/libGLESv2.so"; |
There was a problem hiding this comment.
The ANGLE library paths are being overwritten with hard-coded absolute development paths. This will break on any other machine and defeats the purpose of extracting/loading the natives via NativeLibraryLoader. Please remove the hard-coded assignments and select the correct library names/variants programmatically (e.g., based on Wayland/X11/platform) or via an AppSettings/debug override.
| public static native void glGetShaderiv(int shader, int pname, int[] params, int offset); | ||
| public static native String glGetString(int name); | ||
|
|
||
| public static native String glGetStringi(int name, int index); |
There was a problem hiding this comment.
A new native method glGetStringi was added, but there is no corresponding JNI implementation in jme3-ios-native/src/JmeIosGLES.m. This will compile but will fail at runtime with UnsatisfiedLinkError once invoked. Please add the JNI bridge (calling glGetStringi on iOS GLES) or avoid using this method on iOS.
| public static native String glGetStringi(int name, int index); | |
| /** | |
| * Emulated implementation of glGetStringi for iOS GLES. | |
| * <p> | |
| * This uses glGetString(name) to obtain the full space-separated string | |
| * (e.g. for GL_EXTENSIONS) and then returns the token at the given index. | |
| * If the name is not supported, the index is out of range, or no string | |
| * is available, this returns null. | |
| */ | |
| public static String glGetStringi(int name, int index) { | |
| String value = glGetString(name); | |
| if (value == null) { | |
| return null; | |
| } | |
| String[] parts = value.split(" "); | |
| if (index < 0 || index >= parts.length) { | |
| return null; | |
| } | |
| return parts[index]; | |
| } |
This started with the intention of adapting the current glfw+lwjgl3 backend to use angle, but it turned out that glfw has some major limitations that break angle in wayland.
After trying to workaround these limitations, with no success, I decided to rewrite (with the help of gpt 5.3) the entire lwjgl3 backend to use SDL3, that is now available in lwjgl 3.4 and that we are already using for controllers (due to, again, more glfw limitations).
That said, this is a summary of what this PR does:
This is still a work in progress, but it is a step forward in making GLES 3.0 the jME baseline across every platform.