Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteBatchEffect"/> class.
 /// </summary>
 /// <param name="impl">The <see cref="EffectImplementation"/> that implements the effect.</param>
 protected SpriteBatchEffect(EffectImplementation impl)
     : base(impl)
 {
     this.epTexture         = Parameters["Texture"];
     this.epTextureSize     = Parameters["TextureSize"];
     this.epMatrixTransform = Parameters["MatrixTransform"];
     this.epSrgbColor       = Parameters["SrgbColor"];
 }
Example #2
0
        /// <summary>
        /// Creates a new Effect from the specified compiled shader byte code.
        /// </summary>
        /// <param name="renderSystem">Render system used to create the underlying implementation.</param>
        /// <param name="shaderByteCode">Compiled byte code</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 Effect(IRenderSystemProvider renderSystem, byte[] shaderByteCode)
        {
            if (renderSystem == null)
            {
                Dispose();
                throw new ArgumentNullException("renderSystem", "Render system cannot be null.");
            }

            base.RenderSystem = renderSystem;

            try {
                _impl           = renderSystem.CreateEffectImplementation(shaderByteCode);
                _cachedByteCode = shaderByteCode;
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new Effect from the specified compiled shader byte code.
        /// </summary>
        /// <param name="shaderByteCode">Compiled byte code</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying effect implementation fails.</exception>
        public Effect(byte[] shaderByteCode)
        {
            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.CreateEffectImplementation(shaderByteCode);
                _cachedByteCode = shaderByteCode;
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Example #4
0
        /// <summary>
        /// Deserializes this Effect.
        /// </summary>
        /// <param name="input">Input to read from</param>
        /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying effect implementation fails or the render
        /// system is not set.</exception>
        public void Read(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;

            String name = input.ReadString();

            _cachedByteCode = input.ReadByteArray();

            try {
                _impl      = renderSystem.CreateEffectImplementation(_cachedByteCode);
                _impl.Name = name;
            } catch (Exception e) {
                Dispose();
                throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e);
            }
        }
Example #5
0
 //For Clone
 private Effect(EffectImplementation implementation)
 {
     _impl = implementation;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteBatchEffect"/> class.
 /// </summary>
 /// <param name="impl">The <see cref="EffectImplementation"/> that implements the effect.</param>
 protected SpriteBatchEffect(EffectImplementation impl)
     : base(impl)
 {
     this.epMatrixTransform = Parameters["MatrixTransform"];
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteBatchEffect"/> class.
 /// </summary>
 /// <param name="impl">The <see cref="EffectImplementation"/> that implements the effect.</param>
 protected SpriteBatchEffect(EffectImplementation impl)
     : base(impl)
 {
     this.epMatrixTransform = Parameters["MatrixTransform"];
 }