GlStencilOp

From QB64 Phoenix Edition Wiki
Revision as of 13:07, 5 May 2022 by RhoSigma (talk | contribs)
Jump to navigation Jump to search

_glStencilOp: set front and back stencil test actions


Syntax

 SUB _glStencilOp (BYVAL fail AS _UNSIGNED LONG, BYVAL zfail AS _UNSIGNED LONG, BYVAL zpass AS _UNSIGNED LONG)
 void _glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);


sfail
Specifies the action to take when the stencil test fails. Eight symbolic constants are accepted: Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, and Template:KW. The initial value is Template:KW.
dpfail
Specifies the stencil action when the stencil test passes, but the depth test fails. dpfail accepts the same symbolic constants as sfail. The initial value is Template:KW.
dppass
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. dppass accepts the same symbolic constants as sfail. The initial value is Template:KW.


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 Template:KW and Template:KW with argument Template:KW; to control it, call Template:KW or Template:KW.

There can be two separate sets of sfail, dpfail, and dppass parameters; one affects back-facing polygons, and the other affects front-facing polygons as well as other non-polygon primitives. Template:KW sets both front and back stencil state to the same values. Use Template:KW to set front and back stencil state to different values.

_glStencilOp 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 sfail specifies what happens to the stencil buffer contents. The following eight actions are possible.

Template:KW
Keeps the current value.
Template:KW
Sets the stencil buffer value to 0.
Template:KW
Sets the stencil buffer value to ref, as specified by Template:KW.
Template:KW
Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
Template:KW
Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value.
Template:KW
Decrements the current stencil buffer value. Clamps to 0.
Template:KW
Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of zero.
Template:KW
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</sup> - 1, where n is the value returned by querying Template:KW.

The other two arguments to _glStencilOp specify stencil buffer actions that depend on whether subsequent depth buffer tests succeed (dppass) or fail (dpfail) (see Template:KW). The actions are specified using the same eight symbolic constants as sfail. Note that dpfail is ignored when there is no depth buffer, or when the depth buffer is not enabled. In these cases, sfail and dppass specify stencil action when the stencil test fails and passes, respectively.


Template:PageNotes

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

Template:KW is the same as calling Template:KW with face set to Template:KW.


Template:PageErrors

Template:KW is generated if sfail, dpfail, or dppass is any value other than the defined constant values.


Template:PageUseWith

Template:KW with argument Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, or Template:KW

Template:KW with argument Template:KW


See also

SUB _GL Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW


Template:PageCopyright



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link