- Loads the OpenGL native library into the JVM process.
- Creates instances of
GLCapabilitiesclasses. AGLCapabilitiesinstance contains flags for functionality that is available in an OpenGL context. Internally, it also contains function pointers that are only valid in that specific OpenGL context. - Maintains thread-local state for
GLCapabilitiesinstances, corresponding to OpenGL contexts that are current in those threads.
GLCapabilities creation
Instances of GLCapabilities can be created with the load method. An OpenGL context must be current in the current thread
before it is called. Calling this method is expensive, so the GLCapabilities instance should be associated with the OpenGL context and reused as
necessary.
Thread-local state
Before a function for a given OpenGL context can be called, the corresponding GLCapabilities instance must be passed to the
setCapabilities(overrungl.opengl.GLCapabilities) method. The user is also responsible for clearing the current GLCapabilities instance when the context is destroyed or made
current in another thread.
Note that the load method implicitly calls setCapabilities(overrungl.opengl.GLCapabilities) with the newly created instance.
- Since:
- 0.1.0
- Author:
- squid233
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull MethodHandlecheck(@Nullable MethodHandle handle) Checks whether the given GL function is available in this context.static GLCapabilitiesReturns theGLCapabilitiesof the OpenGL context that is current in the current thread.static GLExtCapsReturns the currentGLExtCapsof the OpenGL context in the current thread.static @Nullable GLCapabilitiesload(GLLoadFunc load) Loads OpenGL compatibility profile with the given load function.static @Nullable GLCapabilitiesload(GLLoadFunc load, boolean forwardCompatible) Loads OpenGL with the given load function.static intmakeVersion(int major, int minor) Pack the version into an integer.static voidsetCapabilities(@Nullable GLCapabilities caps) Sets theGLCapabilitiesof the OpenGL context that is current in the current thread.static intversionMajor(int version) Returns the major version.static intversionMinor(int version) Returns the minor version.
-
Constructor Details
-
GLLoader
public GLLoader()
-
-
Method Details
-
setCapabilities
Sets theGLCapabilitiesof the OpenGL context that is current in the current thread.This
GLCapabilitiesinstance will be used by any OpenGL call in the current thread, untilsetCapabilitiesis called again with a different value. -
getCapabilities
Returns theGLCapabilitiesof the OpenGL context that is current in the current thread..- Returns:
- the
GLCapabilitiesof the OpenGL context that is current in the current thread - Throws:
IllegalStateException- ifsetCapabilities(overrungl.opengl.GLCapabilities)has never been called in the current thread or was last called with anullvalue
-
getExtCapabilities
Returns the currentGLExtCapsof the OpenGL context in the current thread.This is equivalent to the following code:
getCapabilities().ext()- Returns:
- the current
GLExtCapsof the OpenGL context in the current thread - Throws:
IllegalStateException- ifsetCapabilities(overrungl.opengl.GLCapabilities)has never been called in the current thread or was last called with anullvalue
-
load
Loads OpenGL compatibility profile with the given load function.- Parameters:
load- the load function- Returns:
- the OpenGL capabilities, or
nullif no OpenGL context found.
-
load
Loads OpenGL with the given load function.- Parameters:
load- the load functionforwardCompatible- Iftrue, only loads core profile functions.- Returns:
- the OpenGL capabilities, or
nullif no OpenGL context found.
-
check
@NotNull @Contract(value="null -> fail; !null -> param1", pure=true) public static @NotNull MethodHandle check(@Nullable @Nullable MethodHandle handle) throws IllegalStateException Checks whether the given GL function is available in this context. This method raises anIllegalStateExceptionrather than aNullPointerException.- Parameters:
handle- the method handle to be checked.- Returns:
handle- Throws:
IllegalStateException- ifhandleisnull.
-
makeVersion
public static int makeVersion(int major, int minor) Pack the version into an integer.- Parameters:
major- the major versionminor- the minor version- Returns:
- the packed version
-
versionMajor
public static int versionMajor(int version) Returns the major version.- Parameters:
version- the packed version- Returns:
- the major version
-
versionMinor
public static int versionMinor(int version) Returns the minor version.- Parameters:
version- the packed version- Returns:
- the minor version
-