コード例 #1
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.CreateBlendStateImplementation();
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }

            _impl.AlphaBlendFunction    = input.ReadEnum <BlendFunction>();
            _impl.AlphaSourceBlend      = input.ReadEnum <Blend>();
            _impl.AlphaDestinationBlend = input.ReadEnum <Blend>();

            _impl.ColorBlendFunction    = input.ReadEnum <BlendFunction>();
            _impl.ColorSourceBlend      = input.ReadEnum <Blend>();
            _impl.ColorDestinationBlend = input.ReadEnum <Blend>();

            _impl.BlendFactor     = input.ReadColor();
            _impl.MultiSampleMask = input.ReadInt();

            int numBlends = _impl.BlendEnableCount;
            int numMasks  = _impl.ColorWriteChannelsCount;

            //Need to be careful here, this can change across different implementations. Just read in what we can and move on.
            int readNumBlends = input.ReadInt();

            for (int i = 0; i < numBlends; i++)
            {
                _impl.SetBlendEnable(i, input.ReadBoolean());
            }

            int readNumMasks = input.ReadInt();

            for (int i = 0; i < numMasks; i++)
            {
                _impl.SetWriteChannels(i, (ColorWriteChannels)input.ReadInt());
            }
        }
コード例 #2
0
 /// <summary>
 /// Sets the write mask used by the render target specified by its index.
 /// </summary>
 /// <param name="index">Render target index</param>
 /// <param name="mask">Color write mask to use</param>
 public void SetWriteChannels(int index, ColorWriteChannels mask)
 {
     _impl.SetWriteChannels(index, mask);
 }