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 Dec 24, 2023
1 parent 3aec069 commit b306ad9
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 b306ad9

Please sign in to comment.