Package org.lwjgl.system
Class Library
java.lang.Object
org.lwjgl.system.Library
Initializes the LWJGL shared library and handles loading additional shared libraries.
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Ensures that the LWJGL shared library has been loaded.static SharedLibrary
loadNative
(Class<?> context, String module, String name) Loads a shared library using OS-specific APIs (e.g.static SharedLibrary
loadNative
(Class<?> context, String module, String name, boolean bundledWithLWJGL) Loads a shared library using OS-specific APIs (e.g.static SharedLibrary
loadNative
(Class<?> context, String module, Configuration<String> name, String... defaultNames) Loads a shared library usingloadNative(String, String)
with the name specified byname
.static SharedLibrary
loadNative
(Class<?> context, String module, Configuration<String> name, Supplier<SharedLibrary> fallback, String... defaultNames) Loads a shared library usingloadNative(String, String)
with the name specified byname
.static SharedLibrary
loadNative
(String module, String name) CallsloadNative(Class, String, String)
usingLibrary.class
as the context parameter.static void
loadSystem
(String module, String name) CallsloadSystem(Consumer, Consumer, Class, String, String)
usingLibrary.class
as the context parameter.static void
loadSystem
(Consumer<String> load, Consumer<String> loadLibrary, Class<?> context, String module, String name) Loads a JNI shared library.
-
Field Details
-
JNI_LIBRARY_NAME
The LWJGL shared library name.
-
-
Method Details
-
initialize
public static void initialize()Ensures that the LWJGL shared library has been loaded. -
loadSystem
CallsloadSystem(Consumer, Consumer, Class, String, String)
usingLibrary.class
as the context parameter.- Throws:
UnsatisfiedLinkError
-
loadSystem
public static void loadSystem(Consumer<String> load, Consumer<String> loadLibrary, Class<?> context, String module, String name) throws UnsatisfiedLinkError Loads a JNI shared library.- Parameters:
load
- should be theSystem::load
expression. This ensures thatSystem.load
has the same caller as this method.loadLibrary
- should be theSystem::loadLibrary
expression. This ensures thatSystem.loadLibrary
has the same caller as this method.context
- the class to use to discover the shared library in the classpathmodule
- the module to which the shared library belongsname
- the library name. If not an absolute path, it must be the plain library name, without an OS specific prefix or file extension (e.g. GL, not libGL.so)- Throws:
UnsatisfiedLinkError
- if the library could not be loaded
-
loadNative
CallsloadNative(Class, String, String)
usingLibrary.class
as the context parameter. -
loadNative
Loads a shared library using OS-specific APIs (e.g.LoadLibrary
ordlopen
).- Parameters:
context
- the class to use to discover the shared library in the classpathmodule
- the module to which the shared library belongsname
- the library name. OS-specific prefixes and file extensions are optional (e.g. both"GL"
and"libGL.so.1"
are valid on Linux)- Returns:
- the shared library
- Throws:
UnsatisfiedLinkError
- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(Class<?> context, String module, String name, boolean bundledWithLWJGL) Loads a shared library using OS-specific APIs (e.g.LoadLibrary
ordlopen
).- Parameters:
context
- the class to use to discover the shared library in the classpathmodule
- the module to which the shared library belongsname
- the library name. OS-specific prefixes and file extensions are optional (e.g. both"GL"
and"libGL.so.1"
are valid on Linux)bundledWithLWJGL
- whether the default LWJGL distribution includes the shared library. If true, LWJGL will also try to find the shared library under the<platform>/<arch>/<module>
subfolder.- Returns:
- the shared library
- Throws:
UnsatisfiedLinkError
- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(Class<?> context, String module, @Nullable Configuration<String> name, String... defaultNames) Loads a shared library usingloadNative(String, String)
with the name specified byname
. Ifname
is not set,loadNative(String, String)
will be called with the names specified bydefaultNames
. The first successful will be returned.- Parameters:
name
- aConfiguration
that specifies the library namedefaultNames
- the default library name(s)- Returns:
- the shared library
- Throws:
UnsatisfiedLinkError
- if the library could not be loaded
-
loadNative
public static SharedLibrary loadNative(Class<?> context, String module, @Nullable Configuration<String> name, @Nullable Supplier<SharedLibrary> fallback, String... defaultNames) Loads a shared library usingloadNative(String, String)
with the name specified byname
. Ifname
is not set,loadNative(String, String)
will be called with the names specified bydefaultNames
. The first successful will be returned. If the library could not be loaded, thefallback
will be called.- Parameters:
name
- aConfiguration
that specifies the library namefallback
- fallback to use if everything else failsdefaultNames
- the default library name(s)- Returns:
- the shared library
- Throws:
UnsatisfiedLinkError
- if the library could not be loaded
-