GLSTENCILFUNCSEPARAT(3G)
π NAME π
okay so bestie, gather round, because this is the glow-up of glStencilFuncSeparate β and yes, the page title up top is literally GLSTENCILFUNCSEPARAT(3G) (the header cut the E off, which is honestly iconic of it π), and the manual it lives in is the [FIXME: manual] one. We move.
It sets the front and/or back function and reference value for stencil testing. That's the whole vibe. π
πΈ C SPECIFICATION πΈ
void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref,
GLuint mask);
π PARAMETERS π
faceβ which stencil state is getting updated: front, back, or both. Three symbolic constants are valid here:GL_FRONT,GL_BACK, andGL_FRONT_AND_BACK. Pick your fighter π«Άfuncβ the test function, bestie. Eight symbolic constants are valid:GL_NEVER,GL_LESS,GL_LEQUAL,GL_GREATER,GL_GEQUAL,GL_EQUAL,GL_NOTEQUAL, andGL_ALWAYS. The initial value isGL_ALWAYS. (Yep, eight. Count 'em. I'll wait β)refβ the reference value for the stencil test.refgets clamped to the range0to2^n - 1, where n is the number of bitplanes in the stencil buffer. The initial value is0.maskβ a mask that gets ANDed with both the reference value and the stored stencil value when the test is done. The initial value is all1's. All the ones. Every single one of them. π₯
π¦ DESCRIPTION π¦
Stenciling, like depth-buffering, enables and disables drawing on a per-pixel basis β which is genuinely so powerful, no cap. 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. It's giving layers. It's giving range. π¨
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() or glStencilOpSeparate().
There can be two separate sets of func, ref, and mask parameters β one affects back-facing polygons, and the other affects front-facing polygons as well as other non-polygon primitives. glStencilFunc() sets both front and back stencil state to the same values, as if glStencilFuncSeparate() were called with face set to GL_FRONT_AND_BACK. Twins, basically. π―ββοΈ
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 to 2^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 to 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. Down bad. π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. Main character energy, truly. β¨
π NOTES π
Initially, the stencil test is disabled β put that in your notes app fr fr. If there is no stencil buffer, no stencil modification can occur and it is as if the stencil test always passes.
π ERRORS π
GL_INVALID_ENUMis generated iffuncis not one of the eight accepted values. So like, don't invent a ninth one. I'm begging. π
β ASSOCIATED GETS β
glGet()with argumentGL_STENCIL_FUNC,GL_STENCIL_VALUE_MASK,GL_STENCIL_REF,GL_STENCIL_BACK_FUNC,GL_STENCIL_BACK_VALUE_MASK,GL_STENCIL_BACK_REF, orGL_STENCIL_BITSglIsEnabled()with argumentGL_STENCIL_TEST
π§ VERSION SUPPORT π§
glStencilFuncSeparate is supported in every version listed here β yes, all of them, a full sweep, we love a consistent queen π:
- OpenGL
2.0β β - OpenGL
2.1β β - OpenGL
3.0β β - OpenGL
3.1β β - OpenGL
3.2β β - OpenGL
3.3β β - OpenGL
4.0β β - OpenGL
4.1β β - OpenGL
4.2β β - OpenGL
4.3β β - OpenGL
4.4β β - OpenGL
4.5β β
(The original packs all this into a big Function / Feature Name grid, but the takeaway is the same: glStencilFuncSeparate ate and left no crumbs. π)
π SEE ALSO π
glBlendFunc(), glDepthFunc(), glEnable(), glLogicOp(), glStencilFunc(), glStencilMask(), glStencilMaskSeparate(), glStencilOp(), glStencilOpSeparate()
π COPYRIGHT π
Copyright Β© 2006 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
π COPYRIGHT (yes, there's another one, and she's real) π
Copyright Β© 1991-2006 Silicon Graphics, Inc.
okay that's the whole page, bestie β every flag, every number, every checkmark, nothing skipped, periodt. π«Ά
and for the cute sign-off: this came from [FIXME: source], dated 08/09/2021, filed under GLSTENCILFUNCSEPARAT(3G) β go stencil something gorgeous with it. π
β¨
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms