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

Attachments

Comments 1

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

[media]

NONPLAY

(Unassigned)

Unconfirmed

26.3

Retrieved