Example #1
0
 public DeviceRenderState(AlphaBlendState alphaBlendState, AlphaTestState alphaTestState, DepthColourCullState depthState, StencilTestState stencilState)
 {
     StencilTest     = stencilState;
     AlphaBlend      = alphaBlendState;
     AlphaTest       = alphaTestState;
     DepthColourCull = depthState;
 }
Example #2
0
        internal void ResetState(ref DepthColourCullState current, DeviceContext device, bool reverseCull)
        {
            device.SetRenderState(RenderState.ZEnable, DepthTestEnabled);
            device.SetRenderState(RenderState.ZWriteEnable, DepthWriteEnabled);
            device.SetRenderState(RenderState.ZFunc, DepthTestFunction);
            device.SetRenderState(RenderState.CullMode, GetCullMode(reverseCull));
            device.SetRenderState(RenderState.FillMode, FillMode);

            current._mode = _mode;
        }
        internal void ResetState(ref DepthColourCullState current, DeviceContext device, bool reverseCull)
        {
            device.SetRenderState(RenderState.ZEnable, DepthTestEnabled);
            device.SetRenderState(RenderState.ZWriteEnable, DepthWriteEnabled);
            device.SetRenderState(RenderState.ZFunc, DepthTestFunction);
            device.SetRenderState(RenderState.CullMode, GetCullMode(reverseCull));
            device.SetRenderState(RenderState.FillMode, FillMode);

            current._mode = _mode;
        }
        internal bool ApplyState(ref DepthColourCullState current, DeviceContext device, bool reverseCull)
        {
            bool changed = false;

            // bits 6 to 14 are used.. so ignore bits 1-5
            if ((current._mode & (~63)) != (_mode & (~63)))
            {
            #if DEBUG
                changed = true;
            #endif
                Cull cull = CullMode;
                if (cull != current.CullMode)
                {
                    device.SetRenderState(RenderState.CullMode, GetCullMode(reverseCull));
                    current.CullMode = cull;
                }

                FillMode fill = FillMode;
                if (fill != current.FillMode)
                {
                    device.SetRenderState(RenderState.FillMode, FillMode);
                    current.FillMode = fill;
                }
            }

            if (DepthTestEnabled)
            {
                if (!current.DepthTestEnabled)
                {
            #if DEBUG
                    changed = true;
            #endif
                    device.SetRenderState(RenderState.ZEnable, true);
                }

                if (DepthWriteEnabled != current.DepthWriteEnabled)
                {
            #if DEBUG
                    changed = true;
            #endif
                    device.SetRenderState(RenderState.ZWriteEnable, DepthWriteEnabled);
                }

                if (DepthTestFunction != current.DepthTestFunction)
                {
            #if DEBUG
                    changed = true;
            #endif
                    device.SetRenderState(RenderState.ZFunc, DepthTestFunction);
                }

                current._mode = _mode;
            }
            else
            {
                if (current.DepthTestEnabled)
                {
            #if DEBUG
                    changed = true;
            #endif
                    device.SetRenderState(RenderState.ZEnable, false);
                    current.DepthTestEnabled = false;
                }
            }
            return changed;
        }
Example #5
0
        internal bool ApplyState(ref DepthColourCullState current, DeviceContext device, bool reverseCull)
        {
            bool changed = false;

            // bits 6 to 14 are used.. so ignore bits 1-5
            if ((current._mode & (~63)) != (_mode & (~63)))
            {
#if DEBUG
                changed = true;
#endif
                Cull cull = CullMode;
                if (cull != current.CullMode)
                {
                    device.SetRenderState(RenderState.CullMode, GetCullMode(reverseCull));
                    current.CullMode = cull;
                }

                FillMode fill = FillMode;
                if (fill != current.FillMode)
                {
                    device.SetRenderState(RenderState.FillMode, FillMode);
                    current.FillMode = fill;
                }
            }

            if (DepthTestEnabled)
            {
                if (!current.DepthTestEnabled)
                {
#if DEBUG
                    changed = true;
#endif
                    device.SetRenderState(RenderState.ZEnable, true);
                }

                if (DepthWriteEnabled != current.DepthWriteEnabled)
                {
#if DEBUG
                    changed = true;
#endif
                    device.SetRenderState(RenderState.ZWriteEnable, DepthWriteEnabled);
                }

                if (DepthTestFunction != current.DepthTestFunction)
                {
#if DEBUG
                    changed = true;
#endif
                    device.SetRenderState(RenderState.ZFunc, DepthTestFunction);
                }

                current._mode = _mode;
            }
            else
            {
                if (current.DepthTestEnabled)
                {
#if DEBUG
                    changed = true;
#endif
                    device.SetRenderState(RenderState.ZEnable, false);
                    current.DepthTestEnabled = false;
                }
            }
            return(changed);
        }