Ejemplo n.º 1
0
        public GLGraphicsPipelineBlendColorState Initialize(uint noOfAttachments)
        {
            var initialState = new GLGraphicsPipelineBlendColorState {
                LogicOpEnable = false,
                LogicOp       = MgLogicOp.COPY,
                Attachments   = new GLGraphicsPipelineBlendColorAttachmentState[noOfAttachments],
            };

            for (uint i = 0; i < noOfAttachments; ++i)
            {
                var attachment = new GLGraphicsPipelineBlendColorAttachmentState {
                    BlendEnable         = false,
                    ColorWriteMask      = MgColorComponentFlagBits.R_BIT | MgColorComponentFlagBits.G_BIT | MgColorComponentFlagBits.B_BIT | MgColorComponentFlagBits.A_BIT,
                    ColorBlendOp        = MgBlendOp.ADD,
                    AlphaBlendOp        = MgBlendOp.ADD,
                    SrcColorBlendFactor = MgBlendFactor.ONE,
                    DstColorBlendFactor = MgBlendFactor.ZERO,
                    SrcAlphaBlendFactor = MgBlendFactor.ONE,
                    DstAlphaBlendFactor = MgBlendFactor.ZERO,
                };

                EnableBlending(i, attachment.BlendEnable);
                SetColorMask(i, attachment.ColorWriteMask);
                ApplyBlendSeparateFunction(i,
                                           attachment.SrcColorBlendFactor,
                                           attachment.DstColorBlendFactor,
                                           attachment.SrcAlphaBlendFactor,
                                           attachment.DstAlphaBlendFactor);
                initialState.Attachments [i] = attachment;
            }

            return(initialState);
        }
Ejemplo n.º 2
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;
            }
        }