Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the same code path for OSMesa and regular renderers #4

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading