mojira.dev
MC-312230

OpenGL backend fails on Wayland when SDL uses XWayland: "Could not retrieve OpenGL functions"

On Linux, if SDL falls back to XWayland in a Wayland session, the OpenGL backend fails to load and the game silently switches to Vulkan. OpenGL itself works fine on the system (GLX and EGL both verified).

Steps to Reproduce

  1. Start a Wayland session where SDL uses XWayland: a compositor without fifo-v1 (e.g. niri), or set SDL_VIDEO_DRIVER=x11.

  2. Launch vanilla 26.3.

  3. Check the log.

Observed Results

SDL [VIDEO]: Detected XWayland
[Render thread/ERROR]: Failed to create backend OpenGL
BackendCreationException: OpenGL is not supported: Could not retrieve OpenGL functions
    at com.mojang.renderpearl.backend.opengl.GlBackend.loadLibrary(GlBackend.java:36)
Using graphics backend Vulkan

Expected Results

The OpenGL backend loads successfully.

Cause

LWJGL chooses EGL (libEGL.so.1) whenever WAYLAND_DISPLAY or XDG_SESSION_TYPE=wayland is set. GlBackend.loadLibrary() passes that library to SDL_GL_LoadLibrary(). SDL, however, runs on its X11 driver and uses GLX, so it can't find GLX functions in libEGL.so.1.

Tested with the bundled SDL3 on X11:

  • SDL_GL_LoadLibrary("libEGL.so.1") fails with "Could not retrieve OpenGL functions"

  • SDL_GL_LoadLibrary("libGL.so.1") works

Workaround

JVM argument -Dorg.lwjgl.opengl.contextAPI=native

Suggested Fix

Choose the OpenGL context API from the video driver SDL actually uses (SDL_GetCurrentVideoDriver(): x11 → GLX, wayland → EGL), not from environment variables.

Environment

NixOS 26.11 (Linux 7.2.5), Wayland session (niri + xwayland-satellite). NVIDIA RTX 4060, driver 595.99.02. Java 25.0.4.1, LWJGL 3.4.3, SDL 3.4.14, no mods

Linked issues

Attachments

Comments 3

Thank you for helping us improve Minecraft! We saved your files:

[media]

I was able to reproduce on Arch Linux (Linux 7.2.6-zen2-1-zen, Hyprland 0.56.2). Providing the SDL_VIDEO_DRIVER=x11 environment causes it to fallback to Vulkan even if OpenGL is explicitly selected in options.

Thank you for your report!
We're tracking this issue in MC-311954, so this ticket is being resolved and linked as a Duplicate.

If you would like to add a vote and any extra information to the main ticket, it would be appreciated.

If you haven't already, please make use of the search feature to see if an issue you are about to report has already been reported.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

NONPLAY

(Unassigned)

Unconfirmed

26.3

Retrieved