-/* $Id: s_stencil.c,v 1.4 2000/11/28 21:34:04 brianp Exp $ */
+/* $Id: s_stencil.c,v 1.8 2001/03/03 20:33:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
}
break;
default:
- gl_problem(ctx, "Bad stencil op in apply_stencil_op");
+ _mesa_problem(ctx, "Bad stencil op in apply_stencil_op");
}
}
}
break;
default:
- gl_problem(ctx, "Bad stencil func in gl_stencil_span");
+ _mesa_problem(ctx, "Bad stencil func in gl_stencil_span");
return 0;
}
}
break;
default:
- gl_problem(ctx, "Bad stencilop in apply_stencil_op_to_pixels");
+ _mesa_problem(ctx, "Bad stencilop in apply_stencil_op_to_pixels");
}
}
}
break;
default:
- gl_problem(ctx, "Bad stencil func in gl_stencil_pixels");
+ _mesa_problem(ctx, "Bad stencil func in gl_stencil_pixels");
return 0;
}
if (ctx->Driver.WriteStencilPixels) {
/*** Hardware stencil buffer ***/
GLstencil stencil[PB_SIZE];
- GLubyte mask[PB_SIZE];
+ GLubyte origMask[PB_SIZE];
ASSERT(ctx->Driver.ReadStencilPixels);
(*ctx->Driver.ReadStencilPixels)(ctx, n, x, y, stencil);
+ MEMCPY(origMask, mask, n * sizeof(GLubyte));
- if (do_stencil_test( ctx, n, stencil, mask ) == GL_FALSE) {
- /* all fragments failed the stencil test, we're done. */
- return GL_FALSE;
- }
+ (void) do_stencil_test(ctx, n, stencil, mask);
if (ctx->Depth.Test == GL_FALSE) {
- apply_stencil_op( ctx, ctx->Stencil.ZPassFunc, n, stencil, mask );
+ apply_stencil_op(ctx, ctx->Stencil.ZPassFunc, n, stencil, mask);
}
else {
- GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
- GLuint i;
-
- MEMCPY(oldmask, mask, n * sizeof(GLubyte));
-
_mesa_depth_test_pixels(ctx, n, x, y, z, mask);
- for (i=0;i<n;i++) {
- ASSERT(mask[i] == 0 || mask[i] == 1);
- passmask[i] = oldmask[i] & mask[i];
- failmask[i] = oldmask[i] & (mask[i] ^ 1);
- }
-
if (ctx->Stencil.ZFailFunc != GL_KEEP) {
- apply_stencil_op( ctx, ctx->Stencil.ZFailFunc, n, stencil, failmask );
+ GLubyte failmask[PB_SIZE];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ failmask[i] = origMask[i] & (mask[i] ^ 1);
+ }
+ apply_stencil_op(ctx, ctx->Stencil.ZFailFunc,
+ n, stencil, failmask);
}
if (ctx->Stencil.ZPassFunc != GL_KEEP) {
- apply_stencil_op( ctx, ctx->Stencil.ZPassFunc, n, stencil, passmask );
+ GLubyte passmask[PB_SIZE];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ passmask[i] = origMask[i] & mask[i];
+ }
+ apply_stencil_op(ctx, ctx->Stencil.ZPassFunc,
+ n, stencil, passmask);
}
}
/* Write updated stencil values into hardware stencil buffer */
- (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, mask );
+ (ctx->Driver.WriteStencilPixels)(ctx, n, x, y, stencil, origMask);
return GL_TRUE;
-
}
else {
/*** Software stencil buffer ***/
return GL_FALSE;
}
-
if (ctx->Depth.Test==GL_FALSE) {
- apply_stencil_op_to_pixels( ctx, n, x, y, ctx->Stencil.ZPassFunc, mask );
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZPassFunc, mask);
}
else {
GLubyte passmask[PB_SIZE], failmask[PB_SIZE], oldmask[PB_SIZE];
}
if (ctx->Stencil.ZFailFunc != GL_KEEP) {
- apply_stencil_op_to_pixels( ctx, n, x, y,
- ctx->Stencil.ZFailFunc, failmask );
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZFailFunc, failmask);
}
if (ctx->Stencil.ZPassFunc != GL_KEEP) {
- apply_stencil_op_to_pixels( ctx, n, x, y,
- ctx->Stencil.ZPassFunc, passmask );
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZPassFunc, passmask);
}
}
if (!ctx->DrawBuffer->Stencil) {
/* out of memory */
/* _mesa_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE ); */
- gl_error( ctx, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" );
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" );
}
}
static void
clear_software_stencil_buffer( GLcontext *ctx )
{
- if (ctx->Visual.StencilBits==0 || !ctx->DrawBuffer->Stencil) {
+ if (ctx->Visual.stencilBits==0 || !ctx->DrawBuffer->Stencil) {
/* no stencil buffer */
return;
}