GetStencilOp() private static method

private static GetStencilOp ( StencilOperation operation ) : StencilOp
operation StencilOperation
return StencilOp
Exemplo n.º 1
0
        internal void ApplyState(GraphicsDevice device)
        {
            if (!this.DepthBufferEnable)
            {
                GL.Disable(EnableCap.DepthTest);
            }
            else
            {
                GL.Enable(EnableCap.DepthTest);
                DepthFunction func;
                switch (this.DepthBufferFunction)
                {
                case CompareFunction.Never:
                    func = DepthFunction.Never;
                    break;

                case CompareFunction.Less:
                    func = DepthFunction.Less;
                    break;

                case CompareFunction.LessEqual:
                    func = DepthFunction.Lequal;
                    break;

                case CompareFunction.Equal:
                    func = DepthFunction.Equal;
                    break;

                case CompareFunction.GreaterEqual:
                    func = DepthFunction.Gequal;
                    break;

                case CompareFunction.Greater:
                    func = DepthFunction.Greater;
                    break;

                case CompareFunction.NotEqual:
                    func = DepthFunction.Notequal;
                    break;

                default:
                    func = DepthFunction.Always;
                    break;
                }
                GL.DepthFunc(func);
            }
            GL.DepthMask(this.DepthBufferWriteEnable);
            if (!this.StencilEnable)
            {
                GL.Disable(EnableCap.StencilTest);
            }
            else
            {
                GL.Enable(EnableCap.StencilTest);
                StencilFunction func;
                switch (this.StencilFunction)
                {
                case CompareFunction.Never:
                    func = StencilFunction.Never;
                    break;

                case CompareFunction.Less:
                    func = StencilFunction.Less;
                    break;

                case CompareFunction.LessEqual:
                    func = StencilFunction.Lequal;
                    break;

                case CompareFunction.Equal:
                    func = StencilFunction.Equal;
                    break;

                case CompareFunction.GreaterEqual:
                    func = StencilFunction.Gequal;
                    break;

                case CompareFunction.Greater:
                    func = StencilFunction.Greater;
                    break;

                case CompareFunction.NotEqual:
                    func = StencilFunction.Notequal;
                    break;

                default:
                    func = StencilFunction.Always;
                    break;
                }
                GL.StencilFunc(func, this.ReferenceStencil, this.StencilMask);
                GL.StencilOp(DepthStencilState.GetStencilOp(this.StencilFail), DepthStencilState.GetStencilOp(this.StencilDepthBufferFail), DepthStencilState.GetStencilOp(this.StencilPass));
            }
        }
Exemplo n.º 2
0
        internal void ApplyState(GraphicsDevice device)
        {
            if (!this.DepthBufferEnable)
            {
                GL.Disable(EnableCap.DepthTest);
            }
            else
            {
                GL.Enable(EnableCap.DepthTest);
                DepthFunction func;
                switch (this.DepthBufferFunction)
                {
                case CompareFunction.Never:
                    func = DepthFunction.Never;
                    break;

                case CompareFunction.Less:
                    func = DepthFunction.Less;
                    break;

                case CompareFunction.LessEqual:
                    func = DepthFunction.Lequal;
                    break;

                case CompareFunction.Equal:
                    func = DepthFunction.Equal;
                    break;

                case CompareFunction.GreaterEqual:
                    func = DepthFunction.Gequal;
                    break;

                case CompareFunction.Greater:
                    func = DepthFunction.Greater;
                    break;

                case CompareFunction.NotEqual:
                    func = DepthFunction.Notequal;
                    break;

                default:
                    func = DepthFunction.Always;
                    break;
                }
                GL.DepthFunc(func);
            }
            GL.DepthMask(this.DepthBufferWriteEnable);
            if (!this.StencilEnable)
            {
                GL.Disable(EnableCap.StencilTest);
            }
            else
            {
                GL.Enable(EnableCap.StencilTest);
                if (this.TwoSidedStencilMode)
                {
                    Version20   face1 = (Version20)1028;
                    Version20   face2 = (Version20)1029;
                    StencilFace face3 = StencilFace.Front;
                    StencilFace face4 = StencilFace.Back;
                    GL.StencilFuncSeparate(face1, DepthStencilState.GetStencilFunc(this.StencilFunction), this.ReferenceStencil, this.StencilMask);
                    GL.StencilFuncSeparate(face2, DepthStencilState.GetStencilFunc(this.CounterClockwiseStencilFunction), this.ReferenceStencil, this.StencilMask);
                    GL.StencilOpSeparate(face3, DepthStencilState.GetStencilOp(this.StencilFail), DepthStencilState.GetStencilOp(this.StencilDepthBufferFail), DepthStencilState.GetStencilOp(this.StencilPass));
                    GL.StencilOpSeparate(face4, DepthStencilState.GetStencilOp(this.CounterClockwiseStencilFail), DepthStencilState.GetStencilOp(this.CounterClockwiseStencilDepthBufferFail), DepthStencilState.GetStencilOp(this.CounterClockwiseStencilPass));
                }
                else
                {
                    GL.StencilFunc(DepthStencilState.GetStencilFunc(this.StencilFunction), this.ReferenceStencil, this.StencilMask);
                    GL.StencilOp(DepthStencilState.GetStencilOp(this.StencilFail), DepthStencilState.GetStencilOp(this.StencilDepthBufferFail), DepthStencilState.GetStencilOp(this.StencilPass));
                }
            }
        }