mirror of
https://github.com/QB64Official/qb64.git
synced 2024-08-31 13:30:15 +00:00
76 lines
5.5 KiB
Text
76 lines
5.5 KiB
Text
|
'''_glStencilOp:''' set front and back stencil test actions
|
||
|
|
||
|
|
||
|
{{PageSyntax}}
|
||
|
|
||
|
SUB _glStencilOp (BYVAL fail AS _UNSIGNED LONG, BYVAL zfail AS _UNSIGNED LONG, BYVAL zpass AS _UNSIGNED LONG)
|
||
|
void '''_glStencilOp'''(GLenum {{Parameter|sfail}}, GLenum {{Parameter|dpfail}}, GLenum {{Parameter|dppass}});
|
||
|
|
||
|
|
||
|
; sfail
|
||
|
: Specifies the action to take when the stencil test fails. Eight symbolic constants are accepted: {{KW|_GL_KEEP}}, {{KW|_GL_ZERO}}, {{KW|_GL_REPLACE}}, {{KW|_GL_INCR}}, {{KW|_GL_INCR_WRAP}}, {{KW|_GL_DECR}}, {{KW|_GL_DECR_WRAP}}, and {{KW|_GL_INVERT}}. The initial value is {{KW|_GL_KEEP}}.
|
||
|
; dpfail
|
||
|
: Specifies the stencil action when the stencil test passes, but the depth test fails. {{Parameter|dpfail}} accepts the same symbolic constants as {{Parameter|sfail}}. The initial value is {{KW|_GL_KEEP}}.
|
||
|
; 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. {{Parameter|dppass}} accepts the same symbolic constants as {{Parameter|sfail}}. The initial value is {{KW|_GL_KEEP}}.
|
||
|
|
||
|
|
||
|
{{PageDescription}}
|
||
|
|
||
|
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 {{KW|_glEnable}} and {{KW|_glDisable}} with argument {{KW|_GL_STENCIL_TEST}}; to control it, call {{KW|_glStencilFunc}} or {{KW|_glStencilFuncSeparate}}.
|
||
|
|
||
|
There can be two separate sets of {{Parameter|sfail}}, {{Parameter|dpfail}}, and {{Parameter|dppass}} parameters; one affects back-facing polygons, and the other affects front-facing polygons as well as other non-polygon primitives. {{KW|_glStencilOp}} sets both front and back stencil state to the same values. Use {{KW|_glStencilOpSeparate}} 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 {{Parameter|sfail}} specifies what happens to the stencil buffer contents. The following eight actions are possible.
|
||
|
|
||
|
; {{KW|_GL_KEEP}}
|
||
|
: Keeps the current value.
|
||
|
; {{KW|_GL_ZERO}}
|
||
|
: Sets the stencil buffer value to 0.
|
||
|
; {{KW|_GL_REPLACE}}
|
||
|
: Sets the stencil buffer value to ''ref'', as specified by {{KW|_glStencilFunc}}.
|
||
|
; {{KW|_GL_INCR}}
|
||
|
: Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
|
||
|
; {{KW|_GL_INCR_WRAP}}
|
||
|
: Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value.
|
||
|
; {{KW|_GL_DECR}}
|
||
|
: Decrements the current stencil buffer value. Clamps to 0.
|
||
|
; {{KW|_GL_DECR_WRAP}}
|
||
|
: Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of zero.
|
||
|
; {{KW|_GL_INVERT}}
|
||
|
: 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 {{KW|_GL_STENCIL_BITS}}.
|
||
|
|
||
|
The other two arguments to '''_glStencilOp''' specify stencil buffer actions that depend on whether subsequent depth buffer tests succeed ({{Parameter|dppass}}) or fail ({{Parameter|dpfail}}) (see {{KW|_glDepthFunc}}). The actions are specified using the same eight symbolic constants as {{Parameter|sfail}}. Note that {{Parameter|dpfail}} is ignored when there is no depth buffer, or when the depth buffer is not enabled. In these cases, {{Parameter|sfail}} and {{Parameter|dppass}} specify stencil action when the stencil test fails and passes, respectively.
|
||
|
|
||
|
|
||
|
{{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'''.
|
||
|
|
||
|
{{KW|_glStencilOp}} is the same as calling {{KW|_glStencilOpSeparate}} with {{Parameter|face}} set to {{KW|_GL_FRONT_AND_BACK}}.
|
||
|
|
||
|
|
||
|
{{PageErrors}}
|
||
|
|
||
|
{{KW|_GL_INVALID_ENUM}} is generated if {{Parameter|sfail}}, {{Parameter|dpfail}}, or {{Parameter|dppass}} is any value other than the defined constant values.
|
||
|
|
||
|
|
||
|
{{PageUseWith}}
|
||
|
|
||
|
{{KW|_glGet}} with argument {{KW|_GL_STENCIL_FAIL}}, {{KW|_GL_STENCIL_PASS_DEPTH_PASS}}, {{KW|_GL_STENCIL_PASS_DEPTH_FAIL}}, {{KW|_GL_STENCIL_BACK_FAIL}}, {{KW|_GL_STENCIL_BACK_PASS_DEPTH_PASS}}, {{KW|_GL_STENCIL_BACK_PASS_DEPTH_FAIL}}, or {{KW|_GL_STENCIL_BITS}}
|
||
|
|
||
|
{{KW|_glIsEnabled}} with argument {{KW|_GL_STENCIL_TEST}}
|
||
|
|
||
|
|
||
|
{{PageSeeAlso}}
|
||
|
|
||
|
{{KW|_GL}}
|
||
|
{{KW|_glBlendFunc}}, {{KW|_glDepthFunc}}, {{KW|_glEnable}}, {{KW|_glLogicOp}}, {{KW|_glStencilFunc}}, {{KW|_glStencilFuncSeparate}}, {{KW|_glStencilMask}}, {{KW|_glStencilMaskSeparate}}, {{KW|_glStencilOpSeparate}}
|
||
|
|
||
|
|
||
|
{{PageCopyright}}
|
||
|
|
||
|
Copyright 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see [http://oss.sgi.com/projects/FreeB/ http://oss.sgi.com/projects/FreeB/].
|