GlStateGuard
final class GlStateGuard
Package: dev.joid.base.opengl.render.state · Module: base-opengl · Source: GlStateGuard.java
Backends: LWJGL 2 LWJGL 3
Saves the OpenGL state that JOID changes during a frame and gives it back to the host when the frame ends.
Description
Section titled “Description”Entries nest: only the outermost enter() starts the journal and resets the pipeline for JOID, and only the matching exit() restores the state of the host.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| GlStateGuard(IGlBinding binding, GlCapabilities capabilities) | Creates the guard and its journaled binding over the binding of the backend. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | enter() | Enters the guard; the outermost entry starts the journal and resets what a host may leave on: scissor, smooth lines, logic op, polygon offset, sRGB, primitive restart, depth clamp, the fixed pipeline, the clear values, the faces, the line width and the pixel storage. |
void | exit() | Leaves the guard; the outermost exit writes back every state that JOID changed since enter(). |
void | run(Runnable action) | Runs the action between enter() and exit(). |
T | call(Supplier | Returns the result of the action, run between enter() and exit(). |
void | suspend(Runnable draw) | Gives the host its state back, runs the drawing of the host outside the guard, then enters again with the same depth. |
IGlBinding | getBinding() | Returns the journaled binding through which every call must go. |
Creation details
Section titled “Creation details”GlStateGuard
Section titled “GlStateGuard”GlStateGuard(IGlBinding binding, GlCapabilities capabilities)
Creates the guard and its journaled binding over the binding of the backend.
Method details
Section titled “Method details”void enter()
Enters the guard; the outermost entry starts the journal and resets what a host may leave on: scissor, smooth lines, logic op, polygon offset, sRGB, primitive restart, depth clamp, the fixed pipeline, the clear values, the faces, the line width and the pixel storage.
void exit()
Leaves the guard; the outermost exit writes back every state that JOID changed since enter().
void run(Runnable action)
Runs the action between enter() and exit().
<T> T call(Supplier<T> action)
Returns the result of the action, run between enter() and exit().
suspend
Section titled “suspend”void suspend(Runnable draw)
Gives the host its state back, runs the drawing of the host outside the guard, then enters again with the same depth.
getBinding
Section titled “getBinding”IGlBinding getBinding()
Returns the journaled binding through which every call must go.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
