Beispiel #1
0
        private static void UpdateConstantBuffer(GraphicsDevice graphicsDevice, ref EffectParameterResourceData binding, ShaderParameterUpdater parameterUpdater)
        {
            var constantBufferHelper = parameterUpdater.GetValue <ParameterConstantBuffer>(binding.Param.KeyIndex);

            // Update constant buffer content (if required)
            constantBufferHelper.Update(graphicsDevice, parameterUpdater);

            graphicsDevice.SetConstantBuffer(binding.Stage, binding.SlotStart, constantBufferHelper.Buffer);
        }
Beispiel #2
0
        public void Apply(GraphicsDevice graphicsDevice, EffectParameterResourceBinding[] bindings, ref EffectStateBindings effectStateBindings, bool applyEffectStates)
        {
            // Apply shader parameters
            for (int i = 0; i < bindings.Length; i++)
            {
                bindings[i].ApplyParameterWithUpdater(graphicsDevice, ref bindings[i].Description, parameterUpdater);
            }

            if (applyEffectStates)
            {
                // Apply graphics states
                var rasterizerState = parameterUpdater.GetValue <RasterizerState>(effectStateBindings.RasterizerStateKeyIndex);
                graphicsDevice.SetRasterizerState(rasterizerState);

                var depthStencilState = parameterUpdater.GetValue <DepthStencilState>(effectStateBindings.DepthStencilStateKeyIndex);
                graphicsDevice.SetDepthStencilState(depthStencilState);

                var blendState = parameterUpdater.GetValue <BlendState>(effectStateBindings.BlendStateKeyIndex);
                graphicsDevice.SetBlendState(blendState);
            }
        }