core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

stencil.c File Reference


Detailed Description

Stencil operations.

Note: There's some conflict between GL_EXT_stencil_two_side and OpenGL 2.0's two-sided stencil feature.

With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the front OR back face state (as set by glActiveStencilFaceEXT) is set.

But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the front AND back state.

Also, note that GL_ATI_separate_stencil is different as well: glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs. glStencilFuncSeparate(GLenum face, GLenum func, ...).

This problem is solved by keeping three sets of stencil state: state[0] = GL_FRONT state. state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state. state[2] = GL_EXT_stencil_two_side GL_BACK state.

#include "glheader.h"
#include "imports.h"
#include "context.h"
#include "macros.h"
#include "stencil.h"
#include "mtypes.h"

Functions

static GLboolean validate_stencil_op (GLcontext *ctx, GLenum op)
static GLboolean validate_stencil_func (GLcontext *ctx, GLenum func)
void GLAPIENTRY _mesa_ClearStencil (GLint s)
 Set the clear value for the stencil buffer.
void GLAPIENTRY _mesa_StencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask)
 Set the function and reference value for stencil testing.
void GLAPIENTRY _mesa_StencilFunc (GLenum func, GLint ref, GLuint mask)
 Set the function and reference value for stencil testing.
void GLAPIENTRY _mesa_StencilMask (GLuint mask)
 Set the stencil writing mask.
void GLAPIENTRY _mesa_StencilOp (GLenum fail, GLenum zfail, GLenum zpass)
 Set the stencil test actions.
void GLAPIENTRY _mesa_ActiveStencilFaceEXT (GLenum face)
void GLAPIENTRY _mesa_StencilOpSeparate (GLenum face, GLenum sfail, GLenum zfail, GLenum zpass)
 OpenGL 2.0 function.
void GLAPIENTRY _mesa_StencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask)
void GLAPIENTRY _mesa_StencilMaskSeparate (GLenum face, GLuint mask)
void _mesa_update_stencil (GLcontext *ctx)
 Update derived stencil state.
void _mesa_init_stencil (GLcontext *ctx)
 Initialize the context stipple state.


Function Documentation

void GLAPIENTRY _mesa_ActiveStencilFaceEXT ( GLenum  face  ) 

void GLAPIENTRY _mesa_ClearStencil ( GLint  s  ) 

Set the clear value for the stencil buffer.

Parameters:
s clear value.
See also:
glClearStencil().
Updates gl_stencil_attrib::Clear. On change flushes the vertices and notifies the driver via the dd_function_table::ClearStencil callback.

void _mesa_init_stencil ( GLcontext ctx  ) 

Initialize the context stipple state.

Parameters:
ctx GL context.
Initializes __GLcontextRec::Stencil attribute group.

void GLAPIENTRY _mesa_StencilFunc ( GLenum  func,
GLint  ref,
GLuint  mask 
)

Set the function and reference value for stencil testing.

Parameters:
func test function.
ref reference value.
mask bitmask.
See also:
glStencilFunc().
Verifies the parameters and updates the respective values in __GLcontextRec::Stencil. On change flushes the vertices and notifies the driver via the dd_function_table::StencilFunc callback.

void GLAPIENTRY _mesa_StencilFuncSeparate ( GLenum  face,
GLenum  func,
GLint  ref,
GLuint  mask 
)

void GLAPIENTRY _mesa_StencilFuncSeparateATI ( GLenum  frontfunc,
GLenum  backfunc,
GLint  ref,
GLuint  mask 
)

Set the function and reference value for stencil testing.

Parameters:
frontfunc front test function.
backfunc back test function.
ref front and back reference value.
mask front and back bitmask.
See also:
glStencilFunc().
Verifies the parameters and updates the respective values in __GLcontextRec::Stencil. On change flushes the vertices and notifies the driver via the dd_function_table::StencilFunc callback.

void GLAPIENTRY _mesa_StencilMask ( GLuint  mask  ) 

Set the stencil writing mask.

Parameters:
mask bit-mask to enable/disable writing of individual bits in the stencil planes.
See also:
glStencilMask().
Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and notifies the driver via the dd_function_table::StencilMask callback.

void GLAPIENTRY _mesa_StencilMaskSeparate ( GLenum  face,
GLuint  mask 
)

void GLAPIENTRY _mesa_StencilOp ( GLenum  fail,
GLenum  zfail,
GLenum  zpass 
)

Set the stencil test actions.

Parameters:
fail action to take when stencil test fails.
zfail action to take when stencil test passes, but depth test fails.
zpass action to take when stencil test passes and the depth test passes (or depth testing is not enabled).
See also:
glStencilOp().
Verifies the parameters and updates the respective fields in __GLcontextRec::Stencil. On change flushes the vertices and notifies the driver via the dd_function_table::StencilOp callback.

void GLAPIENTRY _mesa_StencilOpSeparate ( GLenum  face,
GLenum  sfail,
GLenum  zfail,
GLenum  zpass 
)

OpenGL 2.0 function.

Todo:
Make StencilOp() call this function. And eventually remove the ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate instead.

void _mesa_update_stencil ( GLcontext ctx  ) 

Update derived stencil state.

static GLboolean validate_stencil_func ( GLcontext ctx,
GLenum  func 
) [static]

static GLboolean validate_stencil_op ( GLcontext ctx,
GLenum  op 
) [static]


Generated on Sun Sep 27 06:47:46 2009 for Mesa Main by  doxygen 1.5.4