Sets the front and back function and reference value for stencil testing.
SyntaxWebGLRenderingContext.stencilFunc(func, ref, mask);
- func [in]
Specifies the test function. The stencil functions for the front and back-facing stencil buffers (whose parameter names are STENCIL_FUNC and STENCIL_BACK_FUNC, respectively) default to ALWAYS.
- ref [in]
Specifies the reference value for the stencil test. ref is clamped to the range [0, 2(n - 1)], where n is the number of stencil bits for both the front and back-facing stencil bits. The stencil reference values for the front and back-facing stencil buffers (respectively STENCIL_REF and STENCIL_BACK_REF) default to 0.
- mask [in]
Specifies a mask that is bit-wise ANDed with both the reference value and the stored stencil value when the test is done. The initial stencil value masks for the front and back-facing stencil buffers (respectively STENCIL_VALUE_MASK and STENCIL_BACK_VALUE_MASK) default to an unsigned integer which has the n least significant bits set all to 1s (where n is the size of the stencil buffer in bits).
This method does not return a value.
Any parameter values set via stencilFunc are set on both the front and back-facing stencil buffers.
The ref and mask values are stored in integer format and any float portion of the values are truncated.
Only the least significant n bits of the mask value are stored (where n is the size of the stencil buffer in bits).
The stencilFunc parameters (that is, STENCIL_FUNC and STENCIL_REF) can be set when the stencil test is disabled or a stencil buffer is not available, but will have no impact during rendering.
Calling stencilFunc with an invalid stencilFunc enumeration value generates the INVALID_ENUM error but doesn’t affect any previously-set parameter value.