From b306ad9d1a600fbde51a7a510c1665142a47d946 Mon Sep 17 00:00:00 2001 From: Maksim Belov <45949002+artdeell@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:03:07 +0300 Subject: [PATCH] Use the same code path for OSMesa and regular renderers --- .../src/main/java/org/lwjgl/opengl/GL.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java b/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java index d1db96e880..1de7444295 100644 --- a/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java +++ b/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java @@ -93,9 +93,6 @@ static void initialize() { // intentionally empty to trigger static initializer } - private static native long getGraphicsBufferAddr(); - private static native int[] getNativeWidthHeight(); - /** Loads the OpenGL native library, using the default library name. */ public static void create() { SharedLibrary GL; @@ -293,17 +290,10 @@ private static GLXCapabilities initCapabilitiesGLX(boolean client) { /** PojavLauncher(Android): sets the OpenGL context again to workaround framebuffer issue */ private static void fixPojavGLContext() throws Exception { long currentContext; - String renderer = System.getProperty("org.lwjgl.opengl.libname"); - if (renderer.startsWith("libOSMesa")) { - int[] dims = getNativeWidthHeight(); - currentContext = callJ(functionProvider.getFunctionAddress("OSMesaGetCurrentContext")); - callJPI(currentContext,getGraphicsBufferAddr(),GL_UNSIGNED_BYTE,dims[0],dims[1],functionProvider.getFunctionAddress("OSMesaMakeCurrent")); - } else if (renderer.matches("lib(gl4es|tinywrapper).*")) { - // Workaround glCheckFramebufferStatus issue on 1.13+ 64-bit - Class glfwClass = Class.forName("org.lwjgl.glfw.GLFW"); - currentContext = (long)glfwClass.getDeclaredField("mainContext").get(null); - glfwClass.getDeclaredMethod("glfwMakeContextCurrent", long.class).invoke(null, new Object[]{currentContext}); - } else throw new RuntimeException("Unknown renderer: " + renderer); + // Workaround glCheckFramebufferStatus issue on 1.13+ 64-bit + Class glfwClass = Class.forName("org.lwjgl.glfw.GLFW"); + currentContext = (long)glfwClass.getDeclaredField("mainContext").get(null); + glfwClass.getDeclaredMethod("glfwMakeContextCurrent", long.class).invoke(null, new Object[]{currentContext}); } /**