예제 #1
0
        /// <summary>
        /// Creates a new instance of <see cref="DepthStencilState"/> with default values.
        /// </summary>
        /// <param name="renderSystem">Render system used to create the underlying implementation.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the render system is null.</exception>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying state implementation fails.</exception>
        public DepthStencilState(IRenderSystemProvider renderSystem)
        {
            if (renderSystem == null)
            {
                Dispose();
                throw new ArgumentNullException("renderSystem", "Render system cannot be null.");
            }

            base.RenderSystem = renderSystem;

            try {
                _impl = renderSystem.CreateDepthStencilStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            SetDefaults();
        }
예제 #2
0
        /// <summary>
        /// Creates a new instance of <see cref="DepthStencilState"/> with default values.
        /// </summary>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying state implementation fails.</exception>
        public DepthStencilState()
        {
            IRenderSystemProvider renderSystem = Engine.Services.GetService <IRenderSystemProvider>();

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;

            try {
                _impl = renderSystem.CreateDepthStencilStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            SetDefaults();
        }
예제 #3
0
        /// <summary>
        /// Deserializes the object and populates it from the input.
        /// </summary>
        /// <param name="input">Savable input</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying state implementation fails or the render
        /// system is not set.</exception>
        public override void Read(Content.ISavableReader input)
        {
            IRenderSystemProvider renderSystem = input.RenderSystem;

            if (renderSystem == null)
            {
                Dispose();
                throw new TeslaException("Render system provider not set, cannot create graphics resource implementation.");
            }

            base.RenderSystem = renderSystem;
            try {
                _impl = renderSystem.CreateDepthStencilStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            _impl.DepthEnable      = input.ReadBoolean();
            _impl.DepthWriteEnable = input.ReadBoolean();
            _impl.DepthFunction    = input.ReadEnum <ComparisonFunction>();
            _impl.StencilEnable    = input.ReadBoolean();
            _impl.ReferenceStencil = input.ReadInt();
            _impl.CounterClockwiseStencilFunction  = input.ReadEnum <ComparisonFunction>();
            _impl.CounterClockwiseStencilDepthFail = input.ReadEnum <StencilOperation>();
            _impl.CounterClockwiseStencilFail      = input.ReadEnum <StencilOperation>();
            _impl.CounterClockwiseStencilPass      = input.ReadEnum <StencilOperation>();
            _impl.StencilFunction       = input.ReadEnum <ComparisonFunction>();
            _impl.StencilDepthFail      = input.ReadEnum <StencilOperation>();
            _impl.StencilFail           = input.ReadEnum <StencilOperation>();
            _impl.StencilPass           = input.ReadEnum <StencilOperation>();
            _impl.TwoSidedStencilEnable = input.ReadBoolean();
            _impl.StencilReadMask       = input.ReadInt();
            _impl.StencilWriteMask      = input.ReadInt();

            this.BindRenderState();
        }