Skip to content

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.

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.

ReturnsSignatureSummary
GlStateGuard(IGlBinding binding, GlCapabilities capabilities)Creates the guard and its journaled binding over the binding of the backend.

ReturnsSignatureSummary
voidenter()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.
voidexit()Leaves the guard; the outermost exit writes back every state that JOID changed since enter().
voidrun(Runnable action)Runs the action between enter() and exit().
Tcall(Supplier action)Returns the result of the action, run between enter() and exit().
voidsuspend(Runnable draw)Gives the host its state back, runs the drawing of the host outside the guard, then enters again with the same depth.
IGlBindinggetBinding()Returns the journaled binding through which every call must go.

GlStateGuard(IGlBinding binding, GlCapabilities capabilities)

Creates the guard and its journaled binding over the binding of the backend.

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().

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.


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

Report a problem with this page