Example #1
0
        /// <summary>
        /// Function to perform clean up on the shader state.
        /// </summary>
        internal void CleanUp()
        {
            ConstantBuffers[0] = null;

            if (DefaultPixelShaderDiffuseMaterial != null)
            {
                DefaultPixelShaderDiffuseMaterial.Dispose();
            }

            if (DefaultPixelShaderTexturedMaterial != null)
            {
                DefaultPixelShaderTexturedMaterial.Dispose();
            }

            if (DefaultPixelShaderDiffuse != null)
            {
                DefaultPixelShaderDiffuse.Dispose();
            }

            if (DefaultPixelShaderTextured != null)
            {
                DefaultPixelShaderTextured.Dispose();
            }

            DefaultPixelShaderTextured         = null;
            DefaultPixelShaderDiffuse          = null;
            DefaultPixelShaderDiffuseMaterial  = null;
            DefaultPixelShaderTexturedMaterial = null;

            if (MaterialBuffer != null)
            {
                MaterialBuffer.Dispose();
            }

            MaterialBuffer = null;

            if (AlphaTestValuesBuffer == null)
            {
                return;
            }

            AlphaTestValuesBuffer.Dispose();
            AlphaTestValuesBuffer = null;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Gorgon2DPixelShaderState"/> class.
        /// </summary>
        /// <param name="gorgon2D">The gorgon 2D interface that created this object.</param>
        internal Gorgon2DPixelShaderState(Gorgon2D gorgon2D)
            : base(gorgon2D.Graphics)
        {
            _gorgon2D = gorgon2D;

            DefaultPixelShaderDiffuse =
                Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>("Default_Basic_Pixel_Shader_Diffuse",
                                                                                   "GorgonPixelShaderDiffuse",
                                                                                   "#GorgonInclude \"Gorgon2DShaders\"");
            DefaultPixelShaderTextured =
                Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>("Default_Basic_Pixel_Shader_Texture",
                                                                                   "GorgonPixelShaderTextured",
                                                                                   "#GorgonInclude \"Gorgon2DShaders\"");

            DefaultPixelShaderDiffuseMaterial =
                Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>(
                    "Default_Basic_Pixel_Shader_Diffuse_Material",
                    "GorgonPixelShaderDiffuseMaterial",
                    "#GorgonInclude \"Gorgon2DShaders\"");
            DefaultPixelShaderTexturedMaterial =
                Graphics.ImmediateContext.Shaders.CreateShader <GorgonPixelShader>(
                    "Default_Basic_Pixel_Shader_Texture_Material",
                    "GorgonPixelShaderTexturedMaterial",
                    "#GorgonInclude \"Gorgon2DShaders\"");

            var alphaTestValues = new Gorgon2DAlphaTest(gorgon2D.IsAlphaTestEnabled, GorgonRangeF.Empty);

            AlphaTestValuesBuffer = Graphics.ImmediateContext.Buffers.CreateConstantBuffer("Gorgon2D Alpha Test Constant Buffer",
                                                                                           new GorgonConstantBufferSettings
            {
                SizeInBytes = DirectAccess.SizeOf <Gorgon2DAlphaTest>()
            });

            // Initialize the alpha testing values.
            AlphaTestValuesBuffer.Update(ref alphaTestValues);

            MaterialBuffer = Graphics.ImmediateContext.Buffers.CreateConstantBuffer("Gorgon2D Material Constant Buffer",
                                                                                    new GorgonConstantBufferSettings
            {
                SizeInBytes = 32,
                Usage       = BufferUsage.Default
            });
        }