gl.StencilFunc(func, ref, mask)
The stencil test conditionally eliminates a pixel based on the outcome of a comparison between the
reference value and the value in the stencil buffer. To enable and disable the test, call gl.Enable()
and gl.Disable() with argument #GL_STENCIL_TEST
. To specify actions based on the outcome
of the stencil test, call gl.StencilOp().
func
is a symbolic constant that determines the stencil comparison function. It accepts one of eight
values, shown in the following list. ref
is an integer reference value that is used in the stencil
comparison. It is clamped to the range (0,2^n-1) , where n is the number of bitplanes in the stencil
buffer. mask
is bitwise ANDed with both the reference value and the stored stencil value, with the
ANDed values participating in the comparison.
If stencil
represents the value stored in the corresponding stencil buffer location, the following list
shows the effect of each comparison function that can be specified by func. Only if the comparison succeeds
is the pixel passed through to the next stage in the rasterization process (See gl.StencilOp for details.).
All tests treat stencil values as unsigned integers in the range (0,2^n-1) , where n is the number of
bitplanes in the stencil buffer.
The following values are accepted by func
:
#GL_NEVER
#GL_LESS
#GL_LEQUAL
#GL_GREATER
#GL_GEQUAL
GL_EQUAL
GL_NOTEQUAL
#GL_ALWAYS
Initially, the stencil test is disabled. If there is no stencil buffer, no stencil modification can occur and it is as if the stencil test always passes.
Please consult an OpenGL reference manual for more information.
#GL_ALWAYS
(see above)#GL_INVALID_ENUM
is generated if func
is not one of the eight accepted values.
#GL_INVALID_OPERATION
is generated if gl.StencilFunc()
is executed between the execution of gl.Begin() and the corresponding execution of gl.End().
#GL_STENCIL_FUNC
, #GL_STENCIL_VALUE_MASK
, #GL_STENCIL_REF
, or #GL_STENCIL_BITS
gl.IsEnabled() with argument #GL_STENCIL_TEST