Skip to content

Commit e5d9a47

Browse files
committed
fix(Library): 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 ee2ed6e commit e5d9a47

2 files changed

Lines changed: 20 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
@@ -52,6 +52,16 @@ public final class Library {
5252
);
5353
}
5454

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

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@
1212

1313
public class Sys {
1414

15-
/**
16-
* No constructor for Sys.
17-
*/
1815
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+
}
1926
}
2027

2128
/** Returns the LWJGL version. */

0 commit comments

Comments
 (0)