Exemplo n.º 1
0
        internal static BlendOperation BlendOperationFromOgl(BlendEquationMode bom)
        {
            switch (bom)
            {
            case BlendEquationMode.FuncAdd:
                return(BlendOperation.Add);

                break;

            case BlendEquationMode.Min:
                return(BlendOperation.Minimum);

                break;

            case BlendEquationMode.Max:
                return(BlendOperation.Maximum);

                break;

            case BlendEquationMode.FuncSubtract:
                return(BlendOperation.Subtract);

                break;

            case BlendEquationMode.FuncReverseSubtract:
                return(BlendOperation.ReverseSubtract);

                break;

            default:
                throw new ArgumentOutOfRangeException("bom");
            }
        }
Exemplo n.º 2
0
 public static void BlendEquationOES(BlendEquationMode mode)
 {
     Debug.Assert(Delegates.pglBlendEquationOES != null, "pglBlendEquationOES not implemented");
     Delegates.pglBlendEquationOES((Int32)mode);
     LogCommand("glBlendEquationOES", null, mode);
     DebugCheckErrors(null);
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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;
 }
 public static void BlendEquationSeparateOES(BlendEquationMode modeRGB, BlendEquationMode modeAlpha)
 {
     Debug.Assert(Delegates.pglBlendEquationSeparateOES != null, "pglBlendEquationSeparateOES not implemented");
     Delegates.pglBlendEquationSeparateOES((int)modeRGB, (int)modeAlpha);
     LogCommand("glBlendEquationSeparateOES", null, modeRGB, modeAlpha);
     DebugCheckErrors(null);
 }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="enabled"></param>
 /// <param name="sourceFactor"></param>
 /// <param name="destinationFactor"></param>
 /// <param name="blendingEquationRgb"></param>
 /// <param name="blendingEquationAlpha"></param>
 public AlphaBlendSettings(bool enabled, BlendingFactor sourceFactor, BlendingFactor destinationFactor,
                           BlendEquationMode blendingEquationRgb, BlendEquationMode blendingEquationAlpha)
 {
     this.enabled               = enabled;
     this.sourceFactor          = sourceFactor;
     this.destinationFactor     = destinationFactor;
     this.blendingEquationRgb   = blendingEquationRgb;
     this.blendingEquationAlpha = blendingEquationAlpha;
 }
Exemplo n.º 12
0
        internal static BlendOp Convert(BlendEquationMode blendOp)
        {
            if (!blendOps.ContainsValue(blendOp))
            {
                throw new NotSupportedException("blend is not supported");
            }

            return(blendOps.First((f) => f.Value == blendOp).Key);
        }
Exemplo n.º 13
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;
 }
 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));
 }
Exemplo n.º 15
0
 /// <summary>
 /// specify pixel arithmetic for RGB and alpha components separately.
 /// </summary>
 /// <param name="rgbMode">set the RGB blend equation.</param>
 /// <param name="alphaMode">set the Alpha blend equation.</param>
 /// <param name="rgbSrcFactor">Specifies how the red, green and blue source blending factors are computedThe initial value is GL_ONE.</param>
 /// <param name="rgbDestFactor">Specifies how the red, green and blue destination blending factors are computed. The initial value is GL_ZERO.</param>
 /// <param name="alphaSrcFactor">Specifies how the alpha source blending factors are computed. The initial value is GL_ONE.</param>
 /// <param name="alphaDestFactor">Specifies how the alpha destination blending factors are computed. The initial value is GL_ZERO.</param>
 /// <param name="enableCapacity"></param>
 public BlendSwitch(BlendEquationMode rgbMode, BlendEquationMode alphaMode, BlendSrcFactor rgbSrcFactor, BlendDestFactor rgbDestFactor, BlendSrcFactor alphaSrcFactor, BlendDestFactor alphaDestFactor, bool enableCapacity = true)
     : base(GL.GL_BLEND, enableCapacity)
 {
     this.RGBMode         = rgbMode;
     this.AlphaMode       = alphaMode;
     this.RGBSrcFactor    = rgbSrcFactor;
     this.RGBDestFactor   = rgbDestFactor;
     this.AlphaSrcFactor  = alphaSrcFactor;
     this.AlphaDestFactor = alphaDestFactor;
 }
Exemplo n.º 16
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;
 }
 private BlendOperation ConvertBlendOp(BlendEquationMode glMode)
 {
     return(glMode switch
     {
         BlendEquationMode.FuncAdd => BlendOperation.Add,
         BlendEquationMode.FuncSubtract => BlendOperation.Subtract,
         BlendEquationMode.Max => BlendOperation.Maximum,
         BlendEquationMode.Min => BlendOperation.Minimum,
         BlendEquationMode.FuncReverseSubtract => BlendOperation.ReverseSubtract,
         _ => throw new ArgumentOutOfRangeException()
     });
Exemplo n.º 18
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;
 }
Exemplo n.º 19
0
        /// <summary>
        /// Construct a BlendState with separated RGB/Alpha functions.
        /// </summary>
        /// <param name="rgbEquation">
        /// A <see cref="BlendEquationMode"/> flag indicating which equation to used for blending RGB color components.
        /// </param>
        /// <param name="alphaEquation">
        /// A <see cref="BlendEquationMode"/> flag indicating which equation to used for blending Alpha color component.
        /// </param>
        /// <param name="srcRgbFactor">
        /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to the source color (alpha component excluded).
        /// </param>
        /// <param name="srcAlphaFactor">
        /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to only the source alpha component.
        /// </param>
        /// <param name="dstRgbFactor">
        /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to the destination color (alpha component excluded).
        /// </param>
        /// <param name="dstAlphaFactor">
        /// A <see cref="BlendingFactor"/> 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(BlendEquationMode rgbEquation, BlendEquationMode alphaEquation, BlendingFactor srcRgbFactor, BlendingFactor srcAlphaFactor, BlendingFactor dstRgbFactor, BlendingFactor 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
            _Enabled = true;

            // Store RGB separate equation
            _RgbEquation = rgbEquation;
            // Store alpha separate equation
            _AlphaEquation = alphaEquation;

            // Store rgb separate function
            _RgbSrcFactor = srcRgbFactor;
            _RgbDstFactor = dstRgbFactor;
            // Store alpha separate function
            _AlphaSrcFactor = srcAlphaFactor;
            _AlphaDstFactor = dstAlphaFactor;
            // Store blend color
            _BlendColor = constColor;

            if (EquationSeparated && !Gl.CurrentExtensions.BlendEquationSeparate_EXT)
            {
                throw new InvalidOperationException("not supported separated blending equations");
            }
            if (FunctionSeparated && !Gl.CurrentExtensions.BlendFuncSeparate_EXT)
            {
                throw new InvalidOperationException("not supported separated blending functions");
            }
        }
Exemplo n.º 20
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;
 }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Determine whether a blending function is supported.
        /// </summary>
        /// <param name="equation"></param>
        /// <returns></returns>
        private static bool IsSupportedEquation(BlendEquationMode equation)
        {
            switch (equation)
            {
            case BlendEquationMode.Min:
            case BlendEquationMode.Max:
                return(Gl.CurrentExtensions.BlendMinmax_EXT);                                                   // XXX Use GraphicsContext

            case BlendEquationMode.FuncSubtract:
            case BlendEquationMode.FuncReverseSubtract:
                return(Gl.CurrentExtensions.BlendSubtract_EXT);                                                 // XXX Use GraphicsContext

            default:
                return(true);
            }
        }
Exemplo n.º 23
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;
 }
Exemplo n.º 24
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");
            }

            _Enabled        = otherState._Enabled;
            _RgbEquation    = otherState._RgbEquation;
            _AlphaEquation  = otherState._AlphaEquation;
            _RgbSrcFactor   = otherState._RgbSrcFactor;
            _AlphaSrcFactor = otherState._AlphaSrcFactor;
            _RgbDstFactor   = otherState._RgbDstFactor;
            _AlphaDstFactor = otherState._AlphaDstFactor;
            _BlendColor     = otherState._BlendColor;
        }
Exemplo n.º 25
0
 public static void BlendEquation(BlendEquationMode mode)
 {
     ES20.GL.BlendEquation(mode);
     CheckError();
 }
Exemplo n.º 26
0
 public BlendingEquationState(BlendEquationMode colorMode, BlendEquationMode alphaMode)
 {
     this.colorMode = colorMode;
     this.alphaMode = alphaMode;
 }
Exemplo n.º 27
0
 public BlendingEquationState(BlendEquationMode mode)
 {
     colorMode = alphaMode = mode;
 }
 internal static BlendOperation BlendOperationFromOgl(BlendEquationMode bom)
 {
     switch (bom)
     {
         case BlendEquationMode.FuncAdd:
             return BlendOperation.Add;
         case BlendEquationMode.Min:
             return BlendOperation.Minimum;
         case BlendEquationMode.Max:
             return BlendOperation.Maximum;
         case BlendEquationMode.FuncSubtract:
             return BlendOperation.Subtract;
         case BlendEquationMode.FuncReverseSubtract:
             return BlendOperation.ReverseSubtract;
         default:
             throw new ArgumentOutOfRangeException("bom");
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// Sets  the equation used for both the RGB blend equation and the Alpha blend equation
 /// </summary>
 /// <param name="buf">specifies the index of the draw buffer for which to set the blend equation.</param>
 /// <param name="mode">specifies how source and destination colors are combined. It must be GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MIN, GL_MAX.</param>
 /// <remarks>
 /// The blend equations determine how a new pixel (the ''source'' color) is combined with a pixel already in the framebuffer (the ''destination'' color). This function sets both the RGB blend equation and the alpha blend equation to a single equation. glBlendEquationi specifies the blend equation for a single draw buffer whereas glBlendEquation sets the blend equation for all draw buffers.
 /// </remarks>
 public static void BlendEquationi(uint buf, BlendEquationMode mode)
 {
     Delegates.glBlendEquationi(buf, mode);
 }
Exemplo n.º 30
0
 public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
                                     BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
 {
     return(null);
 }
Exemplo n.º 31
0
 public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
     BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
 {
     return null;
 }
Exemplo n.º 32
0
 public static void BlendEquation(BlendEquationMode mode)
 {
     Delegates.glBlendEquation(mode);
 }
Exemplo n.º 33
0
 /// <summary>
 /// Construct a BlendState with separated RGB/Alpha functions.
 /// </summary>
 /// <param name="rgbEquation">
 /// A <see cref="BlendEquationMode"/> flag indicating which equation to used for blending RGB color components.
 /// </param>
 /// <param name="alphaEquation">
 /// A <see cref="BlendEquationMode"/> flag indicating which equation to used for blending Alpha color component.
 /// </param>
 /// <param name="srcRgbFactor">
 /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to the source color (alpha component excluded).
 /// </param>
 /// <param name="srcAlphaFactor">
 /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to only the source alpha component.
 /// </param>
 /// <param name="dstRgbFactor">
 /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to the destination color (alpha component excluded).
 /// </param>
 /// <param name="dstAlphaFactor">
 /// A <see cref="BlendingFactor"/> that specify the scaling factors applied to only the destination alpha component.
 /// </param>
 public BlendState(BlendEquationMode rgbEquation, BlendEquationMode alphaEquation, BlendingFactor srcRgbFactor, BlendingFactor srcAlphaFactor, BlendingFactor dstRgbFactor, BlendingFactor dstAlphaFactor) :
     this(rgbEquation, alphaEquation, srcRgbFactor, srcAlphaFactor, dstRgbFactor, dstAlphaFactor, new ColorRGBAF())
 {
 }
 /// <summary>
 /// set the RGBA blend equation.
 /// </summary>
 /// <param name="rgbMode">set the RGB blend equation.</param>
 /// <param name="alphaMode">set the Alpha blend equation.</param>
 /// <param name="enableCapacity"></param>
 public BlendEquationSeprateSwitch(BlendEquationMode rgbMode, BlendEquationMode alphaMode, bool enableCapacity = true)
     : base(GL.GL_BLEND, enableCapacity)
 {
     this.RGBMode   = rgbMode;
     this.AlphaMode = alphaMode;
 }
Exemplo n.º 35
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;
			}
Exemplo n.º 36
0
 public void Reset()
 {
     EquationMode      = BlendEquationMode.FuncAdd;
     SourceFactor      = BlendingFactorSrc.One;
     DestinationFactor = BlendingFactorDest.One;
 }
Exemplo n.º 37
0
		public static void BlendEquation (BlendEquationMode blend)
		{
			blendEquation = blend;
		}
Exemplo n.º 38
0
 /// <summary>
 /// set the RGBA blend equation.
 /// </summary>
 /// <param name="mode">set the RGBA blend equation.</param>
 /// <param name="enableCapacity"></param>
 public BlendEquationSwitch(BlendEquationMode mode, bool enableCapacity = true)
     : base(GL.GL_BLEND, enableCapacity)
 {
     this.Mode = mode;
 }
Exemplo n.º 39
0
		public static void BlendEquationSeparate(BlendEquationMode modeRGB, BlendEquationMode modeAlpha)
		{
			glBlendEquationSeparate deleg = BaseGraphicsContext.Current.Loader.Get<glBlendEquationSeparate>();
			if (deleg != null)
				deleg(modeRGB, modeAlpha);
		}
Exemplo n.º 40
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);
		}
Exemplo n.º 41
0
 public static void BlendEquation(BlendEquationMode mode)
 {
     Delegates.glBlendEquation(mode);
 }
Exemplo n.º 42
0
		public static void BlendEquation(BlendEquationMode mode)
		{
			glBlendEquation deleg = BaseGraphicsContext.Current.Loader.Get<glBlendEquation>();
			if (deleg != null)
				deleg(mode);
		}