NAME

glStencilOp - set stencil test actions

delim $$

C SPECIFICATION

void ggllSStteenncciillOOpp( GLenum _f_a_i_l,
                  GLenum _z_f_a_i_l,
                  GLenum _z_p_a_s_s )

PARAMETERS

_f_a_i_l
Specifies the action to take when the stencil test fails. Six symbolic constants are accepted: GGLL__KKEEEEPP, GGLL__ZZEERROO, GGLL__RREEPPLLAACCEE, GGLL__IINNCCRR, GGLL__DDEECCRR, and GGLL__IINNVVEERRTT. The initial value is GGLL__KKEEEEPP.
_z_f_a_i_l
Specifies the stencil action when the stencil test passes, but the depth test fails. _z_f_a_i_l accepts the same symbolic constants as _f_a_i_l. The initial value is GGLL__KKEEEEPP.
_z_p_a_s_s
Specifies the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled. _z_p_a_s_s accepts the same symbolic constants as _f_a_i_l. The initial value is GGLL__KKEEEEPP.

DESCRIPTION

Stenciling, like depth-buffering, enables and disables drawing on a per-pixel basis. You draw into the stencil planes using GL drawing primitives, then render geometry and images, using the stencil planes to mask out portions of the screen. Stenciling is typically used in multipass rendering algorithms to achieve special effects, such as decals, outlining, and constructive solid geometry rendering.

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 ggllEEnnaabbllee and ggllDDiissaabbllee with argument GGLL__SSTTEENNCCIILL__TTEESSTT; to control it, call ggllSStteenncciillFFuunncc.

ggllSStteenncciillOOpp 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 _f_a_i_l specifies what happens to the stencil buffer contents. The following six actions are possible.

GGLL__KKEEEEPP
Keeps the current value.
GGLL__ZZEERROO
Sets the stencil buffer value to 0.
GGLL__RREEPPLLAACCEE
Sets the stencil buffer value to _r_e_f, as specified by ggllSStteenncciillFFuunncc.
GGLL__IINNCCRR
Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
GGLL__DDEECCRR
Decrements the current stencil buffer value. Clamps to 0.
GGLL__IINNVVEERRTT
Bitwise inverts the current stencil buffer value.

Stencil buffer values are treated as unsigned integers. When incremented and decremented, values are clamped to 0 and $2 sup n - 1$, where $n$ is the value returned by querying GGLL__SSTTEENNCCIILL__BBIITTSS.

The other two arguments to ggllSStteenncciillOOpp specify stencil buffer actions that depend on whether subsequent depth buffer tests succeed (_z_p_a_s_s) or fail (_z_f_a_i_l) (see
ggllDDeepptthhFFuunncc). The actions are specified using the same six symbolic constants as _f_a_i_l. Note that _z_f_a_i_l is ignored when there is no depth buffer, or when the depth buffer is not enabled. In these cases, _f_a_i_l and _z_p_a_s_s specify stencil action when the stencil test fails and passes, respectively.

NOTES

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 ggllSStteenncciillOOpp.

ERRORS

GGLL__IINNVVAALLIIDD__EENNUUMM is generated if _f_a_i_l, _z_f_a_i_l, or _z_p_a_s_s is any value other than the six defined constant values.

GGLL__IINNVVAALLIIDD__OOPPEERRAATTIIOONN is generated if ggllSStteenncciillOOpp is executed between the execution of ggllBBeeggiinn and the corresponding execution of ggllEEnndd.

ASSOCIATED GETS

ggllGGeett with argument GGLL__SSTTEENNCCIILL__FFAAIILL
ggllGGeett with argument GGLL__SSTTEENNCCIILL__PPAASSSS__DDEEPPTTHH__PPAASSSS
ggllGGeett with argument GGLL__SSTTEENNCCIILL__PPAASSSS__DDEEPPTTHH__FFAAIILL
ggllGGeett with argument GGLL__SSTTEENNCCIILL__BBIITTSS
ggllIIssEEnnaabblleedd with argument GGLL__SSTTEENNCCIILL__TTEESSTT

SEE ALSO

ggllAAllpphhaaFFuunncc((33GG)), ggllBBlleennddFFuunncc((33GG)), ggllDDeepptthhFFuunncc((33GG)), ggllEEnnaabbllee((33GG)), ggllLLooggiiccOOpp((33GG)), ggllSStteenncciillFFuunncc((33GG))