示例#1
0
        internal BlendState(GraphicsDevice device, BlendStateDescription blendStateDescription) : base(device)
        {
            Description = blendStateDescription;

            for (int i = 1; i < Description.RenderTargets.Length; ++i)
            {
                if (Description.RenderTargets[i].BlendEnable || Description.RenderTargets[i].ColorWriteChannels != ColorWriteChannels.All)
                {
                    throw new NotSupportedException();
                }
            }

            blendEnable = Description.RenderTargets[0].BlendEnable;

            blendEquationModeColor = ToOpenGL(Description.RenderTargets[0].ColorBlendFunction);
            blendEquationModeAlpha = ToOpenGL(Description.RenderTargets[0].AlphaBlendFunction);
            blendFactorSrcColor    = ToOpenGL(Description.RenderTargets[0].ColorSourceBlend);
            blendFactorSrcAlpha    = ToOpenGL(Description.RenderTargets[0].AlphaSourceBlend);
            blendFactorDestColor   = (BlendingFactorDest)ToOpenGL(Description.RenderTargets[0].ColorDestinationBlend);
            blendFactorDestAlpha   = (BlendingFactorDest)ToOpenGL(Description.RenderTargets[0].AlphaDestinationBlend);
            EnabledColors[0]       = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Red) != 0;
            EnabledColors[1]       = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Green) != 0;
            EnabledColors[2]       = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Blue) != 0;
            EnabledColors[3]       = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Alpha) != 0;

            blendEquationHash = (uint)Description.RenderTargets[0].ColorBlendFunction
                                | ((uint)Description.RenderTargets[0].AlphaBlendFunction << 8);

            blendFuncHash = (uint)Description.RenderTargets[0].ColorSourceBlend
                            | ((uint)Description.RenderTargets[0].AlphaSourceBlend << 8)
                            | ((uint)Description.RenderTargets[0].ColorDestinationBlend << 16)
                            | ((uint)Description.RenderTargets[0].AlphaDestinationBlend << 24);
        }
示例#2
0
        internal BlendState(GraphicsDevice device, BlendStateDescription blendStateDescription) : base(device)
        {
            Description = blendStateDescription;

            for (int i = 1; i < Description.RenderTargets.Length; ++i)
            {
                if (Description.RenderTargets[i].BlendEnable || Description.RenderTargets[i].ColorWriteChannels != ColorWriteChannels.All)
                    throw new NotSupportedException();
            }

            blendEnable = Description.RenderTargets[0].BlendEnable;

            blendEquationModeColor = ToOpenGL(Description.RenderTargets[0].ColorBlendFunction);
            blendEquationModeAlpha = ToOpenGL(Description.RenderTargets[0].AlphaBlendFunction);
            blendFactorSrcColor = ToOpenGL(Description.RenderTargets[0].ColorSourceBlend);
            blendFactorSrcAlpha = ToOpenGL(Description.RenderTargets[0].AlphaSourceBlend);
            blendFactorDestColor = (BlendingFactorDest)ToOpenGL(Description.RenderTargets[0].ColorDestinationBlend);
            blendFactorDestAlpha = (BlendingFactorDest)ToOpenGL(Description.RenderTargets[0].AlphaDestinationBlend);
            EnabledColors[0] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Red  ) != 0;
            EnabledColors[1] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Green) != 0;
            EnabledColors[2] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Blue ) != 0;
            EnabledColors[3] = (Description.RenderTargets[0].ColorWriteChannels & ColorWriteChannels.Alpha) != 0;

            blendEquationHash = (uint)Description.RenderTargets[0].ColorBlendFunction
                             | ((uint)Description.RenderTargets[0].AlphaBlendFunction << 8);

            blendFuncHash = (uint)Description.RenderTargets[0].ColorSourceBlend
                         | ((uint)Description.RenderTargets[0].AlphaSourceBlend << 8)
                         | ((uint)Description.RenderTargets[0].ColorDestinationBlend << 16)
                         | ((uint)Description.RenderTargets[0].AlphaDestinationBlend << 24);
        }
示例#3
0
        public BlendingInfo(BlendingMode blendingMode)
        {
            switch (blendingMode)
            {
            case BlendingMode.Inherit:
            case BlendingMode.Mixture:
                Source           = BlendingFactorSrc.SrcAlpha;
                Destination      = BlendingFactorDest.OneMinusSrcAlpha;
                SourceAlpha      = BlendingFactorSrc.One;
                DestinationAlpha = BlendingFactorDest.One;
                break;

            case BlendingMode.Additive:
                Source           = BlendingFactorSrc.SrcAlpha;
                Destination      = BlendingFactorDest.One;
                SourceAlpha      = BlendingFactorSrc.One;
                DestinationAlpha = BlendingFactorDest.One;
                break;

            default:
                Source           = BlendingFactorSrc.One;
                Destination      = BlendingFactorDest.Zero;
                SourceAlpha      = BlendingFactorSrc.One;
                DestinationAlpha = BlendingFactorDest.Zero;
                break;
            }
        }
示例#4
0
 /// <summary>
 /// Initializes a new custom instance of the <see cref="SurfaceBlendSetting"/> class.
 /// </summary>
 /// <param name="src">The <see cref="BlendingFactorSrc"/>.</param>
 /// <param name="dest">The <see cref="BlendingFactorDest"/>.</param>
 /// <param name="equation">The <see cref="BlendEquationMode"/>.</param>
 public SurfaceBlendSetting(BlendingFactorSrc src, BlendingFactorDest dest, BlendEquationMode equation)
     : base(true)
 {
     this.srcBlend  = src;
     this.destBlend = dest;
     this.equation  = equation;
 }
        internal unsafe BlendState(BlendStateDescription blendStateDescription, bool hasRenderTarget)
        {
            var renderTargets = &blendStateDescription.RenderTarget0;
            for (int i = 1; i < 8; ++i)
            {
                if (renderTargets[i].BlendEnable || renderTargets[i].ColorWriteChannels != ColorWriteChannels.All)
                    throw new NotSupportedException();
            }

            ColorWriteChannels = blendStateDescription.RenderTarget0.ColorWriteChannels;
            if (!hasRenderTarget)
                ColorWriteChannels = 0;

            blendEnable = blendStateDescription.RenderTarget0.BlendEnable;

            blendEquationModeColor = ToOpenGL(blendStateDescription.RenderTarget0.ColorBlendFunction);
            blendEquationModeAlpha = ToOpenGL(blendStateDescription.RenderTarget0.AlphaBlendFunction);
            blendFactorSrcColor = ToOpenGL(blendStateDescription.RenderTarget0.ColorSourceBlend);
            blendFactorSrcAlpha = ToOpenGL(blendStateDescription.RenderTarget0.AlphaSourceBlend);
            blendFactorDestColor = (BlendingFactorDest)ToOpenGL(blendStateDescription.RenderTarget0.ColorDestinationBlend);
            blendFactorDestAlpha = (BlendingFactorDest)ToOpenGL(blendStateDescription.RenderTarget0.AlphaDestinationBlend);

            blendEquationHash = (uint)blendStateDescription.RenderTarget0.ColorBlendFunction
                             | ((uint)blendStateDescription.RenderTarget0.AlphaBlendFunction << 8);

            blendFuncHash = (uint)blendStateDescription.RenderTarget0.ColorSourceBlend
                         | ((uint)blendStateDescription.RenderTarget0.AlphaSourceBlend << 8)
                         | ((uint)blendStateDescription.RenderTarget0.ColorDestinationBlend << 16)
                         | ((uint)blendStateDescription.RenderTarget0.AlphaDestinationBlend << 24);
        }
示例#6
0
 /// <summary>
 /// Initializes a new custom instance of the <see cref="SurfaceBlendSetting"/> class.
 /// </summary>
 /// <param name="src">The <see cref="BlendingFactorSrc"/>.</param>
 /// <param name="dest">The <see cref="BlendingFactorDest"/>.</param>
 /// <param name="equation">The <see cref="BlendEquationMode"/>.</param>
 public SurfaceBlendSetting(BlendingFactorSrc src, BlendingFactorDest dest, BlendEquationMode equation)
     : base(true)
 {
     this.srcBlend = src;
     this.destBlend = dest;
     this.equation = equation;
 }
示例#7
0
        internal unsafe BlendState(BlendStateDescription blendStateDescription, bool hasRenderTarget)
        {
            var renderTargets = &blendStateDescription.RenderTarget0;

            for (int i = 1; i < 8; ++i)
            {
                if (renderTargets[i].BlendEnable || renderTargets[i].ColorWriteChannels != ColorWriteChannels.All)
                {
                    throw new NotSupportedException();
                }
            }

            ColorWriteChannels = blendStateDescription.RenderTarget0.ColorWriteChannels;
            if (!hasRenderTarget)
            {
                ColorWriteChannels = 0;
            }

            blendEnable = blendStateDescription.RenderTarget0.BlendEnable;

            blendEquationModeColor = ToOpenGL(blendStateDescription.RenderTarget0.ColorBlendFunction);
            blendEquationModeAlpha = ToOpenGL(blendStateDescription.RenderTarget0.AlphaBlendFunction);
            blendFactorSrcColor    = ToOpenGL(blendStateDescription.RenderTarget0.ColorSourceBlend);
            blendFactorSrcAlpha    = ToOpenGL(blendStateDescription.RenderTarget0.AlphaSourceBlend);
            blendFactorDestColor   = (BlendingFactorDest)ToOpenGL(blendStateDescription.RenderTarget0.ColorDestinationBlend);
            blendFactorDestAlpha   = (BlendingFactorDest)ToOpenGL(blendStateDescription.RenderTarget0.AlphaDestinationBlend);

            blendEquationHash = (uint)blendStateDescription.RenderTarget0.ColorBlendFunction
                                | ((uint)blendStateDescription.RenderTarget0.AlphaBlendFunction << 8);

            blendFuncHash = (uint)blendStateDescription.RenderTarget0.ColorSourceBlend
                            | ((uint)blendStateDescription.RenderTarget0.AlphaSourceBlend << 8)
                            | ((uint)blendStateDescription.RenderTarget0.ColorDestinationBlend << 16)
                            | ((uint)blendStateDescription.RenderTarget0.AlphaDestinationBlend << 24);
        }
示例#8
0
 public Blending()
 {
     enabled    = false;
     equation   = BlendEquationMode.FuncAdd;
     factorSrc  = BlendingFactorSrc.SrcAlpha;
     factorDest = BlendingFactorDest.OneMinusSrcAlpha;
 }
示例#9
0
 public BlendingFactorState(BlendingFactorSrc src, BlendingFactorDest dest, BlendingFactorSrc alphaSrc, BlendingFactorDest alphaDest)
 {
     this.src       = src;
     this.dest      = dest;
     this.alphaSrc  = alphaSrc;
     this.alphaDest = alphaDest;
 }
示例#10
0
        public BlendingInfo(BlendingParameters parameters)
        {
            switch (parameters.Mode)
            {
            case BlendingMode.Inherit:
            case BlendingMode.Mixture:
                Source           = BlendingFactorSrc.SrcAlpha;
                Destination      = BlendingFactorDest.OneMinusSrcAlpha;
                SourceAlpha      = BlendingFactorSrc.One;
                DestinationAlpha = BlendingFactorDest.One;
                break;

            case BlendingMode.Additive:
                Source           = BlendingFactorSrc.SrcAlpha;
                Destination      = BlendingFactorDest.One;
                SourceAlpha      = BlendingFactorSrc.One;
                DestinationAlpha = BlendingFactorDest.One;
                break;

            default:
                Source           = BlendingFactorSrc.One;
                Destination      = BlendingFactorDest.Zero;
                SourceAlpha      = BlendingFactorSrc.One;
                DestinationAlpha = BlendingFactorDest.Zero;
                break;
            }

            RGBEquation   = translateEquation(parameters.RGBEquation);
            AlphaEquation = translateEquation(parameters.AlphaEquation);
        }
示例#11
0
文件: GL.cs 项目: asmboom/PixelFarm
        public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
        {
#if USE_OPENGL
            OpenTK.Graphics.OpenGL.GL.BlendFunc((OpenTK.Graphics.OpenGL.BlendingFactorSrc)sfactor, (OpenTK.Graphics.OpenGL.BlendingFactorDest)dfactor);
#else
            OpenTK.Graphics.ES11.GL.BlendFunc((OpenTK.Graphics.ES11.All)sfactor, (OpenTK.Graphics.ES11.All)dfactor);
#endif
        }
示例#12
0
 public BlendMode(BlendingFactorSrc srcRgb, BlendingFactorDest dstRgb, BlendingFactorSrc srcAlpha, BlendingFactorDest dstAlpha, BlendEquationMode modeRgb = BlendEquationMode.FuncAdd, BlendEquationMode modeAlpha = BlendEquationMode.FuncAdd)
 {
     BlendSrcRgb    = srcRgb;
     BlendDstRgb    = dstRgb;
     BlendSrcAlpha  = srcAlpha;
     BlendDstAlpha  = dstAlpha;
     BlendModeRgb   = modeRgb;
     BlendModeAlpha = modeAlpha;
 }
示例#13
0
 public static void BlendFunc(BlendingFactorSrc blendingFactorSrc, BlendingFactorDest blendingFactorDest)
 {
     if (blendFactorSrc != blendingFactorSrc || blendFactorDest != blendingFactorDest)
     {
         blendFactorSrc = blendingFactorSrc;
         blendFactorDest = blendingFactorDest;
         GL.BlendFunc(blendingFactorSrc, blendingFactorDest);
     }
 }
示例#14
0
 public static void BlendFunc(BlendingFactorSrc blendingFactorSrc, BlendingFactorDest blendingFactorDest)
 {
     if (blendFactorSrc != blendingFactorSrc || blendFactorDest != blendingFactorDest)
     {
         blendFactorSrc  = blendingFactorSrc;
         blendFactorDest = blendingFactorDest;
         GL.BlendFunc(blendingFactorSrc, blendingFactorDest);
     }
 }
示例#15
0
        internal static Blend Convert(BlendingFactorSrc blend)
        {
            if (!blends.ContainsValue(blend))
            {
                throw new NotSupportedException("blend is not supported");
            }

            return(blends.First((f) => f.Value == blend).Key);
        }
示例#16
0
        public static void BlendFunc(BlendingFactorSrc source, BlendingFactorDest dest)
        {
            if (source != _blendFuncSource && dest != _blendFuncDest)
            {
                source = _blendFuncSource;
                dest = _blendFuncDest;

                GL.BlendFunc(source, dest);
            }
        }
示例#17
0
        public static void BlendFunc(BlendingFactorSrc source, BlendingFactorDest dest)
        {
            if (source != _blendFuncSource && dest != _blendFuncDest)
            {
                source = _blendFuncSource;
                dest   = _blendFuncDest;

                GL.BlendFunc(source, dest);
            }
        }
 public IBlendState CreateBlendState(
     BlendingFactorSrc colorSource,
     BlendEquationMode colorEquation,
     BlendingFactorDest colorDest,
     BlendingFactorSrc alphaSource,
     BlendEquationMode alphaEquation,
     BlendingFactorDest alphaDest)
 {
     return(new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest));
 }
示例#19
0
        public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
        {
#if USE_OPENGL
            if (openGlHardwareAvailable)
            {
                OpenTK.Graphics.OpenGL.GL.BlendFunc((OpenTK.Graphics.OpenGL.BlendingFactorSrc)sfactor, (OpenTK.Graphics.OpenGL.BlendingFactorDest)dfactor);
            }
#else
            OpenTK.Graphics.ES11.GL.BlendFunc((OpenTK.Graphics.ES11.All)sfactor, (OpenTK.Graphics.ES11.All)dfactor);
#endif
        }
示例#20
0
 public MyBlendState(bool enabled, BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
                     BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
 {
     this.enabled       = enabled;
     this.colorSource   = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)colorSource;
     this.colorEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)colorEquation;
     this.colorDest     = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)colorDest;
     this.alphaSource   = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)alphaSource;
     this.alphaEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)alphaEquation;
     this.alphaDest     = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)alphaDest;
 }
示例#21
0
 public GLState(CullFaceMode cullFaceMode, DepthFunction depthFunction, BlendingFactorSrc blendingFactorSrc,
                BlendingFactorDest blendingFactorDest, params EnableCap[] enableCaps)
 {
     CullFaceMode       = cullFaceMode;
     DepthFunction      = depthFunction;
     BlendingFactorSrc  = blendingFactorSrc;
     BlendingFactorDest = blendingFactorDest;
     EnableCaps         = enableCaps;
     _fullHash          = "{" + CullFaceMode + "}{" + DepthFunction + "}{" + BlendingFactorSrc + "}{" + BlendingFactorDest +
                          "}{" + EnableCaps.Aggregate("", (left, cap) => left + cap.ToString()) + "}";
 }
示例#22
0
        /// <summary>
        /// Construct a BlendState with separated RGB/Alpha functions.
        /// </summary>
        /// <param name="rgbEquation">
        /// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending RGB color components.
        /// </param>
        /// <param name="alphaEquation">
        /// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending Alpha color component.
        /// </param>
        /// <param name="srcRgbFactor">
        /// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to the source color (alpha component excluded).
        /// </param>
        /// <param name="srcAlphaFactor">
        /// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to only the source alpha component.
        /// </param>
        /// <param name="dstRgbFactor">
        /// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to the destination color (alpha component excluded).
        /// </param>
        /// <param name="dstAlphaFactor">
        /// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to only the destination alpha component.
        /// </param>
        /// <param name="constColor">
        /// A <see cref="ColorRGBAF"/> that specify the constant color used in blending functions.
        /// </param>
        public BlendState(BlendEquationModeEXT rgbEquation, BlendEquationModeEXT alphaEquation, BlendingFactorSrc srcRgbFactor, BlendingFactorSrc srcAlphaFactor, BlendingFactorDest dstRgbFactor, BlendingFactorDest dstAlphaFactor, ColorRGBAF constColor)
        {
            if (IsSupportedEquation(rgbEquation) == false)
            {
                throw new ArgumentException("not supported blending equation " + srcRgbFactor, "rgbEquation");
            }
            if (IsSupportedEquation(alphaEquation) == false)
            {
                throw new ArgumentException("not supported blending equation " + alphaEquation, "rgbEquation");
            }
            if (IsSupportedFunction(srcRgbFactor) == false)
            {
                throw new ArgumentException("not supported blending function " + srcRgbFactor, "srcRgbFactor");
            }
            if (IsSupportedFunction(srcAlphaFactor) == false)
            {
                throw new ArgumentException("not supported blending function " + srcAlphaFactor, "srcAlphaFactor");
            }
            if (IsSupportedFunction(dstRgbFactor) == false)
            {
                throw new ArgumentException("not supported blending function " + dstRgbFactor, "dstRgbFactor");
            }
            if (IsSupportedFunction(dstAlphaFactor) == false)
            {
                throw new ArgumentException("not supported blending function " + dstAlphaFactor, "dstAlphaFactor");
            }

            // Blend enabled
            mEnabled = true;

            // Store RGB separate equation
            mRgbEquation = rgbEquation;
            // Store alpha separate equation
            mAlphaEquation = alphaEquation;

            // Store rgb separate function
            mRgbSrcFactor = srcRgbFactor;
            mRgbDstFactor = dstRgbFactor;
            // Store alpha separate function
            mAlphaSrcFactor = srcAlphaFactor;
            mAlphaDstFactor = dstAlphaFactor;
            // Store blend color
            mBlendColor = constColor;

            if (EquationSeparated && !GraphicsContext.CurrentCaps.GlExtensions.BlendEquationSeparate_EXT)
            {
                throw new InvalidOperationException("not supported separated blending equations");
            }
            if (FunctionSeparated && !GraphicsContext.CurrentCaps.GlExtensions.BlendFuncSeparate_EXT)
            {
                throw new InvalidOperationException("not supported separated blending functions");
            }
        }
示例#23
0
 public BlendState()
 {
     _alphaBlendFunction    = BlendEquationMode.FuncAdd;
     _alphaDestinationBlend = BlendingFactorDest.Zero;
     _alphaSourceBlend      = BlendingFactorSrc.One;
     _colorBlendFunction    = BlendEquationMode.FuncAdd;
     _colorDestinationBlend = BlendingFactorDest.Zero;
     _colorSourceBlend      = BlendingFactorSrc.One;
     _colorWriteChannels    = ColorWriteChannels.All;
     _blendColor            = new Color4(0, 0, 0, 0);
     _dirty = true;
 }
示例#24
0
        public NiAlphaProperty(NiFile file, BinaryReader reader) : base(file, reader)
        {
            Flags                = reader.ReadUInt16();
            Threshold            = reader.ReadByte();
            AlphaBlendingEnabled = (Flags & 0x01) == 1;

            SourceBlendMode = GetSrc((Flags & 0x1E) >> 1);
            TargetBlendMode = GetTarget((Flags & 0x1E0) >> 5);

            AlphaTestEnabled       = (Flags & 0x200) == 0x200;
            AlphaTestMode          = GetTestMode((Flags & 0x1C00) >> 10);
            DisableTriangleSorting = (Flags & 0x2000) == 0x2000;
        }
示例#25
0
        /// <summary>
        /// Determine whether a blending function is supported.
        /// </summary>
        /// <param name="func"></param>
        /// <returns></returns>
        private static bool IsSupportedFunction(BlendingFactorSrc func)
        {
            switch (func)
            {
            case BlendingFactorSrc.ConstantColor:
            case BlendingFactorSrc.OneMinusConstantColor:
            case BlendingFactorSrc.ConstantAlpha:
            case BlendingFactorSrc.OneMinusConstantAlpha:
                return(GraphicsContext.CurrentCaps.GlExtensions.BlendColor_EXT);

            default:
                return(true);
            }
        }
示例#26
0
        /// <summary>
        /// Sets the blending function to draw with.
        /// </summary>
        /// <param name="src">The source blending factor.</param>
        /// <param name="dest">The destination blending factor.</param>
        public static void SetBlend(BlendingFactorSrc src, BlendingFactorDest dest)
        {
            if (lastSrcBlend == src && lastDestBlend == dest)
            {
                return;
            }

            lastActiveBatch?.Draw();

            GL.BlendFunc(src, dest);

            lastSrcBlend  = src;
            lastDestBlend = dest;
        }
示例#27
0
 /// <summary>
 /// Construct a new BlendType
 /// </summary>
 /// <param name="srcColor">Source RGB factor</param>
 /// <param name="destColor">Destination RGB factor</param>
 /// <param name="srcAlpha">Source alpha factor</param>
 /// <param name="destAlpha">Destination alpha factor</param>
 /// <param name="equationColor">RGB equation</param>
 /// <param name="equationAlpha">Alpha equation</param>
 public BlendType(
     BlendingFactorSrc srcColor, BlendingFactorDest destColor,
     BlendingFactorSrc srcAlpha, BlendingFactorDest destAlpha,
     BlendEquationMode equationColor = BlendEquationMode.FuncAdd,
     BlendEquationMode equationAlpha = BlendEquationMode.FuncAdd
     )
 {
     SrcColor      = srcColor;
     DestColor     = destColor;
     SrcAlpha      = srcAlpha;
     DestAlpha     = destAlpha;
     EquationColor = equationColor;
     EquationAlpha = equationAlpha;
 }
示例#28
0
        private static bool RequiresConstColor(BlendingFactorSrc func)
        {
            switch (func)
            {
            case BlendingFactorSrc.ConstantColor:
            case BlendingFactorSrc.OneMinusConstantColor:
            case BlendingFactorSrc.ConstantAlpha:
            case BlendingFactorSrc.OneMinusConstantAlpha:
                return(true);

            default:
                return(false);
            }
        }
示例#29
0
        public static void SetBlendStates(BlendState state)
        {
            // Set blending mode
            BlendEquationMode blendMode = state.ColorBlendFunction.GetBlendEquationMode();

            GL.BlendEquation(blendMode);

            // Set blending function
            BlendingFactorSrc  bfs = state.ColorSourceBlend.GetBlendFactorSrc();
            BlendingFactorDest bfd = state.ColorDestinationBlend.GetBlendFactorDest();

            GL.BlendFunc(bfs, bfd);

            GL.Enable(EnableCap.Blend);
        }
示例#30
0
        public static void Blending(bool enable = true, BlendingFactorSrc srcFactor = BlendingFactorSrc.SrcAlpha, BlendingFactorDest dstFactor = BlendingFactorDest.OneMinusSrcAlpha)
        {
            if (enable)
            {
                if (!_blendingEnabled)
                {
                    GL.Enable(EnableCap.Blend);
                }
                GL.BlendFunc(srcFactor, dstFactor);
            }
            else if (_blendingEnabled)
            {
                GL.Disable(EnableCap.Blend);
            }

            _blendingEnabled = enable;
        }
示例#31
0
        internal static void SetBlend(BlendingFactorSrc src, BlendingFactorDest dest)
        {
            if (ConfigManager.dDisableBlendingModes)
            {
                return;
            }

            if (lastSrcBlend == src && lastDestBlend == dest)
            {
                return;
            }

            GL.BlendFunc(src, dest);

            lastSrcBlend  = src;
            lastDestBlend = dest;
        }
示例#32
0
 public CacheBlendState(
     bool enabled,
     BlendingFactorSrc colorSource,
     BlendEquationMode colorEquation,
     BlendingFactorDest colorDest,
     BlendingFactorSrc alphaSource,
     BlendEquationMode alphaEquation,
     BlendingFactorDest alphaDest)
 {
     this.Enabled       = enabled;
     this.colorSource   = colorSource;
     this.colorEquation = colorEquation;
     this.colorDest     = colorDest;
     this.alphaSource   = alphaSource;
     this.alphaEquation = alphaEquation;
     this.alphaDest     = alphaDest;
 }
示例#33
0
        public BlendingFactorState(BlendingMode mode)
        {
            switch (mode)
            {
            case BlendingMode.Off:
                enabled = false;
                break;

            case BlendingMode.Alphablend:
                src  = alphaSrc = BlendingFactorSrc.SrcAlpha;
                dest = alphaDest = BlendingFactorDest.OneMinusSrcAlpha;
                break;

            case BlendingMode.Color:
                src       = BlendingFactorSrc.SrcAlpha;
                dest      = BlendingFactorDest.OneMinusSrcAlpha;
                alphaSrc  = BlendingFactorSrc.Zero;
                alphaDest = BlendingFactorDest.One;
                break;

            case BlendingMode.Additive:
                src  = alphaSrc = BlendingFactorSrc.SrcAlpha;
                dest = alphaDest = BlendingFactorDest.One;
                break;

            case BlendingMode.Premultiply:
                src       = BlendingFactorSrc.SrcAlpha;
                dest      = BlendingFactorDest.OneMinusSrcAlpha;
                alphaSrc  = BlendingFactorSrc.One;
                alphaDest = BlendingFactorDest.OneMinusSrcAlpha;
                break;

            case BlendingMode.Premultiplied:
                src  = alphaSrc = BlendingFactorSrc.One;
                dest = alphaDest = BlendingFactorDest.OneMinusSrcAlpha;
                break;
            }
        }
示例#34
0
        /// <summary>
        /// Merge this state with another one.
        /// </summary>
        /// <param name="state">
        /// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state.
        /// </param>
        public override void Merge(IGraphicsState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            BlendState otherState = state as BlendState;

            if (otherState == null)
            {
                throw new ArgumentException("not a BlendState", "state");
            }

            mEnabled        = otherState.mEnabled;
            mRgbEquation    = otherState.mRgbEquation;
            mAlphaEquation  = otherState.mAlphaEquation;
            mRgbSrcFactor   = otherState.mRgbSrcFactor;
            mAlphaSrcFactor = otherState.mAlphaSrcFactor;
            mRgbDstFactor   = otherState.mRgbDstFactor;
            mAlphaDstFactor = otherState.mAlphaDstFactor;
            mBlendColor     = otherState.mBlendColor;
        }
示例#35
0
		/// <summary>
		/// Determine whether a blending function is supported.
		/// </summary>
		/// <param name="func"></param>
		/// <returns></returns>
		private static bool IsSupportedFunction(BlendingFactorSrc func)
		{
			switch (func) {
				case BlendingFactorSrc.ConstantColor:
				case BlendingFactorSrc.OneMinusConstantColor:
				case BlendingFactorSrc.ConstantAlpha:
				case BlendingFactorSrc.OneMinusConstantAlpha:
					return (GraphicsContext.CurrentCaps.GlExtensions.BlendColor_EXT);
				default:
					return (true);
			}
		}
示例#36
0
		internal static extern void glBlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor);
示例#37
0
		private static bool RequiresConstColor(BlendingFactorSrc func)
		{
			switch (func) {
				case BlendingFactorSrc.ConstantColor:
				case BlendingFactorSrc.OneMinusConstantColor:
				case BlendingFactorSrc.ConstantAlpha:
				case BlendingFactorSrc.OneMinusConstantAlpha:
					return (true);
				default:
					return (false);
			}
		}
示例#38
0
 public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
     BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
 {
     return null;
 }
示例#39
0
文件: GL.cs 项目: Wiladams/NewTOAPIA
 public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
 {
     gl.glBlendFunc((int)sfactor, (int)dfactor);
 }
示例#40
0
文件: GLState.cs 项目: Lazzu/Hatzap
        /// <summary>
        /// Set the OpenGL BlendFunc state
        /// </summary>
        /// <param name="src">BlendingFactorSrc</param>
        /// <param name="dst">BlendingFactorDest</param>
        public static void BlendFunc(BlendingFactorSrc src, BlendingFactorDest dst)
        {
            if (!(alphaDst != dst || alphaSrc != src))
                return;

            GL.BlendFunc(src, dst);
            alphaSrc = src;
            alphaDst = dst;
        }
示例#41
0
 public virtual void SetSourceBlendFactor(BlendingFactorSrc aFactor)
 {
     fSrcBlendFactor = aFactor;
     Realize();
 }
示例#42
0
		public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
			BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
		{
			return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest);
		}
示例#43
0
 public void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
 {
     gl.glBlendFunc((int)sfactor, (int)dfactor);
     CheckException();
 }
示例#44
0
		/// <summary>
		/// Construct a BlendState with separated RGB/Alpha functions.
		/// </summary>
		/// <param name="rgbEquation">
		/// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending RGB color components.
		/// </param>
		/// <param name="alphaEquation">
		/// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending Alpha color component.
		/// </param>
		/// <param name="srcRgbFactor">
		/// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to the source color (alpha component excluded).
		/// </param>
		/// <param name="srcAlphaFactor">
		/// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to only the source alpha component.
		/// </param>
		/// <param name="dstRgbFactor">
		/// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to the destination color (alpha component excluded).
		/// </param>
		/// <param name="dstAlphaFactor">
		/// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to only the destination alpha component.
		/// </param>
		public BlendState(BlendEquationModeEXT rgbEquation, BlendEquationModeEXT alphaEquation, BlendingFactorSrc srcRgbFactor, BlendingFactorSrc srcAlphaFactor, BlendingFactorDest dstRgbFactor, BlendingFactorDest dstAlphaFactor)
			: this(rgbEquation, alphaEquation, srcRgbFactor, srcAlphaFactor, dstRgbFactor, dstAlphaFactor, new ColorRGBAF())
		{
			
		}
示例#45
0
			public MyBlendState(bool enabled, BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
				BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
			{
				this.enabled = enabled;
				this.colorSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)colorSource;
				this.colorEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)colorEquation;
				this.colorDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)colorDest;
				this.alphaSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)alphaSource;
				this.alphaEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)alphaEquation;
				this.alphaDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)alphaDest;
			}
示例#46
0
		/// <summary>
		/// Construct a BlendState with separated RGB/Alpha functions.
		/// </summary>
		/// <param name="rgbEquation">
		/// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending RGB color components.
		/// </param>
		/// <param name="alphaEquation">
		/// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending Alpha color component.
		/// </param>
		/// <param name="srcRgbFactor">
		/// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to the source color (alpha component excluded).
		/// </param>
		/// <param name="srcAlphaFactor">
		/// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to only the source alpha component.
		/// </param>
		/// <param name="dstRgbFactor">
		/// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to the destination color (alpha component excluded).
		/// </param>
		/// <param name="dstAlphaFactor">
		/// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to only the destination alpha component.
		/// </param>
		/// <param name="constColor">
		/// A <see cref="ColorRGBAF"/> that specify the constant color used in blending functions.
		/// </param>
		public BlendState(BlendEquationModeEXT rgbEquation, BlendEquationModeEXT alphaEquation, BlendingFactorSrc srcRgbFactor, BlendingFactorSrc srcAlphaFactor, BlendingFactorDest dstRgbFactor, BlendingFactorDest dstAlphaFactor, ColorRGBAF constColor)
		{
			if (IsSupportedEquation(rgbEquation) == false)
				throw new ArgumentException("not supported blending equation " + srcRgbFactor, "rgbEquation");
			if (IsSupportedEquation(alphaEquation) == false)
				throw new ArgumentException("not supported blending equation " + alphaEquation, "rgbEquation");
			if (IsSupportedFunction(srcRgbFactor) == false)
				throw new ArgumentException("not supported blending function " + srcRgbFactor, "srcRgbFactor");
			if (IsSupportedFunction(srcAlphaFactor) == false)
				throw new ArgumentException("not supported blending function " + srcAlphaFactor, "srcAlphaFactor");
			if (IsSupportedFunction(dstRgbFactor) == false)
				throw new ArgumentException("not supported blending function " + dstRgbFactor, "dstRgbFactor");
			if (IsSupportedFunction(dstAlphaFactor) == false)
				throw new ArgumentException("not supported blending function " + dstAlphaFactor, "dstAlphaFactor");

			// Blend enabled
			mEnabled = true;

			// Store RGB separate equation
			mRgbEquation = rgbEquation;
			// Store alpha separate equation
			mAlphaEquation = alphaEquation;

			// Store rgb separate function
			mRgbSrcFactor = srcRgbFactor;
			mRgbDstFactor = dstRgbFactor;
			// Store alpha separate function
			mAlphaSrcFactor = srcAlphaFactor;
			mAlphaDstFactor = dstAlphaFactor;
			// Store blend color
			mBlendColor = constColor;

			if (EquationSeparated && !GraphicsContext.CurrentCaps.GlExtensions.BlendEquationSeparate_EXT)
				throw new InvalidOperationException("not supported separated blending equations");
			if (FunctionSeparated && !GraphicsContext.CurrentCaps.GlExtensions.BlendFuncSeparate_EXT)
				throw new InvalidOperationException("not supported separated blending functions");
		}
示例#47
0
 public GLBlendFunc(GraphicsInterface gi, BlendingFactorSrc srcBlend, BlendingFactorDest dstBlend)
     :base(gi)
 {
     fSrcBlendFactor = srcBlend;
     fDstBlendFactor = dstBlend;
 }
示例#48
0
文件: BlendMode.cs 项目: Dafvid/MCLib
 public BlendMode(BlendingFactorSrc source, BlendingFactorDest destination)
     : this()
 {
     Source = source;
     Destination = destination;
 }
示例#49
0
		/// <summary>
		/// Construct a BlendState with unified RGB/Alpha function.
		/// </summary>
		/// <param name="equation">
		/// A <see cref="BlendEquationModeEXT"/> flag indicating which equation to used for blending.
		/// </param>
		/// <param name="srcFactor">
		/// A <see cref="BlendingFactorSrc"/> that specify the scaling factors applied to the source color (including alpha).
		/// </param>
		/// <param name="dstFactor">
		/// A <see cref="BlendingFactorDest"/> that specify the scaling factors applied to the destination color (including alpha).
		/// </param>
		/// <param name="constColor">
		/// A <see cref="ColorRGBAF"/> that specify the constant color used in blending functions.
		/// </param>
		public BlendState(BlendEquationModeEXT equation, BlendingFactorSrc srcFactor, BlendingFactorDest dstFactor, ColorRGBAF constColor)
			: this(equation, equation, srcFactor, srcFactor, dstFactor, dstFactor, constColor)
		{
			
		}
示例#50
0
		public static void SetBlendMode(BlendingFactorSrc source, BlendingFactorDest destination)
		{
			GL.Enable(EnableCap.Blend);
			GL.BlendFunc(source, destination);
		}
示例#51
0
		/// <summary>
		/// Merge this state with another one.
		/// </summary>
		/// <param name="state">
		/// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state.
		/// </param>
		public override void Merge(IGraphicsState state)
		{
			if (state == null)
				throw new ArgumentNullException("state");

			BlendState otherState = state as BlendState;

			if (otherState == null)
				throw new ArgumentException("not a BlendState", "state");

			mEnabled = otherState.mEnabled;
			mRgbEquation = otherState.mRgbEquation;
			mAlphaEquation = otherState.mAlphaEquation;
			mRgbSrcFactor = otherState.mRgbSrcFactor;
			mAlphaSrcFactor = otherState.mAlphaSrcFactor;
			mRgbDstFactor = otherState.mRgbDstFactor;
			mAlphaDstFactor = otherState.mAlphaDstFactor;
			mBlendColor = otherState.mBlendColor;
		}
示例#52
0
		public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
		{
			Debug.Assert(Delegates.pglBlendFunc != null, "pglBlendFunc not implemented");
			Delegates.pglBlendFunc((Int32)sfactor, (Int32)dfactor);
			CallLog("glBlendFunc({0}, {1})", sfactor, dfactor);
			DebugCheckErrors();
		}
示例#53
0
 public int CreateRenderState(bool enableAlphaBlend = false, bool enableDepthWrite = true, bool enableDepthTest = true, BlendingFactorSrc src = BlendingFactorSrc.Zero, BlendingFactorDest dest = BlendingFactorDest.One, CullFaceMode cullFaceMode = CullFaceMode.Back, bool enableCullFace = true, DepthFunction depthFunction = DepthFunction.Less)
 {
     return RenderSystem.CreateRenderState(enableAlphaBlend, enableDepthWrite, enableDepthTest, src, dest, cullFaceMode, enableCullFace, depthFunction);
 }
示例#54
0
文件: GL.cs 项目: CNCBrasil/agg-sharp
		public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
		{
#if USE_OPENGL
			if (openGlHardwareAvailable)
			{
				OpenTK.Graphics.OpenGL.GL.BlendFunc((OpenTK.Graphics.OpenGL.BlendingFactorSrc)sfactor, (OpenTK.Graphics.OpenGL.BlendingFactorDest)dfactor);
			}
#else
			OpenTK.Graphics.ES11.GL.BlendFunc((OpenTK.Graphics.ES11.All)sfactor, (OpenTK.Graphics.ES11.All)dfactor);
#endif
		}
示例#55
0
		public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
		{
			glBlendFunc deleg = BaseGraphicsContext.Current.Loader.Get<glBlendFunc>();
			if (deleg != null)
				deleg(sfactor, dfactor);
		}
 public static extern void BlendFunc( BlendingFactorSrc sfactor, BlendingFactorDest dfactor );
示例#57
0
		public static void BlendFuncSeparate(BlendingFactorSrc srcRGB, BlendingFactorDest dstRGB, BlendingFactorSrc srcAlpha, BlendingFactorDest dstAlpha)
		{
			glBlendFuncSeparate deleg = BaseGraphicsContext.Current.Loader.Get<glBlendFuncSeparate>();
			if (deleg != null)
				deleg(srcRGB, dstRGB, srcAlpha, dstAlpha);
		}
示例#58
0
 public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor)
 {
     Instance?.BlendFunc(sfactor, dfactor);
 }
示例#59
0
 public void BlendFunc(BlendingFactorSrc src, BlendingFactorDest dest)
 {
     GL.BlendFunc(src, dest);
 }