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. |
void GLAPIENTRY _mesa_ActiveStencilFaceEXT | ( | GLenum | face | ) |
void GLAPIENTRY _mesa_ClearStencil | ( | GLint | s | ) |
Set the clear value for the stencil buffer.
s | clear value. |
void _mesa_init_stencil | ( | GLcontext * | ctx | ) |
Initialize the context stipple state.
ctx | GL context. |
void GLAPIENTRY _mesa_StencilFunc | ( | GLenum | func, | |
GLint | ref, | |||
GLuint | mask | |||
) |
Set the function and reference value for stencil testing.
func | test function. | |
ref | reference value. | |
mask | bitmask. |
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.
frontfunc | front test function. | |
backfunc | back test function. | |
ref | front and back reference value. | |
mask | front and back bitmask. |
void GLAPIENTRY _mesa_StencilMask | ( | GLuint | mask | ) |
Set the stencil writing mask.
mask | bit-mask to enable/disable writing of individual bits in the stencil planes. |
void GLAPIENTRY _mesa_StencilMaskSeparate | ( | GLenum | face, | |
GLuint | mask | |||
) |
void GLAPIENTRY _mesa_StencilOp | ( | GLenum | fail, | |
GLenum | zfail, | |||
GLenum | zpass | |||
) |
Set the stencil test actions.
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). |
void GLAPIENTRY _mesa_StencilOpSeparate | ( | GLenum | face, | |
GLenum | sfail, | |||
GLenum | zfail, | |||
GLenum | zpass | |||
) |
OpenGL 2.0 function.
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] |