Ejemplo n.º 1
0
        void PopulateColorBlend(MgPipelineColorBlendStateCreateInfo colorBlend)
        {
            ColorBlendEnums = new GLGraphicsPipelineBlendColorState();
            if (colorBlend != null)
            {
                BlendConstants = colorBlend.BlendConstants;

                ColorBlendEnums.LogicOpEnable = colorBlend.LogicOpEnable;
                ColorBlendEnums.LogicOp       = colorBlend.LogicOp;

                if (colorBlend.Attachments != null)
                {
                    var colorAttachments = new GLGraphicsPipelineBlendColorAttachmentState[colorBlend.Attachments.Length];
                    for (uint i = 0; i < colorBlend.Attachments.Length; ++i)
                    {
                        var attachment = colorBlend.Attachments[i];

                        colorAttachments[i] = new GLGraphicsPipelineBlendColorAttachmentState {
                            BlendEnable         = attachment.BlendEnable,
                            SrcColorBlendFactor = attachment.SrcColorBlendFactor,
                            DstColorBlendFactor = attachment.DstColorBlendFactor,
                            ColorBlendOp        = attachment.ColorBlendOp,
                            SrcAlphaBlendFactor = attachment.SrcAlphaBlendFactor,
                            DstAlphaBlendFactor = attachment.DstAlphaBlendFactor,
                            AlphaBlendOp        = attachment.AlphaBlendOp,
                            ColorWriteMask      = attachment.ColorWriteMask,
                        };
                    }
                    ColorBlendEnums.Attachments = colorAttachments;
                }
                else
                {
                    ColorBlendEnums.Attachments = new GLGraphicsPipelineBlendColorAttachmentState[] { };
                }
            }
            else
            {
                BlendConstants = new MgColor4f(0f, 0f, 0f, 0f);
                ColorBlendEnums.Attachments = new GLGraphicsPipelineBlendColorAttachmentState[] { };

                ColorBlendEnums.LogicOpEnable = false;
                ColorBlendEnums.LogicOp       = MgLogicOp.COPY;
            }
        }
Ejemplo n.º 2
0
        void InitializeColorBlending(MgPipelineColorBlendStateCreateInfo colorBlend)
        {
            if (colorBlend != null)
            {
                BlendConstants = colorBlend.BlendConstants;

                if (colorBlend.Attachments != null)
                {
                    int arrayLength      = colorBlend.Attachments.Length;
                    var colorAttachments = new AmtBlendColorAttachmentRecord[arrayLength];
                    for (uint i = 0; i < arrayLength; ++i)
                    {
                        var attachment = colorBlend.Attachments[i];

                        colorAttachments[i] = new AmtBlendColorAttachmentRecord
                        {
                            IsBlendingEnabled           = attachment.BlendEnable,
                            SourceRgbBlendFactor        = TranslateBlendFactor(attachment.SrcColorBlendFactor),
                            DestinationRgbBlendFactor   = TranslateBlendFactor(attachment.DstColorBlendFactor),
                            RgbBlendOperation           = TranslateBlendOperation(attachment.ColorBlendOp),
                            SourceAlphaBlendFactor      = TranslateBlendFactor(attachment.SrcAlphaBlendFactor),
                            DestinationAlphaBlendFactor = TranslateBlendFactor(attachment.DstAlphaBlendFactor),
                            AlphaBlendOperation         = TranslateBlendOperation(attachment.AlphaBlendOp),
                            ColorWriteMask = TranslateColorWriteMask(attachment.ColorWriteMask),
                        };
                    }
                    Attachments = colorAttachments;
                }
                else
                {
                    Attachments = new AmtBlendColorAttachmentRecord[] { };
                }
            }
            else
            {
                BlendConstants = new MgColor4f(0f, 0f, 0f, 0f);
                Attachments    = new AmtBlendColorAttachmentRecord[] { };
            }
        }