Skip to content

StencilEmulation

final class StencilEmulation
Package: dev.joid.lib.bridge.render.state · Module: core · Source: StencilEmulation.java

Stencil test and update done in the fragment shader, for a backend whose targets have no stencil buffer.

StencilEmulation turns the StencilState of the render state into what a shader translated with a stencil pass needs: whether to test, whether to write, and the values of its uniforms. Draw the WRITE pass with the pipeline of PipelineKey.stencil and the stencil fragment of the ShaderTranslation, then the draw itself. No backend of JOID uses it: OpenGL and Vulkan have a stencil buffer on the window.

ReturnsSignatureSummary
StencilEmulationfrom(RenderState state, boolean screen) factoryReads the stencil of a render state.

ReturnsSignatureSummary
voidwrite(UniformBlock block)Writes the stencil uniforms of GlslShaderTranslator (STENCIL_TEST, STENCIL_FUNCTION, STENCIL_REFERENCE, STENCIL_MASK, STENCIL_FAIL and STENCIL_PASS) into the block of the shader.
booleanisTest()If true, the draw tests the stencil: the target is the window and the stencil of the state is on.
booleanisWrite()If true, the draw also changes the stencil, so it needs the WRITE pass first: the test is on and the fail or the pass operation is not KEEP.
intgetMask()Returns the mask of the state, reduced to 8 bits.
intgetReference()Returns the reference of the state, reduced to 8 bits.
StencilFunctiongetFunction()Returns the comparison of the state.
StencilOperationgetFail()Returns the operation when the comparison fails.
StencilOperationgetPass()Returns the operation when the comparison passes; the emulation has no depth-fail case.

StencilEmulation from(RenderState state, boolean screen) factory

Reads the stencil of a render state. Pass screen as true when the target is the window: off screen, nothing is tested nor written, as the core never uses a stencil in a framebuffer.

void write(UniformBlock block)

Writes the stencil uniforms of GlslShaderTranslator (STENCIL_TEST, STENCIL_FUNCTION, STENCIL_REFERENCE, STENCIL_MASK, STENCIL_FAIL and STENCIL_PASS) into the block of the shader. Call it before the block is sent for a draw; it throws IllegalArgumentException on a shader translated without stencil emulation.

boolean isTest()

If true, the draw tests the stencil: the target is the window and the stencil of the state is on.

boolean isWrite()

If true, the draw also changes the stencil, so it needs the WRITE pass first: the test is on and the fail or the pass operation is not KEEP.

int getMask()

Returns the mask of the state, reduced to 8 bits.

int getReference()

Returns the reference of the state, reduced to 8 bits.

StencilFunction getFunction()

Returns the comparison of the state.

StencilOperation getFail()

Returns the operation when the comparison fails.

StencilOperation getPass()

Returns the operation when the comparison passes; the emulation has no depth-fail case.


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