Function tetra::graphics::set_stencil_state[][src]

pub fn set_stencil_state(ctx: &mut Context, state: StencilState)
Expand description

Sets the global stencil behavior.

The stencil buffer is an invisible drawing target that you can use as a mask for other drawing operations. For example, you might want to crop an image to a circle. You can do this by drawing a circle to the stencil buffer, then using that buffer as a mask while drawing the image.

In order to use stencils, you must be rendering to a target that was created with a stencil buffer attached. To enable this for the main backbuffer, set ContextBuilder::stencil_buffer to true when creating your context. To enable this for a canvas, initialize it via Canvas::builder, with stencil_buffer set to true.