public void SetDefaults()
 {
     StencilFailOp      = StencilOperation.Keep;
     StencilDepthFailOp = StencilOperation.Keep;
     StencilPassOp      = StencilOperation.Keep;
     StencilFunc        = Comparison.Always;
 }
Exemplo n.º 2
0
        public static SharpVulkan.StencilOperation ConvertStencilOperation(StencilOperation operation)
        {
            switch (operation)
            {
            case StencilOperation.Decrement:
                return(SharpVulkan.StencilOperation.DecrementAndWrap);

            case StencilOperation.DecrementSaturation:
                return(SharpVulkan.StencilOperation.DecrementAndClamp);

            case StencilOperation.Increment:
                return(SharpVulkan.StencilOperation.IncrementAndWrap);

            case StencilOperation.IncrementSaturation:
                return(SharpVulkan.StencilOperation.IncrementAndClamp);

            case StencilOperation.Invert:
                return(SharpVulkan.StencilOperation.Invert);

            case StencilOperation.Keep:
                return(SharpVulkan.StencilOperation.Keep);

            case StencilOperation.Replace:
                return(SharpVulkan.StencilOperation.Replace);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DepthStencilOperationDescription"/> struct.
 /// </summary>
 /// <param name="stencilFailOp">A <see cref="StencilOperation"/> value that identifies the stencil operation to perform when stencil testing fails.</param>
 /// <param name="stencilDepthFailOp">A <see cref="StencilOperation"/> value that identifies the stencil operation to perform when stencil testing passes and depth testing fails.</param>
 /// <param name="stencilPassOp">A <see cref="StencilOperation"/> value that identifies the stencil operation to perform when stencil testing and depth testing both pass.</param>
 /// <param name="stencilFunc">A <see cref="ComparisonFunction"/> value that identifies the function that compares stencil data against existing stencil data.</param>
 public DepthStencilOperationDescription(StencilOperation stencilFailOp, StencilOperation stencilDepthFailOp, StencilOperation stencilPassOp, ComparisonFunction stencilFunc)
 {
     StencilFailOp      = stencilFailOp;
     StencilDepthFailOp = stencilDepthFailOp;
     StencilPassOp      = stencilPassOp;
     StencilFunc        = stencilFunc;
 }
Exemplo n.º 4
0
        internal static XFG.StencilOperation ToXNAStencilOperation(StencilOperation op)
        {
            switch (op)
            {
            case StencilOperation.Decrement:
                return(XFG.StencilOperation.Decrement);

            case StencilOperation.DecrementAndClamp:
                return(XFG.StencilOperation.DecrementSaturation);

            case StencilOperation.Increment:
                return(XFG.StencilOperation.Increment);

            case StencilOperation.IncrementAndClamp:
                return(XFG.StencilOperation.IncrementSaturation);

            case StencilOperation.Invert:
                return(XFG.StencilOperation.Invert);

            case StencilOperation.Keep:
                return(XFG.StencilOperation.Keep);

            case StencilOperation.Replace:
                return(XFG.StencilOperation.Replace);

            case StencilOperation.Zero:
                return(XFG.StencilOperation.Zero);

            default:
                throw new InvalidCastException();
            }
        }
Exemplo n.º 5
0
        public DepthStencilState(bool depthEnabled, bool stencilEnabled, Comparison depthComparison,
            Comparison frontFaceComparison, StencilOperation frontFaceDepthFailOp, StencilOperation frontFaceFailOp, StencilOperation frontFacePassOp,
            Comparison backFaceComparison, StencilOperation backFaceDepthFailOp, StencilOperation backFaceFailOp, StencilOperation backFacePassOp)
        {

            DepthStencilStateDescription desc = new DepthStencilStateDescription()
            {
                IsDepthEnabled = depthEnabled,
                IsStencilEnabled = stencilEnabled,
                DepthWriteMask = SharpDX.Direct3D11.DepthWriteMask.All,
                FrontFace = new DepthStencilOperationDescription()
                {
                    Comparison = frontFaceComparison,
                    DepthFailOperation = frontFaceDepthFailOp,
                    FailOperation = frontFaceFailOp,
                    PassOperation = frontFacePassOp
                },
                BackFace = new DepthStencilOperationDescription()
                {
                    Comparison = backFaceComparison,
                    DepthFailOperation = backFaceDepthFailOp,
                    FailOperation = backFaceFailOp,
                    PassOperation = backFacePassOp
                },
                DepthComparison = depthComparison
            };

            NativeDepthStencilState = new SharpDX.Direct3D11.DepthStencilState(GraphicManager.Device, desc);

        }
Exemplo n.º 6
0
        public static StencilOp ToOpenGL(this StencilOperation operation)
        {
            switch (operation)
            {
            case StencilOperation.Keep:
                return(StencilOp.Keep);

            case StencilOperation.Zero:
                return(StencilOp.Zero);

            case StencilOperation.Replace:
                return(StencilOp.Replace);

            case StencilOperation.IncrementSaturation:
                return(StencilOp.Incr);

            case StencilOperation.DecrementSaturation:
                return(StencilOp.Decr);

            case StencilOperation.Invert:
                return(StencilOp.Invert);

            case StencilOperation.Increment:
                return(StencilOp.IncrWrap);

            case StencilOperation.Decrement:
                return(StencilOp.DecrWrap);

            default:
                throw new ArgumentOutOfRangeException("operation");
            }
        }
Exemplo n.º 7
0
        public static StencilOp To(StencilOperation operation)
        {
            switch (operation)
            {
            case StencilOperation.Zero:
                return(StencilOp.Zero);

            case StencilOperation.Invert:
                return(StencilOp.Invert);

            case StencilOperation.Keep:
                return(StencilOp.Keep);

            case StencilOperation.Replace:
                return(StencilOp.Replace);

            case StencilOperation.Increment:
                return(StencilOp.Incr);

            case StencilOperation.Decrement:
                return(StencilOp.Decr);

            case StencilOperation.IncrementWrap:
                return(StencilOp.IncrWrap);

            case StencilOperation.DecrementWrap:
                return(StencilOp.DecrWrap);
            }

            throw new ArgumentException("operation");
        }
 public StencilTestOperationDesc_NativeInterop(ref StencilTestOperationDesc desc)
 {
     stencilTestFunction       = desc.stencilTestFunction;
     stencilFailOperation      = desc.stencilFailOperation;
     stencilDepthFailOperation = desc.stencilDepthFailOperation;
     stencilPassOperation      = desc.stencilPassOperation;
 }
Exemplo n.º 9
0
        internal static D3D.StencilOperation ToD3DStencilOperation(StencilOperation func)
        {
            switch (func)
            {
            case StencilOperation.Zero:
                return(D3D.StencilOperation.Zero);

            case StencilOperation.Replace:
                return(D3D.StencilOperation.Replace);

            case StencilOperation.Keep:
                return(D3D.StencilOperation.Keep);

            case StencilOperation.Invert:
                return(D3D.StencilOperation.Invert);

            case StencilOperation.IncrementAndClamp:
                return(D3D.StencilOperation.IncrementAndClamp);

            case StencilOperation.Increment:
                return(D3D.StencilOperation.Increment);

            case StencilOperation.DecrementAndClamp:
                return(D3D.StencilOperation.DecrementAndClamp);

            case StencilOperation.Decrement:
                return(D3D.StencilOperation.Decrement);

            default:
                throw new ArgumentException("Invalid stencil function");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DepthStencilDescription"/> struct.
 /// </summary>
 /// <param name="depthEnable">Specifies whether to enable depth testing. Set this member to <b>true</b> to enable depth testing.</param>
 /// <param name="depthWriteEnable">Specifies a value that identifies a portion of the depth-stencil buffer that can be modified by depth data.</param>
 /// <param name="depthFunc">A <see cref="ComparisonFunction"/> value that identifies a function that compares depth data against existing depth data.</param>
 /// <param name="stencilEnable">Specifies whether to enable stencil testing. Set this member to <b>true</b> to enable stencil testing.</param>
 /// <param name="stencilReadMask">Identify a portion of the depth-stencil buffer for reading stencil data.</param>
 /// <param name="stencilWriteMask">Identify a portion of the depth-stencil buffer for writing stencil data.</param>
 /// <param name="frontStencilFailOp"></param>
 /// <param name="frontStencilDepthFailOp"></param>
 /// <param name="frontStencilPassOp"></param>
 /// <param name="frontStencilFunc"></param>
 /// <param name="backStencilFailOp"></param>
 /// <param name="backStencilDepthFailOp"></param>
 /// <param name="backStencilPassOp"></param>
 /// <param name="backStencilFunc"></param>
 public DepthStencilDescription(
     bool depthEnable,
     bool depthWriteEnable,
     ComparisonFunction depthFunc,
     bool stencilEnable,
     byte stencilReadMask,
     byte stencilWriteMask,
     StencilOperation frontStencilFailOp,
     StencilOperation frontStencilDepthFailOp,
     StencilOperation frontStencilPassOp,
     ComparisonFunction frontStencilFunc,
     StencilOperation backStencilFailOp,
     StencilOperation backStencilDepthFailOp,
     StencilOperation backStencilPassOp,
     ComparisonFunction backStencilFunc)
 {
     DepthEnable                  = depthEnable;
     DepthWriteMask               = depthWriteEnable ? DepthWriteMask.All : DepthWriteMask.Zero;
     DepthFunc                    = depthFunc;
     StencilEnable                = stencilEnable;
     StencilReadMask              = stencilReadMask;
     StencilWriteMask             = stencilWriteMask;
     FrontFace.StencilFailOp      = frontStencilFailOp;
     FrontFace.StencilDepthFailOp = frontStencilDepthFailOp;
     FrontFace.StencilPassOp      = frontStencilPassOp;
     FrontFace.StencilFunc        = frontStencilFunc;
     BackFace.StencilFailOp       = backStencilFailOp;
     BackFace.StencilDepthFailOp  = backStencilDepthFailOp;
     BackFace.StencilPassOp       = backStencilPassOp;
     BackFace.StencilFunc         = backStencilFunc;
 }
Exemplo n.º 11
0
        /// <summary>
        ///		Find the GL int value for the StencilOperation enum.
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public static int ConvertEnum(StencilOperation op, bool invert)
        {
            switch (op)
            {
            case StencilOperation.Keep:
                return(Gl.GL_KEEP);

            case StencilOperation.Zero:
                return(Gl.GL_ZERO);

            case StencilOperation.Replace:
                return(Gl.GL_REPLACE);

            case StencilOperation.Increment:
                return(invert ? Gl.GL_DECR : Gl.GL_INCR);

            case StencilOperation.Decrement:
                return(invert ? Gl.GL_INCR : Gl.GL_DECR);

            case StencilOperation.IncrementWrap:
                return(invert ? Gl.GL_DECR_WRAP_EXT : Gl.GL_INCR_WRAP_EXT);

            case StencilOperation.DecrementWrap:
                return(invert ? Gl.GL_INCR_WRAP_EXT : Gl.GL_DECR_WRAP_EXT);

            case StencilOperation.Invert:
                return(Gl.GL_INVERT);
            }

            // make the compiler happy
            return(Gl.GL_KEEP);
        }
Exemplo n.º 12
0
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent                   = parent;
     this.type                     = CompositorPassType.RenderQuad;
     this.identifier               = 0;
     this.firstRenderQueue         = RenderQueueGroupID.Background;
     this.lastRenderQueue          = RenderQueueGroupID.SkiesLate;
     this.materialSchemeName       = string.Empty;
     this.clearBuffers             = FrameBufferType.Color | FrameBufferType.Depth;
     this.clearColor               = new ColorEx(0f, 0f, 0f, 0f);
     this.clearDepth               = 1.0f;
     this.clearStencil             = 0;
     this.stencilCheck             = false;
     this.stencilFunc              = CompareFunction.AlwaysPass;
     this.stencilRefValue          = 0;
     this.stencilMask              = 0x7FFFFFFF;
     this.stencilFailOp            = StencilOperation.Keep;
     this.stencilDepthFailOp       = StencilOperation.Keep;
     this.stencilPassOp            = StencilOperation.Keep;
     this.stencilTwoSidedOperation = false;
     this.quadCornerModified       = false;
     this.quadLeft                 = -1;
     this.quadTop                  = 1;
     this.quadRight                = 1;
     this.quadBottom               = -1;
     this.quadFarCorners           = false;
     this.quadFarCornersViewSpace  = false;
 }
Exemplo n.º 13
0
        private static StencilOp GetStencilOp(StencilOperation operation)
        {
            switch (operation)
            {
            case StencilOperation.Keep:
                return(StencilOp.Keep);

            case StencilOperation.Decrement:
                return(StencilOp.DecrWrap);

            case StencilOperation.DecrementSaturation:
                return(StencilOp.Decr);

            case StencilOperation.IncrementSaturation:
                return(StencilOp.Incr);

            case StencilOperation.Increment:
                return(StencilOp.IncrWrap);

            case StencilOperation.Invert:
                return(StencilOp.Invert);

            case StencilOperation.Replace:
                return(StencilOp.Replace);

            case StencilOperation.Zero:
                return(StencilOp.Zero);

            default:
                return(StencilOp.Keep);
            }
        }
Exemplo n.º 14
0
        internal static VkStencilOp VdToVkStencilOp(StencilOperation op)
        {
            switch (op)
            {
            case StencilOperation.Keep:
                return(VkStencilOp.Keep);

            case StencilOperation.Zero:
                return(VkStencilOp.Zero);

            case StencilOperation.Replace:
                return(VkStencilOp.Replace);

            case StencilOperation.IncrementAndClamp:
                return(VkStencilOp.IncrementAndClamp);

            case StencilOperation.DecrementAndClamp:
                return(VkStencilOp.DecrementAndClamp);

            case StencilOperation.Invert:
                return(VkStencilOp.Invert);

            case StencilOperation.IncrementAndWrap:
                return(VkStencilOp.IncrementAndWrap);

            case StencilOperation.DecrementAndWrap:
                return(VkStencilOp.DecrementAndWrap);

            default:
                throw Illegal.Value <StencilOperation>();
            }
        }
Exemplo n.º 15
0
        static private SharpDX.Direct3D11.StencilOperation GetStencilOp(StencilOperation op)
        {
            switch (op)
            {
            case StencilOperation.Decrement:
                return(SharpDX.Direct3D11.StencilOperation.Decrement);

            case StencilOperation.DecrementSaturation:
                return(SharpDX.Direct3D11.StencilOperation.DecrementAndClamp);

            case StencilOperation.Increment:
                return(SharpDX.Direct3D11.StencilOperation.Increment);

            case StencilOperation.IncrementSaturation:
                return(SharpDX.Direct3D11.StencilOperation.IncrementAndClamp);

            case StencilOperation.Invert:
                return(SharpDX.Direct3D11.StencilOperation.Invert);

            case StencilOperation.Keep:
                return(SharpDX.Direct3D11.StencilOperation.Keep);

            case StencilOperation.Replace:
                return(SharpDX.Direct3D11.StencilOperation.Replace);

            case StencilOperation.Zero:
                return(SharpDX.Direct3D11.StencilOperation.Zero);

            default:
                throw new NotImplementedException("Invalid stencil operation!");
            }
        }
Exemplo n.º 16
0
        static private SharpDX.Direct3D11.StencilOperation GetStencilOp(StencilOperation op)
        {
            switch (op)
            {
                case StencilOperation.Decrement:
                    return SharpDX.Direct3D11.StencilOperation.Decrement;

                case StencilOperation.DecrementSaturation:
                    return SharpDX.Direct3D11.StencilOperation.DecrementAndClamp;

                case StencilOperation.Increment:
                    return SharpDX.Direct3D11.StencilOperation.Increment;

                case StencilOperation.IncrementSaturation:
                    return SharpDX.Direct3D11.StencilOperation.IncrementAndClamp;

                case StencilOperation.Invert:
                    return SharpDX.Direct3D11.StencilOperation.Invert;

                case StencilOperation.Keep:
                    return SharpDX.Direct3D11.StencilOperation.Keep;

                case StencilOperation.Replace:
                    return SharpDX.Direct3D11.StencilOperation.Replace;

                case StencilOperation.Zero:
                    return SharpDX.Direct3D11.StencilOperation.Zero;

                default:
                    throw new ArgumentException("Invalid stencil operation!");
            }
        }
        /// <summary>
        /// Gets the OpenGL enum value that corresponds to the specified StencilOperation value.
        /// </summary>
        /// <param name="op">The StencilOperation value to convert.</param>
        /// <returns>The converted value.</returns>
        private static UInt32 GetStencilOpGL(StencilOperation op)
        {
            switch (op)
            {
            case StencilOperation.Decrement:
                return(gl.GL_DECR_WRAP);

            case StencilOperation.DecrementSaturation:
                return(gl.GL_DECR);

            case StencilOperation.Increment:
                return(gl.GL_INCR_WRAP);

            case StencilOperation.IncrementSaturation:
                return(gl.GL_INCR);

            case StencilOperation.Invert:
                return(gl.GL_INVERT);

            case StencilOperation.Keep:
                return(gl.GL_KEEP);

            case StencilOperation.Replace:
                return(gl.GL_REPLACE);

            case StencilOperation.Zero:
                return(gl.GL_ZERO);
            }
            throw new NotSupportedException();
        }
Exemplo n.º 18
0
        internal static SharpDX.Direct3D11.StencilOperation ToD3D11StencilOperation(StencilOperation op)
        {
            switch (op)
            {
            case StencilOperation.Keep:
                return(SharpDX.Direct3D11.StencilOperation.Keep);

            case StencilOperation.Zero:
                return(SharpDX.Direct3D11.StencilOperation.Zero);

            case StencilOperation.Replace:
                return(SharpDX.Direct3D11.StencilOperation.Replace);

            case StencilOperation.IncrementAndClamp:
                return(SharpDX.Direct3D11.StencilOperation.IncrementAndClamp);

            case StencilOperation.DecrementAndClamp:
                return(SharpDX.Direct3D11.StencilOperation.DecrementAndClamp);

            case StencilOperation.Invert:
                return(SharpDX.Direct3D11.StencilOperation.Invert);

            case StencilOperation.IncrementAndWrap:
                return(SharpDX.Direct3D11.StencilOperation.Increment);

            case StencilOperation.DecrementAndWrap:
                return(SharpDX.Direct3D11.StencilOperation.Decrement);

            default:
                throw Illegal.Value <StencilOperation>();
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DepthStencilDescriptor"/> struct.
        /// </summary>
        /// <param name="isDepthWriteEnabled">A bool value that indicates whether depth values can be written to the depth attachment.</param>
        /// <param name="depthCompareFunction">The <see cref="CompareFunction"/> that is performed between a fragment’s depth value and the depth value in the attachment, which determines whether to discard the fragment.</param>
        /// <param name="frontFaceStencilFailOperation"></param>
        /// <param name="frontFaceStencilDepthFailOperation"></param>
        /// <param name="frontFaceStencilPassOperation"></param>
        /// <param name="frontFaceStencilCompareFunction"></param>
        /// <param name="backFaceStencilFailOperation"></param>
        /// <param name="backFaceStencilDepthFailOperation"></param>
        /// <param name="backFaceStencilPassOperation"></param>
        /// <param name="backFaceStencilCompareFunction"></param>
        /// <param name="stencilReadMask">A bitmask that determines from which bits that stencil comparison tests can read.</param>
        /// <param name="stencilWriteMask">A bitmask that determines to which bits that stencil operations can write.</param>
        public DepthStencilDescriptor(
            bool isDepthWriteEnabled,
            CompareFunction depthCompareFunction,
            StencilOperation frontFaceStencilFailOperation,
            StencilOperation frontFaceStencilDepthFailOperation,
            StencilOperation frontFaceStencilPassOperation,
            CompareFunction frontFaceStencilCompareFunction,
            StencilOperation backFaceStencilFailOperation,
            StencilOperation backFaceStencilDepthFailOperation,
            StencilOperation backFaceStencilPassOperation,
            CompareFunction backFaceStencilCompareFunction,
            byte stencilReadMask  = DefaultStencilReadMask,
            byte stencilWriteMask = DefaultStencilWriteMask)
        {
            IsDepthWriteEnabled  = isDepthWriteEnabled;
            DepthCompareFunction = depthCompareFunction;

            // Front
            FrontFaceStencil = new DepthStencilOperationDescriptor(
                frontFaceStencilFailOperation, frontFaceStencilDepthFailOperation, frontFaceStencilPassOperation, frontFaceStencilCompareFunction);

            // Back
            BackFaceStencil = new DepthStencilOperationDescriptor(
                backFaceStencilFailOperation, backFaceStencilDepthFailOperation, backFaceStencilPassOperation, backFaceStencilCompareFunction);

            StencilReadMask  = stencilReadMask;
            StencilWriteMask = stencilWriteMask;
        }
Exemplo n.º 20
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Methods
        //---------------------------------------------------------------
        /// <summary>
        /// Saves the current state into the current <see cref="IRenderState"/> object.
        /// </summary>
        public void Save()
        {
            this.Enable      = Device.Instance.RenderStates.TwoSidedStencilMode;
            this.Function    = Device.Instance.RenderStates.CounterClockwiseStencilFunction;
            this.Fail        = Device.Instance.RenderStates.CounterClockwiseStencilFail;
            this.Pass        = Device.Instance.RenderStates.CounterClockwiseStencilPass;
            this.ZBufferFail = Device.Instance.RenderStates.CounterClockwiseStencilZBufferFail;
        }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new instance of a <see cref="StencilState"/>.
 /// </summary>
 /// <param name="device">The device from which to fill this RenderState.</param>
 public StencilState(Device device)
 {
     this.Enable      = device.RenderStates.StencilTest;
     this.Function    = device.RenderStates.StencilFunction;
     this.Fail        = device.RenderStates.StencilFail;
     this.Pass        = device.RenderStates.StencilPass;
     this.ZBufferFail = device.RenderStates.StencilZBufferFail;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Applies the <see cref="StencilState"/> defined by the passed parameters.
 /// </summary>
 /// <remarks>
 /// Use this static method if you don't want to allocate a renderState object.
 /// </remarks>
 /// <param name="enable">True to turn on stencil testing.</param>
 /// <param name="function">Stencil compare function.</param>
 /// <param name="pass">The operation to perform if the stencil test passes.</param>
 /// <param name="fail">The operation to perform if the stencil test fails.</param>
 /// <param name="zBufferFail">The operation to perform if the stencil test passes but the zBuffer Test fails.</param>
 public static void Apply(bool enable, Compare function, StencilOperation pass, StencilOperation fail, StencilOperation zBufferFail)
 {
     Device.Instance.RenderStates.StencilFunction    = function;
     Device.Instance.RenderStates.StencilTest        = enable;
     Device.Instance.RenderStates.StencilFail        = fail;
     Device.Instance.RenderStates.StencilPass        = pass;
     Device.Instance.RenderStates.StencilZBufferFail = zBufferFail;
 }
Exemplo n.º 23
0
 public void setStencilPassOp(StencilOperation value)
 {
     OgrePINVOKE.CompositionPass_setStencilPassOp(swigCPtr, (int)value);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 24
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Methods
        //---------------------------------------------------------------
        /// <summary>
        /// Saves the current state into the current <see cref="IRenderState"/> object.
        /// </summary>
        public void Save()
        {
            this.Enable      = Device.Instance.RenderStates.StencilTest;
            this.Function    = Device.Instance.RenderStates.StencilFunction;
            this.Fail        = Device.Instance.RenderStates.StencilFail;
            this.Pass        = Device.Instance.RenderStates.StencilPass;
            this.ZBufferFail = Device.Instance.RenderStates.StencilZBufferFail;
        }
Exemplo n.º 25
0
 public StencilMode(StencilOperation frontOperation, StencilFunction frontCompare, StencilOperation backOperation, StencilFunction backCompare)
 {
     IsEnabled      = true;
     CompareFront   = frontCompare;
     CompareBack    = backCompare;
     OperationFront = frontOperation;
     OperationBack  = backOperation;
 }
Exemplo n.º 26
0
 /// <summary>
 /// Creates a new instance of a <see cref="StencilState"/>.
 /// </summary>
 /// <param name="device">The device from which to fill this RenderState.</param>
 public CCWStencilState(Device device)
 {
     this.Enable      = device.RenderStates.TwoSidedStencilMode;
     this.Function    = device.RenderStates.CounterClockwiseStencilFunction;
     this.Fail        = device.RenderStates.CounterClockwiseStencilFail;
     this.Pass        = device.RenderStates.CounterClockwiseStencilPass;
     this.ZBufferFail = device.RenderStates.CounterClockwiseStencilZBufferFail;
 }
Exemplo n.º 27
0
 /// <summary>
 /// Applies the <see cref="StencilState"/> defined by the passed parameters.
 /// </summary>
 /// <remarks>
 /// Use this static method if you don't want to allocate a renderState object.
 /// </remarks>
 /// <param name="enable">True to turn on two sided stencil testing.</param>
 /// <param name="function">Stencil compare function.</param>
 /// <param name="pass">The operation to perform if the stencil test passes.</param>
 /// <param name="fail">The operation to perform if the stencil test fails.</param>
 /// <param name="zBufferFail">The operation to perform if the stencil test passes but the zBuffer Test fails.</param>
 public static void Apply(bool enable, Compare function, StencilOperation pass, StencilOperation fail, StencilOperation zBufferFail)
 {
     Device.Instance.RenderStates.CounterClockwiseStencilFunction    = function;
     Device.Instance.RenderStates.TwoSidedStencilMode                = enable;
     Device.Instance.RenderStates.CounterClockwiseStencilFail        = fail;
     Device.Instance.RenderStates.CounterClockwiseStencilPass        = pass;
     Device.Instance.RenderStates.CounterClockwiseStencilZBufferFail = zBufferFail;
 }
Exemplo n.º 28
0
 public StencilMode(StencilOperation operation, StencilFunction compare)
 {
     IsEnabled      = true;
     CompareFront   = compare;
     CompareBack    = compare;
     OperationFront = operation;
     OperationBack  = operation;
 }
Exemplo n.º 29
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Initialisation
        //---------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of a <see cref="StencilState"/>.
        /// </summary>
        /// <param name="enable">True to turn on stencil testing.</param>
        /// <param name="function">The compare function to use for the stencil test.</param>
        /// <param name="fail">The stencil operation to perform when the stencil test fails.</param>
        /// <param name="pass">The stencil operation to perform when the stencil test passes.</param>
        /// <param name="zBufferFail">The stencil operation to perform when the stencil test passes but the zBuffer test fails.</param>
        public StencilState(bool enable, Compare function, StencilOperation pass, StencilOperation fail, StencilOperation zBufferFail)
        {
            Enable      = enable;
            Function    = function;
            Fail        = fail;
            Pass        = pass;
            ZBufferFail = zBufferFail;
        }
Exemplo n.º 30
0
        internal static StencilOp Convert(StencilOperation stencilOperation)
        {
            if (!stencilOperations.ContainsKey(stencilOperation))
            {
                throw new NotSupportedException("indexFormat is not supported");
            }

            return(stencilOperations[stencilOperation]);
        }
Exemplo n.º 31
0
        public StencilOperation getStencilPassOp()
        {
            StencilOperation ret = (StencilOperation)OgrePINVOKE.CompositionPass_getStencilPassOp(swigCPtr);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DepthStencilOperationDescriptor"/> struct.
 /// </summary>
 /// <param name="stencilFailOperation">A <see cref="StencilOperation"/> value that identifies the stencil operation to perform when stencil testing fails.</param>
 /// <param name="stencilDepthFailOperation">A <see cref="StencilOperation"/> value that identifies the stencil operation to perform when stencil testing passes and depth testing fails.</param>
 /// <param name="stencilPassOperation">A <see cref="StencilOperation"/> value that identifies the stencil operation to perform when stencil testing and depth testing both pass.</param>
 /// <param name="stencilCompareFunction">A <see cref="CompareFunction"/> value that identifies the function that compares stencil data against existing stencil data.</param>
 public DepthStencilOperationDescriptor(
     StencilOperation stencilFailOperation,
     StencilOperation stencilDepthFailOperation,
     StencilOperation stencilPassOperation,
     CompareFunction stencilCompareFunction)
 {
     StencilFailOperation      = stencilFailOperation;
     StencilDepthFailOperation = stencilDepthFailOperation;
     StencilPassOperation      = stencilPassOperation;
     StencilCompareFunction    = stencilCompareFunction;
 }
Exemplo n.º 33
0
        private DepthStencilState(DepthStencilState cloneSource)
	    {
	        Name = cloneSource.Name;
            _depthBufferEnable = cloneSource._depthBufferEnable;
            _depthBufferWriteEnable = cloneSource._depthBufferWriteEnable;
            _counterClockwiseStencilDepthBufferFail = cloneSource._counterClockwiseStencilDepthBufferFail;
            _counterClockwiseStencilFail = cloneSource._counterClockwiseStencilFail;
            _counterClockwiseStencilFunction = cloneSource._counterClockwiseStencilFunction;
            _counterClockwiseStencilPass = cloneSource._counterClockwiseStencilPass;
            _depthBufferFunction = cloneSource._depthBufferFunction;
            _referenceStencil = cloneSource._referenceStencil;
            _stencilDepthBufferFail = cloneSource._stencilDepthBufferFail;
            _stencilEnable = cloneSource._stencilEnable;
            _stencilFail = cloneSource._stencilFail;
            _stencilFunction = cloneSource._stencilFunction;
            _stencilMask = cloneSource._stencilMask;
            _stencilPass = cloneSource._stencilPass;
            _stencilWriteMask = cloneSource._stencilWriteMask;
            _twoSidedStencilMode = cloneSource._twoSidedStencilMode;
	    }
Exemplo n.º 34
0
        public static StencilOp To(StencilOperation operation)
        {
            switch (operation)
            {
                case StencilOperation.Zero:
                    return StencilOp.Zero;
                case StencilOperation.Invert:
                    return StencilOp.Invert;
                case StencilOperation.Keep:
                    return StencilOp.Keep;
                case StencilOperation.Replace:
                    return StencilOp.Replace;
                case StencilOperation.Increment:
                    return StencilOp.Incr;
                case StencilOperation.Decrement:
                    return StencilOp.Decr;
                case StencilOperation.IncrementWrap:
                    return StencilOp.IncrWrap;
                case StencilOperation.DecrementWrap:
                    return StencilOp.DecrWrap;
            }

            throw new ArgumentException("operation");
        }
Exemplo n.º 35
0
 /// <summary>
 /// Gets the OpenGL enum value that corresponds to the specified StencilOperation value.
 /// </summary>
 /// <param name="op">The StencilOperation value to convert.</param>
 /// <returns>The converted value.</returns>
 private static UInt32 GetStencilOpGL(StencilOperation op)
 {
     switch (op)
     {
         case StencilOperation.Decrement:
             return gl.GL_DECR_WRAP;
         case StencilOperation.DecrementSaturation:
             return gl.GL_DECR;
         case StencilOperation.Increment:
             return gl.GL_INCR_WRAP;
         case StencilOperation.IncrementSaturation:
             return gl.GL_INCR;
         case StencilOperation.Invert:
             return gl.GL_INVERT;
         case StencilOperation.Keep:
             return gl.GL_KEEP;
         case StencilOperation.Replace:
             return gl.GL_REPLACE;
         case StencilOperation.Zero:
             return gl.GL_ZERO;
     }
     throw new NotSupportedException();
 }
Exemplo n.º 36
0
		public override void SetStencilBufferParams( CompareFunction func, 
            int refValue, int mask, StencilOperation stencilFailOp, 
            StencilOperation depthFailOp, StencilOperation passOp, 
            bool twoSidedOperation )
		{
            if (twoSidedOperation)
            {
                if ( !currentCapabilities.HasCapability( Graphics.Capabilities.TwoSidedStencil ) )
                {
                    throw new AxiomException( "2-sided stencils are not supported on this hardware!" );
                }

                // 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.
                var flip = ( invertVertexWinding ^ activeRenderTarget.RequiresTextureFlipping );
                if ( GLEW_VERSION_2_0 ) // New GL2 commands
                {
                    // Back
                    Gl.glStencilMaskSeparate( Gl.GL_BACK, mask );
                    Gl.glStencilFuncSeparate( Gl.GL_BACK, GLHelper.ConvertEnum( func ), refValue, mask );
                    Gl.glStencilOpSeparate( Gl.GL_BACK,
                                            GLHelper.ConvertEnum( stencilFailOp, !flip ),
                                            GLHelper.ConvertEnum( depthFailOp, !flip ),
                                            GLHelper.ConvertEnum( passOp, !flip ) );
                    // Front
                    Gl.glStencilMaskSeparate( Gl.GL_FRONT, mask );
                    Gl.glStencilFuncSeparate( Gl.GL_FRONT, GLHelper.ConvertEnum( func ), refValue, mask );
                    Gl.glStencilOpSeparate( Gl.GL_FRONT,
                                            GLHelper.ConvertEnum( stencilFailOp, flip ),
                                            GLHelper.ConvertEnum( depthFailOp, flip ),
                                            GLHelper.ConvertEnum( passOp, flip ) );

                    Gl.glActiveStencilFaceEXT( Gl.GL_FRONT );
                }
                else // EXT_stencil_two_side
                {
                    Gl.glEnable( Gl.GL_STENCIL_TEST_TWO_SIDE_EXT );
                    // Back
                    Gl.glActiveStencilFaceEXT( Gl.GL_BACK );
                    Gl.glStencilMask( mask );
                    Gl.glStencilFunc( GLHelper.ConvertEnum( func ), refValue, mask );
                    Gl.glStencilOp(
                        GLHelper.ConvertEnum( stencilFailOp, !flip ),
                        GLHelper.ConvertEnum( depthFailOp, !flip ),
                        GLHelper.ConvertEnum( passOp, !flip ) );
                    // Front
                    Gl.glActiveStencilFaceEXT( Gl.GL_FRONT );
                    Gl.glStencilMask( mask );
                    Gl.glStencilFunc( GLHelper.ConvertEnum( func ), refValue, mask );
                    Gl.glStencilOp(
                        GLHelper.ConvertEnum( stencilFailOp, flip ),
                        GLHelper.ConvertEnum( depthFailOp, flip ),
                        GLHelper.ConvertEnum( passOp, flip ) );
                }
            }
            else
            {
                Gl.glDisable(Gl.GL_STENCIL_TEST_TWO_SIDE_EXT);
                var flip = false;
                Gl.glStencilMask(mask);
                Gl.glStencilFunc(GLHelper.ConvertEnum(func), refValue, mask);
                Gl.glStencilOp(
                    GLHelper.ConvertEnum(stencilFailOp, flip),
                    GLHelper.ConvertEnum(depthFailOp, flip),
                    GLHelper.ConvertEnum(passOp, flip));
            }
		}
Exemplo n.º 37
0
 public static extern void glStencilOp(StencilOperation fail, StencilOperation zfail, StencilOperation zpass);
        /// <summary>
        ///		This method allows you to set all the stencil buffer parameters in one call.
        /// </summary>
        /// <remarks>
        ///		<para>
        ///		The stencil buffer is used to mask out pixels in the render target, allowing
        ///		you to do effects like mirrors, cut-outs, stencil shadows and more. Each of
        ///		your batches of rendering is likely to ignore the stencil buffer, 
        ///		update it with new values, or apply it to mask the output of the render.
        ///		The stencil test is:<PRE>
        ///		(Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)</PRE>
        ///		The result of this will cause one of 3 actions depending on whether the test fails,
        ///		succeeds but with the depth buffer check still failing, or succeeds with the
        ///		depth buffer check passing too.</para>
        ///		<para>
        ///		Unlike other render states, stencilling is left for the application to turn
        ///		on and off when it requires. This is because you are likely to want to change
        ///		parameters between batches of arbitrary objects and control the ordering yourself.
        ///		In order to batch things this way, you'll want to use OGRE's separate render queue
        ///		groups (see RenderQueue) and register a RenderQueueListener to get notifications
        ///		between batches.</para>
        ///		<para>
        ///		There are individual state change methods for each of the parameters set using 
        ///		this method. 
        ///		Note that the default values in this method represent the defaults at system 
        ///		start up too.</para>
        /// </remarks>
        /// <param name="function">The comparison function applied.</param>
        /// <param name="refValue">The reference value used in the comparison.</param>
        /// <param name="mask">
        ///		The bitmask applied to both the stencil value and the reference value 
        ///		before comparison.
        /// </param>
        /// <param name="stencilFailOp">The action to perform when the stencil check fails.</param>
        /// <param name="depthFailOp">
        ///		The action to perform when the stencil check passes, but the depth buffer check still fails.
        /// </param>
        /// <param name="passOp">The action to take when both the stencil and depth check pass.</param>
        /// <param name="twoSidedOperation">
        ///		If set to true, then if you render both back and front faces 
        ///		(you'll have to turn off culling) then these parameters will apply for front faces, 
        ///		and the inverse of them will happen for back faces (keep remains the same).
        /// </param>
        public abstract void SetStencilBufferParams(CompareFunction function, int refValue, int mask,
			StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp, bool twoSidedOperation);
Exemplo n.º 39
0
		public GLenum ConvertStencilOp( StencilOperation op, bool invert )
		{
			switch ( op )
			{
				case StencilOperation.Keep:
					return GLenum.Keep;
				case StencilOperation.Zero:
					return GLenum.Zero;
				case StencilOperation.Replace:
					return GLenum.Replace;
				case StencilOperation.Increment:
					return invert ? GLenum.Decr : GLenum.Incr;
				case StencilOperation.Decrement:
					return invert ? GLenum.Incr : GLenum.Decr;
				case StencilOperation.IncrementWrap:
					return invert ? GLenum.DecrWrap : GLenum.IncrWrap;
				case StencilOperation.DecrementWrap:
					return invert ? GLenum.IncrWrap : GLenum.DecrWrap;
				case StencilOperation.Invert:
					return GLenum.Invert;
				default:
					return GLenum.Invert; // to keep compiler happy
			}
		}
Exemplo n.º 40
0
 public static void StencilOp(StencilOperation sfail, StencilOperation spass)
 {
     GDTransport.cmd32((12 << 24) | ((byte)sfail << 3) | (byte)spass);
 }
Exemplo n.º 41
0
		public override void SetStencilBufferParams( CompareFunction function, int refValue, int mask, StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp, bool twoSidedOperation )
		{
			bool flip;
			this.stencilMask = (uint) mask;

			if ( twoSidedOperation )
			{
				if ( !currentCapabilities.HasCapability( Graphics.Capabilities.TwoSidedStencil ) )
				{
					throw new AxiomException( "2-sided stencils are not supported" );
				}
				// 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 );
				//Back
				GL.StencilMaskSeparate( GLenum.Back, mask );
				GLES2Config.GlCheckError( this );
				GL.StencilFuncSeparate( GLenum.Back, this.ConvertCompareFunction( function ), refValue, mask );
				GLES2Config.GlCheckError( this );
				GL.StencilOpSeparate( GLenum.Back, this.ConvertStencilOp( stencilFailOp, !flip ), this.ConvertStencilOp( depthFailOp, !flip ), this.ConvertStencilOp( passOp, !flip ) );
				GLES2Config.GlCheckError( this );

				//Front
				GL.StencilMaskSeparate( GLenum.Front, mask );
				GLES2Config.GlCheckError( this );
				GL.StencilFuncSeparate( GLenum.Front, this.ConvertCompareFunction( function ), refValue, mask );
				GLES2Config.GlCheckError( this );
				GL.StencilOpSeparate( GLenum.Front, this.ConvertStencilOp( stencilFailOp, flip ), this.ConvertStencilOp( depthFailOp, flip ), this.ConvertStencilOp( passOp, flip ) );
				GLES2Config.GlCheckError( this );
			}
			else
			{
				flip = ( faceCount == 0 ) ? false : true;
				GL.StencilMask( mask );
				GLES2Config.GlCheckError( this );
				GL.StencilFunc( this.ConvertCompareFunction( function ), refValue, mask );
				GLES2Config.GlCheckError( this );
				GL.StencilOp( this.ConvertStencilOp( stencilFailOp, flip ), this.ConvertStencilOp( depthFailOp, flip ), this.ConvertStencilOp( passOp, flip ) );
				GLES2Config.GlCheckError( this );
			}
		}
Exemplo n.º 42
0
		public GLenum ConvertStencilOp( StencilOperation op )
		{
			return this.ConvertStencilOp( op, false );
		}
Exemplo n.º 43
0
 private static StencilOp GetStencilOp(StencilOperation operation)
 {
     switch (operation)
     {
         case StencilOperation.Keep:
             return StencilOp.Keep;
         case StencilOperation.Decrement:
             return StencilOp.DecrWrap;
         case StencilOperation.DecrementSaturation:
             return StencilOp.Decr;
         case StencilOperation.IncrementSaturation:
             return StencilOp.Incr;
         case StencilOperation.Increment:
             return StencilOp.IncrWrap;
         case StencilOperation.Invert:
             return StencilOp.Invert;
         case StencilOperation.Replace:
             return StencilOp.Replace;
         case StencilOperation.Zero:
             return StencilOp.Zero;
         default:
             return StencilOp.Keep;
     }
 }
Exemplo n.º 44
0
		public RSStencilOperation( bool stencilCheck, CompareFunction func, int refValue, int mask,
		                           StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp,
		                           bool twoSidedOperation )
		{
			this.stencilCheck = stencilCheck;
			this.func = func;
			this.refValue = refValue;
			this.mask = mask;
			this.stencilFailOp = stencilFailOp;
			this.depthFailOp = depthFailOp;
			this.passOp = passOp;
			this.twoSidedOperation = twoSidedOperation;
		}
Exemplo n.º 45
0
 public static void StencilOp(StencilOperation fail, StencilOperation zfail, StencilOperation zpass)
 {
     Delegates.glStencilOp(fail, zfail, zpass);
 }
        public override void SetStencilBufferParams(CompareFunction function, int refValue, int mask, StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp, bool twoSidedOperation)
        {
            if (twoSidedOperation) {
                if(!caps.CheckCap(Capabilities.TwoSidedStencil)) {
                    throw new AxiomException("2-sided stencils are not supported on this hardware!");
                }

                Gl.glActiveStencilFaceEXT(Gl.GL_FRONT);
            }

            Gl.glStencilMask(mask);
            Gl.glStencilFunc(GLHelper.ConvertEnum(function), refValue, mask);
            Gl.glStencilOp(GLHelper.ConvertEnum(stencilFailOp), GLHelper.ConvertEnum(depthFailOp),
                GLHelper.ConvertEnum(passOp));

            if (twoSidedOperation) {
                // set everything again, inverted
                Gl.glActiveStencilFaceEXT(Gl.GL_BACK);
                Gl.glStencilMask(mask);
                Gl.glStencilFunc(GLHelper.ConvertEnum(function), refValue, mask);
                Gl.glStencilOp(
                    GLHelper.ConvertEnum(stencilFailOp, true),
                    GLHelper.ConvertEnum(depthFailOp, true),
                    GLHelper.ConvertEnum(passOp, true));

                // reset
                Gl.glActiveStencilFaceEXT(Gl.GL_FRONT);
                Gl.glEnable(Gl.GL_STENCIL_TEST_TWO_SIDE_EXT);
            }
            else {
                Gl.glDisable(Gl.GL_STENCIL_TEST_TWO_SIDE_EXT);
            }
        }
        public void SetStencilBufferParams(CompareFunction function, int refValue, int mask, 
			StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp)
        {
            SetStencilBufferParams(function, refValue, mask,
                stencilFailOp, depthFailOp, passOp, false);
        }
Exemplo n.º 48
0
 public static StencilOp StencilOp(StencilOperation bStencilOperation)
 {
     switch (bStencilOperation)
     {
         case StencilOperation.Keep: return OpenTK.Graphics.OpenGL.StencilOp.Keep;
         case StencilOperation.Zero: return OpenTK.Graphics.OpenGL.StencilOp.Zero;
         case StencilOperation.Replace: return OpenTK.Graphics.OpenGL.StencilOp.Replace;
         case StencilOperation.IncrementSaturate: return OpenTK.Graphics.OpenGL.StencilOp.Incr;
         case StencilOperation.DecrementSaturate: return OpenTK.Graphics.OpenGL.StencilOp.Decr;
         case StencilOperation.Invert: return OpenTK.Graphics.OpenGL.StencilOp.Invert;
         case StencilOperation.Increment: return OpenTK.Graphics.OpenGL.StencilOp.IncrWrap;
         case StencilOperation.Decrement: return OpenTK.Graphics.OpenGL.StencilOp.DecrWrap;
         default: throw new ArgumentOutOfRangeException("bStencilOperation");
     }
 }
 public static SharpVulkan.StencilOperation ConvertStencilOperation(StencilOperation operation)
 {
     switch (operation)
     {
         case StencilOperation.Decrement:
             return SharpVulkan.StencilOperation.DecrementAndWrap;
         case StencilOperation.DecrementSaturation:
             return SharpVulkan.StencilOperation.DecrementAndClamp;
         case StencilOperation.Increment:
             return SharpVulkan.StencilOperation.IncrementAndWrap;
         case StencilOperation.IncrementSaturation:
             return SharpVulkan.StencilOperation.IncrementAndClamp;
         case StencilOperation.Invert:
             return SharpVulkan.StencilOperation.Invert;
         case StencilOperation.Keep:
             return SharpVulkan.StencilOperation.Keep;
         case StencilOperation.Replace:
             return SharpVulkan.StencilOperation.Replace;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Exemplo n.º 50
0
 public static int ConvertEnum(StencilOperation op)
 {
     return ConvertEnum(op, false);
 }
Exemplo n.º 51
0
		public override void SetStencilBufferParams( CompareFunction function, int refValue, int mask, StencilOperation stencilFailOp, StencilOperation depthFailOp, StencilOperation passOp, bool twoSidedOperation )
		{
			throw new NotImplementedException();
		}
Exemplo n.º 52
0
		public void SetDepthStencilState(DepthStencilState depthStencilState)
		{
			if (depthStencilState.DepthBufferEnable != zEnable)
			{
				zEnable = depthStencilState.DepthBufferEnable;
				ToggleGLState(GLenum.GL_DEPTH_TEST, zEnable);
			}

			if (zEnable)
			{
				if (depthStencilState.DepthBufferWriteEnable != zWriteEnable)
				{
					zWriteEnable = depthStencilState.DepthBufferWriteEnable;
					glDepthMask(zWriteEnable);
				}

				if (depthStencilState.DepthBufferFunction != depthFunc)
				{
					depthFunc = depthStencilState.DepthBufferFunction;
					glDepthFunc(XNAToGL.CompareFunc[(int) depthFunc]);
				}
			}

			if (depthStencilState.StencilEnable != stencilEnable)
			{
				stencilEnable = depthStencilState.StencilEnable;
				ToggleGLState(GLenum.GL_STENCIL_TEST, stencilEnable);
			}

			if (stencilEnable)
			{
				if (depthStencilState.StencilWriteMask != stencilWriteMask)
				{
					stencilWriteMask = depthStencilState.StencilWriteMask;
					glStencilMask(stencilWriteMask);
				}

				// TODO: Can we split StencilFunc/StencilOp up nicely? -flibit
				if (	depthStencilState.TwoSidedStencilMode != separateStencilEnable ||
					depthStencilState.ReferenceStencil != stencilRef ||
					depthStencilState.StencilMask != stencilMask ||
					depthStencilState.StencilFunction != stencilFunc ||
					depthStencilState.CounterClockwiseStencilFunction != ccwStencilFunc ||
					depthStencilState.StencilFail != stencilFail ||
					depthStencilState.StencilDepthBufferFail != stencilZFail ||
					depthStencilState.StencilPass != stencilPass ||
					depthStencilState.CounterClockwiseStencilFail != ccwStencilFail ||
					depthStencilState.CounterClockwiseStencilDepthBufferFail != ccwStencilZFail ||
					depthStencilState.CounterClockwiseStencilPass != ccwStencilPass	)
				{
					separateStencilEnable = depthStencilState.TwoSidedStencilMode;
					stencilRef = depthStencilState.ReferenceStencil;
					stencilMask = depthStencilState.StencilMask;
					stencilFunc = depthStencilState.StencilFunction;
					stencilFail = depthStencilState.StencilFail;
					stencilZFail = depthStencilState.StencilDepthBufferFail;
					stencilPass = depthStencilState.StencilPass;
					if (separateStencilEnable)
					{
						ccwStencilFunc = depthStencilState.CounterClockwiseStencilFunction;
						ccwStencilFail = depthStencilState.CounterClockwiseStencilFail;
						ccwStencilZFail = depthStencilState.CounterClockwiseStencilDepthBufferFail;
						ccwStencilPass = depthStencilState.CounterClockwiseStencilPass;
						glStencilFuncSeparate(
							GLenum.GL_FRONT,
							XNAToGL.CompareFunc[(int) stencilFunc],
							stencilRef,
							stencilMask
						);
						glStencilFuncSeparate(
							GLenum.GL_BACK,
							XNAToGL.CompareFunc[(int) ccwStencilFunc],
							stencilRef,
							stencilMask
						);
						glStencilOpSeparate(
							GLenum.GL_FRONT,
							XNAToGL.GLStencilOp[(int) stencilFail],
							XNAToGL.GLStencilOp[(int) stencilZFail],
							XNAToGL.GLStencilOp[(int) stencilPass]
						);
						glStencilOpSeparate(
							GLenum.GL_BACK,
							XNAToGL.GLStencilOp[(int) ccwStencilFail],
							XNAToGL.GLStencilOp[(int) ccwStencilZFail],
							XNAToGL.GLStencilOp[(int) ccwStencilPass]
						);
					}
					else
					{
						glStencilFunc(
							XNAToGL.CompareFunc[(int) stencilFunc],
							stencilRef,
							stencilMask
						);
						glStencilOp(
							XNAToGL.GLStencilOp[(int) stencilFail],
							XNAToGL.GLStencilOp[(int) stencilZFail],
							XNAToGL.GLStencilOp[(int) stencilPass]
						);
					}
				}
			}
		}
Exemplo n.º 53
0
        /// <summary>
        ///		Find the GL int value for the StencilOperation enum.
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public static int ConvertEnum(StencilOperation op, bool invert)
        {
            switch(op) {
                case StencilOperation.Keep:
                    return Gl.GL_KEEP;

                case StencilOperation.Zero:
                    return Gl.GL_ZERO;

                case StencilOperation.Replace:
                    return Gl.GL_REPLACE;

                case StencilOperation.Increment:
                    return invert ? Gl.GL_DECR : Gl.GL_INCR;

                case StencilOperation.Decrement:
                    return invert ? Gl.GL_INCR : Gl.GL_DECR;

                case StencilOperation.IncrementWrap:
                    return invert ? Gl.GL_DECR_WRAP_EXT : Gl.GL_INCR_WRAP_EXT;

                case StencilOperation.DecrementWrap:
                    return invert ? Gl.GL_INCR_WRAP_EXT : Gl.GL_DECR_WRAP_EXT;

                case StencilOperation.Invert:
                    return Gl.GL_INVERT;
            }

            // make the compiler happy
            return Gl.GL_KEEP;
        }
 public CompositionPass(CompositionTargetPass parent)
 {
     this.parent = parent;
     type = CompositorPassType.RenderQuad;
     identifier = 0;
     firstRenderQueue = RenderQueueGroupID.SkiesEarly;
     lastRenderQueue = RenderQueueGroupID.SkiesLate;
     clearBuffers = FrameBuffer.Color | FrameBuffer.Depth;
     clearColor = new ColorEx(0f, 0f, 0f, 0f);
     clearDepth = 1.0f;
     clearStencil = 0;
     stencilCheck = false;
     stencilFunc = CompareFunction.AlwaysPass;
     stencilRefValue = 0;
     stencilMask = (int)0x7FFFFFFF;
     stencilFailOp = StencilOperation.Keep;
     stencilDepthFailOp = StencilOperation.Keep;
     stencilPassOp = StencilOperation.Keep;
     stencilTwoSidedOperation = false;
 }
Exemplo n.º 55
0
		private All ConvertStencilOP( StencilOperation op, bool invert )
		{
			switch ( op )
			{
				case StencilOperation.Keep:
					return All.Keep;
				case StencilOperation.Zero:
					return All.Zero;
				case StencilOperation.Replace:
					return All.Replace;
				case StencilOperation.IncrementWrap:
				case StencilOperation.Increment:
					return invert == true ? All.Decr : All.Incr;
				case StencilOperation.DecrementWrap:
				case StencilOperation.Decrement:
					return invert == true ? All.Incr : All.Decr;
				case StencilOperation.Invert:
					return All.Invert;
				default:
					// to keep compiler happy
					return All.Keep;
			}

		}
Exemplo n.º 56
0
		public CompositionPass( CompositionTargetPass parent )
		{
			this.parent = parent;
			type = CompositorPassType.RenderQuad;
			identifier = 0;
			firstRenderQueue = RenderQueueGroupID.Background;
			lastRenderQueue = RenderQueueGroupID.SkiesLate;
			materialSchemeName = string.Empty;
			clearBuffers = FrameBufferType.Color | FrameBufferType.Depth;
			clearColor = new ColorEx( 0f, 0f, 0f, 0f );
			clearDepth = 1.0f;
			clearStencil = 0;
			stencilCheck = false;
			stencilFunc = CompareFunction.AlwaysPass;
			stencilRefValue = 0;
			stencilMask = 0x7FFFFFFF;
			stencilFailOp = StencilOperation.Keep;
			stencilDepthFailOp = StencilOperation.Keep;
			stencilPassOp = StencilOperation.Keep;
			stencilTwoSidedOperation = false;
			quadCornerModified = false;
			quadLeft = -1;
			quadTop = 1;
			quadRight = 1;
			quadBottom = -1;
			quadFarCorners = false;
			quadFarCornersViewSpace = false;
		}
Exemplo n.º 57
0
        void GetFaceForDepthStencil(XmlNode node, out Comparison comparison, out StencilOperation failDepthOp,
            out StencilOperation failOp, out StencilOperation passOp)
        {
            Comparison cmp = Comparison.LessEqual;
            StencilOperation faildepth = StencilOperation.Keep;
            StencilOperation fail = StencilOperation.Keep;
            StencilOperation pass = StencilOperation.Replace;

            foreach (XmlNode parameter in node.ChildNodes)
            {
                switch (parameter.Name.ToLower())
                {
                    case "comparison":
                        cmp = GetComparison(parameter.InnerText);
                        break;
                    case "depthfailop":
                        faildepth = GetStencilOperation(parameter.InnerText);
                        break;
                    case "failop":
                        fail = GetStencilOperation(parameter.InnerText);
                        break;
                    case "passop":
                        pass = GetStencilOperation(parameter.InnerText);
                        break;
                    default:
                        throw new Exception("Unknow parameter for face operation on depthstencil");
                }
            }

            comparison = cmp;
            failDepthOp = faildepth;
            failOp = fail;
            passOp = pass;
        }