GLSTENCILFUNC



GLSTENCILFUNC

NAME
C SPECIFICATION
PARAMETERS
DESCRIPTION
NOTES
ERRORS
ASSOCIATED GETS
SEE ALSO

NAME

glStencilFunc − set function and reference value for stencil testing

C SPECIFICATION

void glStencilFunc( GLenum func,

GLint ref,

GLuint mask )

PARAMETERS

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

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 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 sup 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 glStencilOp). All tests treat stencil values as unsigned integers in the range [0,$2 sup 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.

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 test always passes.

ERRORS

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.

ASSOCIATED GETS

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

SEE ALSO

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






Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.