Skip to content

Commit b84bec4

Browse files
committed
fix(Library/Sys): Load pojavexec at the right time
Usually LWJGL3 programs would run Library.initialize() to make sure LWJGL is loaded first. We put pojavexec here because it provides methods that modules may need. Currently GLFW and Vulkan modules have methods that are needed by pojavexec, those being `getVulkanDriverHandle()` and `nativeInitializeGLFWNativeBridge()` the latter of which is found used in the Amethyst-Android repository. LWJGL2 programs run through LWJGLX load Sys.initialize() instead so we also add it there for the same reason.
1 parent fe86505 commit b84bec4

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

modules/lwjgl/core/src/main/java/org/lwjgl/system/Library.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ public final class Library {
5555
);
5656
}
5757

58+
try {
59+
// pojavexec is used to bridge GLFW with Android/iOS and loading vulkan driver for Android.
60+
if (Platform.get() == Platform.MACOSX) {
61+
System.load(System.getenv("BUNDLE_PATH") + "/AngelAuraAmethyst");
62+
} else if (Platform.get() == Platform.LINUX) {
63+
System.loadLibrary("pojavexec");
64+
}
65+
} catch (UnsatisfiedLinkError e) {
66+
e.printStackTrace();
67+
}
5868
loadSystem("org.lwjgl", JNI_LIBRARY_NAME);
5969
}
6070

modules/lwjgl/lwjglx/src/main/java/org/lwjgl/Sys.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.lwjgl;
22

33
import org.lwjgl.opengl.GL11;
4+
import org.lwjgl.system.Platform;
45
import org.lwjgl.glfw.GLFW;
56

67
import java.awt.Desktop;
@@ -11,10 +12,17 @@
1112

1213
public class Sys {
1314

14-
/**
15-
* No constructor for Sys.
16-
*/
1715
private Sys() {
16+
try {
17+
// pojavexec is used to bridge GLFW with Android/iOS and loading vulkan driver for Android.
18+
if (Platform.get() == Platform.MACOSX) {
19+
System.load(System.getenv("BUNDLE_PATH") + "/AngelAuraAmethyst");
20+
} else if (Platform.get() == Platform.LINUX) {
21+
System.loadLibrary("pojavexec");
22+
}
23+
} catch (UnsatisfiedLinkError e) {
24+
e.printStackTrace();
25+
}
1826
}
1927

2028
/** Returns the LWJGL version. */

0 commit comments

Comments
 (0)