public override void SetStencilBufferParams( CompareFunction function = CompareFunction.AlwaysPass,
int refValue = 0, int mask = -1,
StencilOperation stencilFailOp = StencilOperation.Keep, StencilOperation depthFailOp = StencilOperation.Keep,
StencilOperation passOp = StencilOperation.Keep, bool twoSidedOperation = false )
{
bool flip;
// 2 sided operation?
if ( twoSidedOperation )
{
if (!currentCapabilities.HasCapability(Graphics.Capabilities.TwoSidedStencil))
{
throw new AxiomException( "2-sided stencils are not supported on this hardware!" );
}
SetRenderState( RenderState.TwoSidedStencilMode, true );
// NB: We should always treat CCW as front face for consistent with default
// culling mode. Therefore, we must take care with two-sided stencil settings.
flip = (invertVertexWinding && activeRenderTarget.RequiresTextureFlipping) ||
(!invertVertexWinding && !activeRenderTarget.RequiresTextureFlipping);
SetRenderState( RenderState.CcwStencilFail, (int)D3DHelper.ConvertEnum( stencilFailOp, !flip ) );
SetRenderState( RenderState.CcwStencilZFail, (int)D3DHelper.ConvertEnum( depthFailOp, !flip ) );
SetRenderState( RenderState.CcwStencilPass, (int)D3DHelper.ConvertEnum( passOp, !flip ) );
}
else
{
SetRenderState( RenderState.TwoSidedStencilMode, false );
flip = false;
}
// configure standard version of the stencil operations
SetRenderState( RenderState.StencilFunc, (int)D3DHelper.ConvertEnum( function ) );
SetRenderState( RenderState.StencilRef, refValue );
SetRenderState( RenderState.StencilMask, mask );
SetRenderState( RenderState.StencilFail, (int)D3DHelper.ConvertEnum( stencilFailOp, flip ) );
SetRenderState( RenderState.StencilZFail, (int)D3DHelper.ConvertEnum( depthFailOp, flip ) );
SetRenderState( RenderState.StencilPass, (int)D3DHelper.ConvertEnum( passOp, flip ) );
}