Skip to content

Commit

Permalink
Use the same code path for OSMesa and regular renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Nov 5, 2023
1 parent 22aa25c commit 370e58c
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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});
}

/**
Expand Down

0 comments on commit 370e58c

Please sign in to comment.