Mac Developer Library Developer


This manual page is part of Xcode Tools version 5.0

To obtain these tools:

If you are running a version of Xcode Tools other than 5.0, view the documentation locally:

  • In Xcode

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • To learn how the manual is organized or to learn about command syntax, read the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Developer Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.

GLSTENCILFUNC(3G)                                                                          GLSTENCILFUNC(3G)

       glStencilFunc - set function and reference value for stencil testing

       void glStencilFunc( GLenum func,
                           GLint ref,
                           GLuint mask )

       func  Specifies the test function.  Eight tokens are valid: GL_NEVER, GL_LESS, GL_LEQUAL, GL_GREATER,
             GL_GEQUAL, GL_EQUAL, GL_NOTEQUAL, and GL_ALWAYS. The initial value is GL_ALWAYS.

       ref   Specifies the reference value for the stencil test.  ref is clamped to the range [0,2^n  -  1],
             where n is the number of bitplanes in the stencil buffer. The initial value is 0.

       mask  Specifies  a mask that is ANDed with both the reference value and the stored stencil value when
             the test is done. The initial value is all 1's.

       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 algo-rithms algorithms
       rithms to achieve special effects, such as decals, outlining, and constructive solid geometry render-ing. rendering.

       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 glEnable
       and glDisable with argument GL_STENCIL_TEST.  To specify actions based on the outcome of the  stencil
       test, call glStencilOp.

       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 sten-cil stencil
       cil 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 compar-ison comparison
       ison  succeeds  is  the  pixel  passed  through  to  the next stage in the rasterization process (see
       glStencilOp).  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          Always fails.

       GL_LESS           Passes if ( ref & mask ) < ( stencil & mask ).

       GL_LEQUAL         Passes if ( ref & mask ) <= ( stencil & mask ).

       GL_GREATER        Passes if ( ref & mask ) > ( stencil & mask ).

       GL_GEQUAL         Passes if ( ref & mask ) >= ( stencil & mask ).

       GL_EQUAL          Passes if ( ref & mask ) = ( stencil & mask ).

       GL_NOTEQUAL       Passes if ( ref & mask ) !=  ( stencil & mask ).

       GL_ALWAYS         Always passes.

       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.

       GL_INVALID_ENUM is generated if func is not one of the eight accepted values.

       GL_INVALID_OPERATION is generated if glStencilFunc is executed between the execution of  glBegin  and
       the corresponding execution of glEnd.

       glGet with argument GL_STENCIL_FUNC
       glGet with argument GL_STENCIL_VALUE_MASK
       glGet with argument GL_STENCIL_REF
       glGet with argument GL_STENCIL_BITS
       glIsEnabled with argument GL_STENCIL_TEST

       glAlphaFunc(3G), glBlendFunc(3G), glDepthFunc(3G), glEnable(3G), glIsEnabled(3G), glLogicOp(3G), glStencilOp(3G)


Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation to the OpenGL project.
Bug reports
Report bugs in the functionality of the described tool or API through Bug Reporter.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.