2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
30 * Note: There's some conflict between GL_EXT_stencil_two_side and
31 * OpenGL 2.0's two-sided stencil feature.
33 * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the
34 * front OR back face state (as set by glActiveStencilFaceEXT) is set.
36 * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the
37 * front AND back state.
39 * Also, note that GL_ATI_separate_stencil is different as well:
40 * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs.
41 * glStencilFuncSeparate(GLenum face, GLenum func, ...).
43 * This problem is solved by keeping three sets of stencil state:
44 * state[0] = GL_FRONT state.
45 * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state.
46 * state[2] = GL_EXT_stencil_two_side GL_BACK state.
59 validate_stencil_op(struct gl_context
*ctx
, GLenum op
)
78 validate_stencil_func(struct gl_context
*ctx
, GLenum func
)
97 * Set the clear value for the stencil buffer.
99 * \param s clear value.
101 * \sa glClearStencil().
103 * Updates gl_stencil_attrib::Clear. On change
104 * flushes the vertices and notifies the driver via
105 * the dd_function_table::ClearStencil callback.
108 _mesa_ClearStencil( GLint s
)
110 GET_CURRENT_CONTEXT(ctx
);
112 if (MESA_VERBOSE
& VERBOSE_API
)
113 _mesa_debug(ctx
, "glClearStencil(%d)\n", s
);
115 ctx
->Stencil
.Clear
= (GLuint
) s
;
120 * Set the function and reference value for stencil testing.
122 * \param frontfunc front test function.
123 * \param backfunc back test function.
124 * \param ref front and back reference value.
125 * \param mask front and back bitmask.
127 * \sa glStencilFunc().
129 * Verifies the parameters and updates the respective values in
130 * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
131 * the driver via the dd_function_table::StencilFunc callback.
134 _mesa_StencilFuncSeparateATI( GLenum frontfunc
, GLenum backfunc
, GLint ref
, GLuint mask
)
136 GET_CURRENT_CONTEXT(ctx
);
138 if (MESA_VERBOSE
& VERBOSE_API
)
139 _mesa_debug(ctx
, "glStencilFuncSeparateATI()\n");
141 if (!validate_stencil_func(ctx
, frontfunc
)) {
142 _mesa_error(ctx
, GL_INVALID_ENUM
,
143 "glStencilFuncSeparateATI(frontfunc)");
146 if (!validate_stencil_func(ctx
, backfunc
)) {
147 _mesa_error(ctx
, GL_INVALID_ENUM
,
148 "glStencilFuncSeparateATI(backfunc)");
152 /* set both front and back state */
153 if (ctx
->Stencil
.Function
[0] == frontfunc
&&
154 ctx
->Stencil
.Function
[1] == backfunc
&&
155 ctx
->Stencil
.ValueMask
[0] == mask
&&
156 ctx
->Stencil
.ValueMask
[1] == mask
&&
157 ctx
->Stencil
.Ref
[0] == ref
&&
158 ctx
->Stencil
.Ref
[1] == ref
)
160 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
161 ctx
->Stencil
.Function
[0] = frontfunc
;
162 ctx
->Stencil
.Function
[1] = backfunc
;
163 ctx
->Stencil
.Ref
[0] = ctx
->Stencil
.Ref
[1] = ref
;
164 ctx
->Stencil
.ValueMask
[0] = ctx
->Stencil
.ValueMask
[1] = mask
;
165 if (ctx
->Driver
.StencilFuncSeparate
) {
166 ctx
->Driver
.StencilFuncSeparate(ctx
, GL_FRONT
,
167 frontfunc
, ref
, mask
);
168 ctx
->Driver
.StencilFuncSeparate(ctx
, GL_BACK
,
169 backfunc
, ref
, mask
);
175 * Set the function and reference value for stencil testing.
177 * \param func test function.
178 * \param ref reference value.
179 * \param mask bitmask.
181 * \sa glStencilFunc().
183 * Verifies the parameters and updates the respective values in
184 * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
185 * the driver via the dd_function_table::StencilFunc callback.
188 stencil_func(struct gl_context
*ctx
, GLenum func
, GLint ref
, GLuint mask
)
190 const GLint face
= ctx
->Stencil
.ActiveFace
;
193 if (ctx
->Stencil
.Function
[face
] == func
&&
194 ctx
->Stencil
.ValueMask
[face
] == mask
&&
195 ctx
->Stencil
.Ref
[face
] == ref
)
197 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
198 ctx
->Stencil
.Function
[face
] = func
;
199 ctx
->Stencil
.Ref
[face
] = ref
;
200 ctx
->Stencil
.ValueMask
[face
] = mask
;
202 /* Only propagate the change to the driver if EXT_stencil_two_side
205 if (ctx
->Driver
.StencilFuncSeparate
&& ctx
->Stencil
.TestTwoSide
) {
206 ctx
->Driver
.StencilFuncSeparate(ctx
, GL_BACK
, func
, ref
, mask
);
210 /* set both front and back state */
211 if (ctx
->Stencil
.Function
[0] == func
&&
212 ctx
->Stencil
.Function
[1] == func
&&
213 ctx
->Stencil
.ValueMask
[0] == mask
&&
214 ctx
->Stencil
.ValueMask
[1] == mask
&&
215 ctx
->Stencil
.Ref
[0] == ref
&&
216 ctx
->Stencil
.Ref
[1] == ref
)
218 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
219 ctx
->Stencil
.Function
[0] = ctx
->Stencil
.Function
[1] = func
;
220 ctx
->Stencil
.Ref
[0] = ctx
->Stencil
.Ref
[1] = ref
;
221 ctx
->Stencil
.ValueMask
[0] = ctx
->Stencil
.ValueMask
[1] = mask
;
222 if (ctx
->Driver
.StencilFuncSeparate
) {
223 ctx
->Driver
.StencilFuncSeparate(ctx
,
224 ((ctx
->Stencil
.TestTwoSide
)
225 ? GL_FRONT
: GL_FRONT_AND_BACK
),
233 _mesa_StencilFunc_no_error(GLenum func
, GLint ref
, GLuint mask
)
235 GET_CURRENT_CONTEXT(ctx
);
236 stencil_func(ctx
, func
, ref
, mask
);
241 _mesa_StencilFunc(GLenum func
, GLint ref
, GLuint mask
)
243 GET_CURRENT_CONTEXT(ctx
);
245 if (MESA_VERBOSE
& VERBOSE_API
)
246 _mesa_debug(ctx
, "glStencilFunc()\n");
248 if (!validate_stencil_func(ctx
, func
)) {
249 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilFunc(func)");
253 stencil_func(ctx
, func
, ref
, mask
);
258 * Set the stencil writing mask.
260 * \param mask bit-mask to enable/disable writing of individual bits in the
263 * \sa glStencilMask().
265 * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and
266 * notifies the driver via the dd_function_table::StencilMask callback.
269 _mesa_StencilMask( GLuint mask
)
271 GET_CURRENT_CONTEXT(ctx
);
272 const GLint face
= ctx
->Stencil
.ActiveFace
;
274 if (MESA_VERBOSE
& VERBOSE_API
)
275 _mesa_debug(ctx
, "glStencilMask()\n");
278 /* Only modify the EXT_stencil_two_side back-face state.
280 if (ctx
->Stencil
.WriteMask
[face
] == mask
)
282 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
283 ctx
->Stencil
.WriteMask
[face
] = mask
;
285 /* Only propagate the change to the driver if EXT_stencil_two_side
288 if (ctx
->Driver
.StencilMaskSeparate
&& ctx
->Stencil
.TestTwoSide
) {
289 ctx
->Driver
.StencilMaskSeparate(ctx
, GL_BACK
, mask
);
293 /* set both front and back state */
294 if (ctx
->Stencil
.WriteMask
[0] == mask
&&
295 ctx
->Stencil
.WriteMask
[1] == mask
)
297 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
298 ctx
->Stencil
.WriteMask
[0] = ctx
->Stencil
.WriteMask
[1] = mask
;
299 if (ctx
->Driver
.StencilMaskSeparate
) {
300 ctx
->Driver
.StencilMaskSeparate(ctx
,
301 ((ctx
->Stencil
.TestTwoSide
)
302 ? GL_FRONT
: GL_FRONT_AND_BACK
),
310 * Set the stencil test actions.
312 * \param fail action to take when stencil test fails.
313 * \param zfail action to take when stencil test passes, but depth test fails.
314 * \param zpass action to take when stencil test passes and the depth test
315 * passes (or depth testing is not enabled).
319 * Verifies the parameters and updates the respective fields in
320 * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
321 * the driver via the dd_function_table::StencilOp callback.
324 _mesa_StencilOp(GLenum fail
, GLenum zfail
, GLenum zpass
)
326 GET_CURRENT_CONTEXT(ctx
);
327 const GLint face
= ctx
->Stencil
.ActiveFace
;
329 if (MESA_VERBOSE
& VERBOSE_API
)
330 _mesa_debug(ctx
, "glStencilOp()\n");
332 if (!validate_stencil_op(ctx
, fail
)) {
333 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOp(sfail)");
336 if (!validate_stencil_op(ctx
, zfail
)) {
337 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOp(zfail)");
340 if (!validate_stencil_op(ctx
, zpass
)) {
341 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOp(zpass)");
346 /* only set active face state */
347 if (ctx
->Stencil
.ZFailFunc
[face
] == zfail
&&
348 ctx
->Stencil
.ZPassFunc
[face
] == zpass
&&
349 ctx
->Stencil
.FailFunc
[face
] == fail
)
351 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
352 ctx
->Stencil
.ZFailFunc
[face
] = zfail
;
353 ctx
->Stencil
.ZPassFunc
[face
] = zpass
;
354 ctx
->Stencil
.FailFunc
[face
] = fail
;
356 /* Only propagate the change to the driver if EXT_stencil_two_side
359 if (ctx
->Driver
.StencilOpSeparate
&& ctx
->Stencil
.TestTwoSide
) {
360 ctx
->Driver
.StencilOpSeparate(ctx
, GL_BACK
, fail
, zfail
, zpass
);
364 /* set both front and back state */
365 if (ctx
->Stencil
.ZFailFunc
[0] == zfail
&&
366 ctx
->Stencil
.ZFailFunc
[1] == zfail
&&
367 ctx
->Stencil
.ZPassFunc
[0] == zpass
&&
368 ctx
->Stencil
.ZPassFunc
[1] == zpass
&&
369 ctx
->Stencil
.FailFunc
[0] == fail
&&
370 ctx
->Stencil
.FailFunc
[1] == fail
)
372 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
373 ctx
->Stencil
.ZFailFunc
[0] = ctx
->Stencil
.ZFailFunc
[1] = zfail
;
374 ctx
->Stencil
.ZPassFunc
[0] = ctx
->Stencil
.ZPassFunc
[1] = zpass
;
375 ctx
->Stencil
.FailFunc
[0] = ctx
->Stencil
.FailFunc
[1] = fail
;
376 if (ctx
->Driver
.StencilOpSeparate
) {
377 ctx
->Driver
.StencilOpSeparate(ctx
,
378 ((ctx
->Stencil
.TestTwoSide
)
379 ? GL_FRONT
: GL_FRONT_AND_BACK
),
387 /* GL_EXT_stencil_two_side */
389 _mesa_ActiveStencilFaceEXT(GLenum face
)
391 GET_CURRENT_CONTEXT(ctx
);
393 if (MESA_VERBOSE
& VERBOSE_API
)
394 _mesa_debug(ctx
, "glActiveStencilFaceEXT()\n");
396 if (!ctx
->Extensions
.EXT_stencil_two_side
) {
397 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glActiveStencilFaceEXT");
401 if (face
== GL_FRONT
|| face
== GL_BACK
) {
402 ctx
->Stencil
.ActiveFace
= (face
== GL_FRONT
) ? 0 : 2;
405 _mesa_error(ctx
, GL_INVALID_ENUM
, "glActiveStencilFaceEXT(face)");
411 stencil_op_separate(struct gl_context
*ctx
, GLenum face
, GLenum sfail
,
412 GLenum zfail
, GLenum zpass
)
414 GLboolean set
= GL_FALSE
;
416 if (face
!= GL_BACK
) {
418 if (ctx
->Stencil
.ZFailFunc
[0] != zfail
||
419 ctx
->Stencil
.ZPassFunc
[0] != zpass
||
420 ctx
->Stencil
.FailFunc
[0] != sfail
){
421 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
422 ctx
->Stencil
.ZFailFunc
[0] = zfail
;
423 ctx
->Stencil
.ZPassFunc
[0] = zpass
;
424 ctx
->Stencil
.FailFunc
[0] = sfail
;
429 if (face
!= GL_FRONT
) {
431 if (ctx
->Stencil
.ZFailFunc
[1] != zfail
||
432 ctx
->Stencil
.ZPassFunc
[1] != zpass
||
433 ctx
->Stencil
.FailFunc
[1] != sfail
) {
434 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
435 ctx
->Stencil
.ZFailFunc
[1] = zfail
;
436 ctx
->Stencil
.ZPassFunc
[1] = zpass
;
437 ctx
->Stencil
.FailFunc
[1] = sfail
;
442 if (set
&& ctx
->Driver
.StencilOpSeparate
) {
443 ctx
->Driver
.StencilOpSeparate(ctx
, face
, sfail
, zfail
, zpass
);
449 _mesa_StencilOpSeparate_no_error(GLenum face
, GLenum sfail
, GLenum zfail
,
452 GET_CURRENT_CONTEXT(ctx
);
453 stencil_op_separate(ctx
, face
, sfail
, zfail
, zpass
);
458 _mesa_StencilOpSeparate(GLenum face
, GLenum sfail
, GLenum zfail
, GLenum zpass
)
460 GET_CURRENT_CONTEXT(ctx
);
462 if (MESA_VERBOSE
& VERBOSE_API
)
463 _mesa_debug(ctx
, "glStencilOpSeparate()\n");
465 if (!validate_stencil_op(ctx
, sfail
)) {
466 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOpSeparate(sfail)");
470 if (!validate_stencil_op(ctx
, zfail
)) {
471 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOpSeparate(zfail)");
475 if (!validate_stencil_op(ctx
, zpass
)) {
476 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOpSeparate(zpass)");
480 if (face
!= GL_FRONT
&& face
!= GL_BACK
&& face
!= GL_FRONT_AND_BACK
) {
481 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilOpSeparate(face)");
485 stencil_op_separate(ctx
, face
, sfail
, zfail
, zpass
);
490 stencil_func_separate(struct gl_context
*ctx
, GLenum face
, GLenum func
,
491 GLint ref
, GLuint mask
)
493 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
495 if (face
!= GL_BACK
) {
497 ctx
->Stencil
.Function
[0] = func
;
498 ctx
->Stencil
.Ref
[0] = ref
;
499 ctx
->Stencil
.ValueMask
[0] = mask
;
502 if (face
!= GL_FRONT
) {
504 ctx
->Stencil
.Function
[1] = func
;
505 ctx
->Stencil
.Ref
[1] = ref
;
506 ctx
->Stencil
.ValueMask
[1] = mask
;
509 if (ctx
->Driver
.StencilFuncSeparate
) {
510 ctx
->Driver
.StencilFuncSeparate(ctx
, face
, func
, ref
, mask
);
517 _mesa_StencilFuncSeparate_no_error(GLenum face
, GLenum func
, GLint ref
,
520 GET_CURRENT_CONTEXT(ctx
);
521 stencil_func_separate(ctx
, face
, func
, ref
, mask
);
526 _mesa_StencilFuncSeparate(GLenum face
, GLenum func
, GLint ref
, GLuint mask
)
528 GET_CURRENT_CONTEXT(ctx
);
530 if (MESA_VERBOSE
& VERBOSE_API
)
531 _mesa_debug(ctx
, "glStencilFuncSeparate()\n");
533 if (face
!= GL_FRONT
&& face
!= GL_BACK
&& face
!= GL_FRONT_AND_BACK
) {
534 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilFuncSeparate(face)");
538 if (!validate_stencil_func(ctx
, func
)) {
539 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilFuncSeparate(func)");
543 stencil_func_separate(ctx
, face
, func
, ref
, mask
);
548 stencil_mask_separate(struct gl_context
*ctx
, GLenum face
, GLuint mask
)
550 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
552 if (face
!= GL_BACK
) {
553 ctx
->Stencil
.WriteMask
[0] = mask
;
556 if (face
!= GL_FRONT
) {
557 ctx
->Stencil
.WriteMask
[1] = mask
;
560 if (ctx
->Driver
.StencilMaskSeparate
) {
561 ctx
->Driver
.StencilMaskSeparate(ctx
, face
, mask
);
568 _mesa_StencilMaskSeparate_no_error(GLenum face
, GLuint mask
)
570 GET_CURRENT_CONTEXT(ctx
);
571 stencil_mask_separate(ctx
, face
, mask
);
576 _mesa_StencilMaskSeparate(GLenum face
, GLuint mask
)
578 GET_CURRENT_CONTEXT(ctx
);
580 if (MESA_VERBOSE
& VERBOSE_API
)
581 _mesa_debug(ctx
, "glStencilMaskSeparate()\n");
583 if (face
!= GL_FRONT
&& face
!= GL_BACK
&& face
!= GL_FRONT_AND_BACK
) {
584 _mesa_error(ctx
, GL_INVALID_ENUM
, "glStencilaMaskSeparate(face)");
588 stencil_mask_separate(ctx
, face
, mask
);
593 * Update derived stencil state.
596 _mesa_update_stencil(struct gl_context
*ctx
)
598 const GLint face
= ctx
->Stencil
._BackFace
;
600 ctx
->Stencil
._Enabled
= (ctx
->Stencil
.Enabled
&&
601 ctx
->DrawBuffer
->Visual
.stencilBits
> 0);
603 ctx
->Stencil
._TestTwoSide
=
604 ctx
->Stencil
._Enabled
&&
605 (ctx
->Stencil
.Function
[0] != ctx
->Stencil
.Function
[face
] ||
606 ctx
->Stencil
.FailFunc
[0] != ctx
->Stencil
.FailFunc
[face
] ||
607 ctx
->Stencil
.ZPassFunc
[0] != ctx
->Stencil
.ZPassFunc
[face
] ||
608 ctx
->Stencil
.ZFailFunc
[0] != ctx
->Stencil
.ZFailFunc
[face
] ||
609 ctx
->Stencil
.Ref
[0] != ctx
->Stencil
.Ref
[face
] ||
610 ctx
->Stencil
.ValueMask
[0] != ctx
->Stencil
.ValueMask
[face
] ||
611 ctx
->Stencil
.WriteMask
[0] != ctx
->Stencil
.WriteMask
[face
]);
613 ctx
->Stencil
._WriteEnabled
=
614 ctx
->Stencil
._Enabled
&&
615 (ctx
->Stencil
.WriteMask
[0] != 0 ||
616 (ctx
->Stencil
._TestTwoSide
&& ctx
->Stencil
.WriteMask
[face
] != 0));
621 * Initialize the context stipple state.
623 * \param ctx GL context.
625 * Initializes __struct gl_contextRec::Stencil attribute group.
628 _mesa_init_stencil(struct gl_context
*ctx
)
630 ctx
->Stencil
.Enabled
= GL_FALSE
;
631 ctx
->Stencil
.TestTwoSide
= GL_FALSE
;
632 ctx
->Stencil
.ActiveFace
= 0; /* 0 = GL_FRONT, 2 = GL_BACK */
633 ctx
->Stencil
.Function
[0] = GL_ALWAYS
;
634 ctx
->Stencil
.Function
[1] = GL_ALWAYS
;
635 ctx
->Stencil
.Function
[2] = GL_ALWAYS
;
636 ctx
->Stencil
.FailFunc
[0] = GL_KEEP
;
637 ctx
->Stencil
.FailFunc
[1] = GL_KEEP
;
638 ctx
->Stencil
.FailFunc
[2] = GL_KEEP
;
639 ctx
->Stencil
.ZPassFunc
[0] = GL_KEEP
;
640 ctx
->Stencil
.ZPassFunc
[1] = GL_KEEP
;
641 ctx
->Stencil
.ZPassFunc
[2] = GL_KEEP
;
642 ctx
->Stencil
.ZFailFunc
[0] = GL_KEEP
;
643 ctx
->Stencil
.ZFailFunc
[1] = GL_KEEP
;
644 ctx
->Stencil
.ZFailFunc
[2] = GL_KEEP
;
645 ctx
->Stencil
.Ref
[0] = 0;
646 ctx
->Stencil
.Ref
[1] = 0;
647 ctx
->Stencil
.Ref
[2] = 0;
649 /* 4.1.4 Stencil Test section of the GL-ES 3.0 specification says:
651 * "In the initial state, [...] the front and back stencil mask are both
652 * set to the value 2^s − 1, where s is greater than or equal to the
653 * number of bits in the deepest stencil buffer* supported by the GL
656 * Since the maximum supported precision for stencil buffers is 8 bits,
657 * mask values should be initialized to 2^8 - 1 = 0xFF.
659 ctx
->Stencil
.ValueMask
[0] = 0xFF;
660 ctx
->Stencil
.ValueMask
[1] = 0xFF;
661 ctx
->Stencil
.ValueMask
[2] = 0xFF;
662 ctx
->Stencil
.WriteMask
[0] = 0xFF;
663 ctx
->Stencil
.WriteMask
[1] = 0xFF;
664 ctx
->Stencil
.WriteMask
[2] = 0xFF;
666 ctx
->Stencil
.Clear
= 0;
667 ctx
->Stencil
._BackFace
= 1;