Microsoft.Xna.Framework.Graphics.Effect.OnApply C# (CSharp) Method

OnApply() protected method

protected OnApply ( ) : bool
return bool
        protected internal virtual bool OnApply()
        {
            return false;
        }

Usage Example

Esempio n. 1
0
        public void Apply()
        {
            // Set/get the correct shader handle/cleanups.

            var current = _effect.CurrentTechnique;

            _effect.OnApply();
            if (_effect.CurrentTechnique != current)
            {
                _effect.CurrentTechnique.Passes[0].Apply();
                return;
            }

            var device = _effect.GraphicsDevice;

            if (_vertexShader != null)
            {
                device.VertexShader = _vertexShader;

                // Update the texture parameters.
                SetShaderSamplers(_vertexShader, device.VertexTextures, device.VertexSamplerStates);

                // Update the constant buffers.
                for (var c = 0; c < _vertexShader.CBuffers.Length; c++)
                {
                    var cb = _effect.ConstantBuffers[_vertexShader.CBuffers[c]];
                    cb.Update(_effect.Parameters);
                    device.SetConstantBuffer(ShaderStage.Vertex, c, cb);
                }
            }

            if (_pixelShader != null)
            {
                device.PixelShader = _pixelShader;

                // Update the texture parameters.
                SetShaderSamplers(_pixelShader, device.Textures, device.SamplerStates);

                // Update the constant buffers.
                for (var c = 0; c < _pixelShader.CBuffers.Length; c++)
                {
                    var cb = _effect.ConstantBuffers[_pixelShader.CBuffers[c]];
                    cb.Update(_effect.Parameters);
                    device.SetConstantBuffer(ShaderStage.Pixel, c, cb);
                }
            }

            // Set the render states if we have some.
            //            if (_rasterizerState != null)
            //                device.RasterizerState = _rasterizerState;
            //            if (_blendState != null)
            //                device.BlendState = _blendState;
            //            if (_depthStencilState != null)
            //                device.DepthStencilState = _depthStencilState;
        }
All Usage Examples Of Microsoft.Xna.Framework.Graphics.Effect::OnApply