![]() | glStencilOperation Method |
Namespace: Ooogles
public static void StencilOperation( glStencilOp stencilFail = glStencilOp.Keep, glStencilOp depthFail = glStencilOp.Keep, glStencilOp bothPass = glStencilOp.Keep )
The stencil test conditionally eliminates a pixel based on the outcome of a comparison between the value in the stencil buffer and a reference value. To enable and disable the test, call Enable(glCapability) and Disable(glCapability) with argument StencilTest; to control it, call StencilFunc(glCompareFunc, Int32, UInt32) or StencilFuncSeparate(glFace, glCompareFunc, Int32, UInt32).
There can be two separate sets of stencilFail, depthFail and bothPass parameters; one affects back-facing polygons, and the other affects front-facing polygons as well as other non-polygon primitives. StencilOperation sets both front and back stencil state to the same values. Use StencilOperationSeparate(glFace, glStencilOp, glStencilOp, glStencilOp) to set front and back stencil state to different values.
StencilOperation takes three arguments that indicate what happens to the stored stencil value while stenciling is enabled. If the stencil test fails, no change is made to the pixel's color or depth buffers, and stencilFail specifies what happens to the stencil buffer contents.
Stencil buffer values are treated as unsigned integers. When incremented and decremented, values are clamped to 0 and 2n - 1, where n is the value returned by StencilBits.
The other two arguments to StencilOperation specify stencil buffer actions that depend on whether subsequent depth buffer tests succeed (bothPass) or fail (depthFail) (see DepthFunc(glCompareFunc)). Note that depthFail is ignored when there is no depth buffer, or when the depth buffer is not enabled. In these cases, stencilFail and bothPass specify stencil action when the stencil test fails and passes, respectively.
Note: initially the stencil test is disabled. If there is no stencil buffer, no stencil modification can occur and it is as if the stencil tests always pass, regardless of any call to StencilOperation.
Note: StencilOperation is the same as calling StencilOperationSeparate(glFace, glStencilOp, glStencilOp, glStencilOp) with face set to FrontAndBack.
OpenGL API: glStencilOp