Ejemplo n.º 1
0
        private void SetAlphaBlending()
        {
            //TODO: Support independent blend properly.
            bool Enable = (ReadRegister(NvGpuEngine3dReg.IBlendNEnable) & 1) != 0;

            Gpu.Renderer.SetBlendEnable(Enable);

            bool BlendSeparateAlpha = (ReadRegister(NvGpuEngine3dReg.IBlendNSeparateAlpha) & 1) != 0;

            GalBlendEquation EquationRgb = (GalBlendEquation)ReadRegister(NvGpuEngine3dReg.IBlendNEquationRgb);

            GalBlendFactor FuncSrcRgb = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncSrcRgb);
            GalBlendFactor FuncDstRgb = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncDstRgb);

            if (BlendSeparateAlpha)
            {
                GalBlendEquation EquationAlpha = (GalBlendEquation)ReadRegister(NvGpuEngine3dReg.IBlendNEquationAlpha);

                GalBlendFactor FuncSrcAlpha = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncSrcAlpha);
                GalBlendFactor FuncDstAlpha = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncDstAlpha);

                Gpu.Renderer.SetBlendSeparate(
                    EquationRgb,
                    EquationAlpha,
                    FuncSrcRgb,
                    FuncDstRgb,
                    FuncSrcAlpha,
                    FuncDstAlpha);
            }
            else
            {
                Gpu.Renderer.SetBlend(EquationRgb, FuncSrcRgb, FuncDstRgb);
            }
        }
Ejemplo n.º 2
0
        public static BlendEquationMode GetBlendEquation(GalBlendEquation blendEquation)
        {
            switch (blendEquation)
            {
            case GalBlendEquation.FuncAdd:
            case GalBlendEquation.FuncAddGl:
                return(BlendEquationMode.FuncAdd);

            case GalBlendEquation.FuncSubtract:
            case GalBlendEquation.FuncSubtractGl:
                return(BlendEquationMode.FuncSubtract);

            case GalBlendEquation.FuncReverseSubtract:
            case GalBlendEquation.FuncReverseSubtractGl:
                return(BlendEquationMode.FuncReverseSubtract);

            case GalBlendEquation.Min:
            case GalBlendEquation.MinGl:
                return(BlendEquationMode.Min);

            case GalBlendEquation.Max:
            case GalBlendEquation.MaxGl:
                return(BlendEquationMode.Max);
            }

            throw new ArgumentException(nameof(blendEquation) + " \"" + blendEquation + "\" is not valid!");
        }
Ejemplo n.º 3
0
 public void SetBlend(
     GalBlendEquation Equation,
     GalBlendFactor FuncSrc,
     GalBlendFactor FuncDst)
 {
     ActionsQueue.Enqueue(() => Blend.Set(Equation, FuncSrc, FuncDst));
 }
Ejemplo n.º 4
0
        private void SetAlphaBlending()
        {
            bool BlendEnableMaster = (ReadRegister(NvGpuEngine3dReg.BlendEnableMaster) & 1) != 0;

            Gpu.Renderer.SetBlendEnable(BlendEnableMaster);

            bool BlendSeparateAlpha = (ReadRegister(NvGpuEngine3dReg.BlendSeparateAlpha) & 1) != 0;

            GalBlendEquation EquationRgb = (GalBlendEquation)ReadRegister(NvGpuEngine3dReg.BlendEquationRgb);

            GalBlendFactor FuncSrcRgb = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.BlendFuncSrcRgb);
            GalBlendFactor FuncDstRgb = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.BlendFuncDstRgb);

            if (BlendSeparateAlpha)
            {
                GalBlendEquation EquationAlpha = (GalBlendEquation)ReadRegister(NvGpuEngine3dReg.BlendEquationAlpha);

                GalBlendFactor FuncSrcAlpha = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.BlendFuncSrcAlpha);
                GalBlendFactor FuncDstAlpha = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.BlendFuncDstAlpha);

                Gpu.Renderer.SetBlendSeparate(
                    EquationRgb,
                    EquationAlpha,
                    FuncSrcRgb,
                    FuncDstRgb,
                    FuncSrcAlpha,
                    FuncDstAlpha);
            }
            else
            {
                Gpu.Renderer.SetBlend(EquationRgb, FuncSrcRgb, FuncDstRgb);
            }
        }
Ejemplo n.º 5
0
        public void Set(
            GalBlendEquation Equation,
            GalBlendFactor FuncSrc,
            GalBlendFactor FuncDst)
        {
            GL.BlendEquation(
                OGLEnumConverter.GetBlendEquation(Equation));

            GL.BlendFunc(
                OGLEnumConverter.GetBlendFactorSrc(FuncSrc),
                OGLEnumConverter.GetBlendFactorDst(FuncDst));
        }
Ejemplo n.º 6
0
        private void SetAlphaBlending()
        {
            //TODO: Support independent blend properly.
            bool Enable = (ReadRegister(NvGpuEngine3dReg.IBlendNEnable) & 1) != 0;

            if (Enable)
            {
                Gpu.Renderer.Blend.Enable();
            }
            else
            {
                Gpu.Renderer.Blend.Disable();
            }

            if (!Enable)
            {
                //If blend is not enabled, then the other values have no effect.
                //Note that if it is disabled, the register may contain invalid values.
                return;
            }

            bool BlendSeparateAlpha = (ReadRegister(NvGpuEngine3dReg.IBlendNSeparateAlpha) & 1) != 0;

            GalBlendEquation EquationRgb = (GalBlendEquation)ReadRegister(NvGpuEngine3dReg.IBlendNEquationRgb);

            GalBlendFactor FuncSrcRgb = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncSrcRgb);
            GalBlendFactor FuncDstRgb = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncDstRgb);

            if (BlendSeparateAlpha)
            {
                GalBlendEquation EquationAlpha = (GalBlendEquation)ReadRegister(NvGpuEngine3dReg.IBlendNEquationAlpha);

                GalBlendFactor FuncSrcAlpha = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncSrcAlpha);
                GalBlendFactor FuncDstAlpha = (GalBlendFactor)ReadRegister(NvGpuEngine3dReg.IBlendNFuncDstAlpha);

                Gpu.Renderer.Blend.SetSeparate(
                    EquationRgb,
                    EquationAlpha,
                    FuncSrcRgb,
                    FuncDstRgb,
                    FuncSrcAlpha,
                    FuncDstAlpha);
            }
            else
            {
                Gpu.Renderer.Blend.Set(EquationRgb, FuncSrcRgb, FuncDstRgb);
            }
        }
Ejemplo n.º 7
0
        public static BlendEquationMode GetBlendEquation(GalBlendEquation BlendEquation)
        {
            switch (BlendEquation)
            {
            case GalBlendEquation.FuncAdd:             return(BlendEquationMode.FuncAdd);

            case GalBlendEquation.FuncSubtract:        return(BlendEquationMode.FuncSubtract);

            case GalBlendEquation.FuncReverseSubtract: return(BlendEquationMode.FuncReverseSubtract);

            case GalBlendEquation.Min:                 return(BlendEquationMode.Min);

            case GalBlendEquation.Max:                 return(BlendEquationMode.Max);
            }

            throw new ArgumentException(nameof(BlendEquation));
        }
Ejemplo n.º 8
0
        public static BlendEquationMode GetBlendEquation(GalBlendEquation BlendEquation)
        {
            switch (BlendEquation)
            {
            case GalBlendEquation.FuncAdd:             return(BlendEquationMode.FuncAdd);

            case GalBlendEquation.FuncSubtract:        return(BlendEquationMode.FuncSubtract);

            case GalBlendEquation.FuncReverseSubtract: return(BlendEquationMode.FuncReverseSubtract);

            case GalBlendEquation.Min:                 return(BlendEquationMode.Min);

            case GalBlendEquation.Max:                 return(BlendEquationMode.Max);
            }

            return(BlendEquationMode.FuncAdd);
        }
Ejemplo n.º 9
0
        public void SetSeparate(
            GalBlendEquation EquationRgb,
            GalBlendEquation EquationAlpha,
            GalBlendFactor FuncSrcRgb,
            GalBlendFactor FuncDstRgb,
            GalBlendFactor FuncSrcAlpha,
            GalBlendFactor FuncDstAlpha)
        {
            GL.BlendEquationSeparate(
                OGLEnumConverter.GetBlendEquation(EquationRgb),
                OGLEnumConverter.GetBlendEquation(EquationAlpha));

            GL.BlendFuncSeparate(
                OGLEnumConverter.GetBlendFactorSrc(FuncSrcRgb),
                OGLEnumConverter.GetBlendFactorDst(FuncDstRgb),
                OGLEnumConverter.GetBlendFactorSrc(FuncSrcAlpha),
                OGLEnumConverter.GetBlendFactorDst(FuncDstAlpha));
        }
Ejemplo n.º 10
0
 public void SetBlendSeparate(
     GalBlendEquation EquationRgb,
     GalBlendEquation EquationAlpha,
     GalBlendFactor FuncSrcRgb,
     GalBlendFactor FuncDstRgb,
     GalBlendFactor FuncSrcAlpha,
     GalBlendFactor FuncDstAlpha)
 {
     ActionsQueue.Enqueue(() =>
     {
         Blend.SetSeparate(
             EquationRgb,
             EquationAlpha,
             FuncSrcRgb,
             FuncDstRgb,
             FuncSrcAlpha,
             FuncDstAlpha);
     });
 }
Ejemplo n.º 11
0
 public static BlendEquationMode GetBlendEquation(GalBlendEquation BlendEquation)
 {
     return((BlendEquationMode)BlendEquation);
 }