Beispiel #1
0
        public void SetBlendState(H1BlendStateDescription blendState, Int32 numRenderTargets)
        {
            BlendStateDescription blendStateRef = BlendStateDescription.Default();

            blendStateRef.AlphaToCoverageEnable  = blendState.AlphaToCoverageEnable;
            blendStateRef.IndependentBlendEnable = blendState.IndependentBlendEnable;

            for (Int32 i = 0; i < numRenderTargets; ++i)
            {
                RenderTargetBlendDescription   rtBlendDescDest = blendStateRef.RenderTarget[i];
                H1RenderTargetBlendDescription rtBlendDescSrc  = blendState.RenderTargets[i];
                rtBlendDescDest.IsBlendEnabled = rtBlendDescSrc.BlendEnable;
                rtBlendDescDest.LogicOpEnable  = rtBlendDescSrc.LogicOpEnable;

                rtBlendDescDest.SourceBlend      = H1RHIDefinitionHelper.ConvertToBlend(rtBlendDescSrc.SrcBlend);
                rtBlendDescDest.DestinationBlend = H1RHIDefinitionHelper.ConvertToBlend(rtBlendDescSrc.DestBlend);
                rtBlendDescDest.BlendOperation   = H1RHIDefinitionHelper.ConvertToBlendOp(rtBlendDescSrc.BlendOp);

                rtBlendDescDest.SourceAlphaBlend      = H1RHIDefinitionHelper.ConvertToBlend(rtBlendDescSrc.SrcBlendAlpha);
                rtBlendDescDest.DestinationAlphaBlend = H1RHIDefinitionHelper.ConvertToBlend(rtBlendDescSrc.DestBlendAlpha);
                rtBlendDescDest.AlphaBlendOperation   = H1RHIDefinitionHelper.ConvertToBlendOp(rtBlendDescSrc.BlendOpAlpha);

                rtBlendDescDest.LogicOp = H1RHIDefinitionHelper.ConvertToLogicOp(rtBlendDescSrc.LogicOp);
                rtBlendDescDest.RenderTargetWriteMask = H1RHIDefinitionHelper.ConvertToColorWriteMaskFlags(rtBlendDescSrc.RenderTargetWriteMask);
            }

            // newly assign the created blend state
            m_GraphicsPipelineStateDesc.BlendState = blendStateRef;
        }