- Loads the OpenGL native library into the JVM process.
- Creates instances of
GLCapabilities
classes. AGLCapabilities
instance 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
GLCapabilities
instances, 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull MethodHandle
check
(@Nullable MethodHandle handle) Checks whether the given GL function is available in this context.static GLCapabilities
Returns theGLCapabilities
of the OpenGL context that is current in the current thread.static GLExtCaps
Returns the currentGLExtCaps
of the OpenGL context in the current thread.static @Nullable GLCapabilities
load
(GLLoadFunc load) Loads OpenGL compatibility profile with the given load function.static @Nullable GLCapabilities
load
(GLLoadFunc load, boolean forwardCompatible) Loads OpenGL with the given load function.static int
makeVersion
(int major, int minor) Pack the version into an integer.static void
setCapabilities
(@Nullable GLCapabilities caps) Sets theGLCapabilities
of the OpenGL context that is current in the current thread.static int
versionMajor
(int version) Returns the major version.static int
versionMinor
(int version) Returns the minor version.
-
Constructor Details
-
GLLoader
public GLLoader()
-
-
Method Details
-
setCapabilities
Sets theGLCapabilities
of the OpenGL context that is current in the current thread.This
GLCapabilities
instance will be used by any OpenGL call in the current thread, untilsetCapabilities
is called again with a different value. -
getCapabilities
Returns theGLCapabilities
of the OpenGL context that is current in the current thread..- Returns:
- the
GLCapabilities
of 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 anull
value
-
getExtCapabilities
Returns the currentGLExtCaps
of the OpenGL context in the current thread.This is equivalent to the following code:
getCapabilities()
.ext()
- Returns:
- the current
GLExtCaps
of 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 anull
value
-
load
Loads OpenGL compatibility profile with the given load function.- Parameters:
load
- the load function- Returns:
- the OpenGL capabilities, or
null
if 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
null
if 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 anIllegalStateException
rather than aNullPointerException
.- Parameters:
handle
- the method handle to be checked.- Returns:
handle
- Throws:
IllegalStateException
- ifhandle
isnull
.
-
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
-