-
Notifications
You must be signed in to change notification settings - Fork 6
Wayland Support
The Wayland display server has become very popular in recent Linux distributions, replacing X11. At the time of writing, AWT/Swing are still using X11 under the hood, making use of Xwayland when in a Wayland session. Therefore, lwjgl3-awt which provides the AWTGLCanvas class that brings JPlotters GL capabilities, has to make use of X11. In general, this is no problem, since Wayland provides an X11 server through Xwayland for compatibility. However, LWJGL which provides all of the OpenGL API, does something peculiar when it detects a Wayland session:
It switches from GLX to EGL as the OpenGL native library.
Therefore, AWTGLCanvas cannot access the GLX capabilities that it relies on, and you likely end up with IllegalStateException("Failed to query GLX version").
From LWJGL's GL class:
public static void create() {
SharedLibrary GL = null;
String contextAPI = Configuration.OPENGL_CONTEXT_API.get();
boolean tryEGL = "EGL".equals(contextAPI) || (contextAPI == null && isWayland());
if (tryEGL) {
GL = loadEGL();
} else if ("OSMesa".equals(contextAPI)) {
GL = loadOSMesa();
}
if (GL == null) {
GL = loadNative();
if (GL == null && !"native".equals(contextAPI)) {
if (!tryEGL) {
GL = loadEGL();
}
if (GL == null && !"OSMesa".equals(contextAPI)) {
GL = loadOSMesa();
}
}
}Until any of the libraries adapt, you have to force LWJGL to loadNative(). This can be done in code (i.e. in your main method before anything else GL related is executed) or when launching your application on the JVM.
Configuration.OPENGL_CONTEXT_API.set("native"); // requires changing your code
/* OR */
System.setProperty("org.lwjgl.opengl.contextAPI", "native"); // requires changing your code tooOR
java -Dorg.lwjgl.opengl.contextAPI=native -jar myapplication.jar
# does not require any changes to your code, but how it is launched