Class StencilMask
java.lang.Object
lol.trq.helios.state.StencilMask
Clips drawing to an arbitrary shape with the stencil buffer: draw a mask, then draw content only inside it (or only
outside it).
helios.stencil().clip(
() -> helios.shapes().begin(pixel).circle(50, 50, 30, Paint.solid(-1)).end(),
true,
() -> drawAvatar());
The bound framebuffer needs a stencil buffer: pooled framebuffers made with depthStencil, or on
Minecraft the main framebuffer after MinecraftHelios.enableStencil(). Mask fragments with alpha at or below
one half are dropped, so the mask edge is not anti-aliased; the content inside it is. Masks do not nest: a clip
clears the stencil buffer.
-
Constructor Summary
ConstructorsConstructorDescriptionStencilMask(GlBackend gl, GlStateCache cache, ShapeBatch batch) Creates the helper. -
Method Summary
-
Constructor Details
-
StencilMask
Creates the helper.- Parameters:
gl- the backendcache- the host's state cachebatch- the batch the mask is drawn with; its alpha cutoff is raised while the mask draws
-
-
Method Details
-
clip
Draws content clipped to a mask.- Parameters:
mask- draws the mask shape with the batch given to the constructor; nothing reaches the colour bufferinside- keep the content inside the mask, or outside itcontent- draws the clipped content- Throws:
IllegalStateException- if the bound framebuffer has no stencil buffer
-