Skip to content

Replace desktop backend with SDL3 GL and ANGLE-GLES#2585

Open
riccardobl wants to merge 39 commits intojMonkeyEngine:masterfrom
riccardobl:angle
Open

Replace desktop backend with SDL3 GL and ANGLE-GLES#2585
riccardobl wants to merge 39 commits intojMonkeyEngine:masterfrom
riccardobl:angle

Conversation

@riccardobl
Copy link
Copy Markdown
Member

@riccardobl riccardobl commented Jan 25, 2026

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:

  • entirely replaces glfw with sdl3
    • removes glfw dependency
  • implements angle built here
  • replaces the unreliable sRGB default framebuffer with an offscreen framebuffer
    • when gamma correction = true an offscreen RGBA16F framebuffer is passed to jme
    • jme renders to it as usual (doesn't even know it is not the default fb)
    • the offscreen fb is converted to srgb and blitted to the default framebuffer automatically using a shader
  • removes opencl
    • as discussed, it is mostly untested and unused and doesn't work on every platform we support
  • deprecates every opengl version before 3.2
  • set some better defaults (related to Plan to remove default dependency from AWT Settings launcher #2626)

This is still a work in progress, but it is a step forward in making GLES 3.0 the jME baseline across every platform.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 25, 2026

🖼️ 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 didn't expect to change anything visual:
Fix your changes so the screenshot tests pass.

If you did mean to change things:
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.

If you are creating entirely new tests:
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.

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

@riccardobl riccardobl changed the title Angle backend (Work in progress) Angle GLES backend for desktop (Work in progress) Jan 25, 2026
@riccardobl riccardobl changed the title Angle GLES backend for desktop (Work in progress) New GL/GLES backend for jme (Work in progress) Mar 21, 2026
@riccardobl riccardobl requested a review from Copilot March 28, 2026 10:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when listener == null, but queued events are never drained/cleared. If SDL events are still being forwarded via onSDLEvent(...), this can cause unbounded queue growth and stale key events once a listener is attached later. Consider clearing keyInputEvents when listener == null (similar to SdlMouseInput.update()) or avoiding enqueuing events when there's no listener.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java
Comment thread jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib
Comment thread jme3-lwjgl3/src/main/java/com/jme3/renderer/lwjgl/LwjglGLES.java
Comment thread jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java Outdated
Comment thread jme3-ios/src/main/java/com/jme3/renderer/ios/JmeIosGLES.java
@8Keep
Copy link
Copy Markdown
Contributor

8Keep commented Apr 15, 2026

@riccardobl Could you split this out into multiple PRs? Opencl removal, gles 2 removal, could be very independent and land before the main changes here are ready.

@riccardobl
Copy link
Copy Markdown
Member Author

@riccardobl Could you split this out into multiple PRs? Opencl removal, gles 2 removal, could be very independent and land before the main changes here are ready.

The goal of this PR is to implement ANGLE in jme, everything else is just a side effect of that.

  • GLFW is replaced with SDL because it does not support angle very well on wayland
  • OpenCL is dropped because angle does not support it
  • GL2 is dropped because it becomes useless with ANGLE and it would be just be extra effort to implement in SDL

So, this is actually a single feature, there is no point in implementing any of these changes on their own in the current jme , and splitting this would make it much harder to test.

The blocker here is just that I need to test it on a real project and implement ios support

@riccardobl riccardobl changed the title New GL/GLES backend for jme (Work in progress) New GL/GLES backend for jme May 9, 2026
@riccardobl riccardobl changed the title New GL/GLES backend for jme New SDL GL and ANGLE GLES backend May 9, 2026
@riccardobl riccardobl changed the title New SDL GL and ANGLE GLES backend SDL3 GL and ANGLE GLES backend May 9, 2026
@riccardobl riccardobl changed the title SDL3 GL and ANGLE GLES backend SDL3 GL and ANGLE-GLES backend May 9, 2026
@riccardobl riccardobl changed the title SDL3 GL and ANGLE-GLES backend Replace desktop backend with SDL3 GL and ANGLE-GLES May 9, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 58 out of 59 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlKeyInput.java:145

  • When listener is null, update() returns without draining keyInputEvents. If SDL events keep arriving (e.g., when UseInput is false or the listener is set later), this queue can grow unbounded. Consider clearing the queue when listener == null (similar to SdlMouseInput).

Comment on lines 1 to +2
#extension GL_ARB_texture_multisample : enable
#extension GL_EXT_multisampled_render_to_texture : enable
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it

Comment on lines +275 to +277
if (settings.getBoolean("GraphicsTrace")) {
gles = (LwjglGLES) GLTracer.createGlesTracer(gles, GL.class, GLES_30.class, GLFbo.class,
GLExt.class);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Comment thread jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java
Comment thread common.gradle
Comment on lines +42 to +43
maven {
url = uri("https://central.sonatype.com/repository/maven-snapshots")
Comment thread jme3-examples/build.gradle
Comment thread jme3-examples/build.gradle
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 58 out of 59 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlKeyInput.java:145

  • update() returns early when listener == null but does not drain/clear keyInputEvents. If the listener is temporarily unset (or input is disabled), the queue can grow without bound and then replay stale events later. Consider mirroring SdlMouseInput.update() by clearing the queue when there is no listener (and/or when the context isn’t renderable).

Comment thread jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java
Comment thread jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants