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); }
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); }
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; } }
/// <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); }
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); }
public Blending() { enabled = false; equation = BlendEquationMode.FuncAdd; factorSrc = BlendingFactorSrc.SrcAlpha; factorDest = BlendingFactorDest.OneMinusSrcAlpha; }
public BlendingFactorState(BlendingFactorSrc src, BlendingFactorDest dest, BlendingFactorSrc alphaSrc, BlendingFactorDest alphaDest) { this.src = src; this.dest = dest; this.alphaSrc = alphaSrc; this.alphaDest = alphaDest; }
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); }
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 }
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 static void BlendFunc(BlendingFactorSrc blendingFactorSrc, BlendingFactorDest blendingFactorDest) { if (blendFactorSrc != blendingFactorSrc || blendFactorDest != blendingFactorDest) { blendFactorSrc = blendingFactorSrc; blendFactorDest = blendingFactorDest; GL.BlendFunc(blendingFactorSrc, blendingFactorDest); } }
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); }
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)); }
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 }
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; }
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()) + "}"; }
/// <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"); } }
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; }
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; }
/// <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); } }
/// <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; }
/// <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; }
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); } }
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); }
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; }
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; }
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; }
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; } }
/// <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; }
/// <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); } }
internal static extern void glBlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor);
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); } }
public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest, BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest) { return null; }
public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor) { gl.glBlendFunc((int)sfactor, (int)dfactor); }
/// <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; }
public virtual void SetSourceBlendFactor(BlendingFactorSrc aFactor) { fSrcBlendFactor = aFactor; Realize(); }
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); }
public void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor) { gl.glBlendFunc((int)sfactor, (int)dfactor); CheckException(); }
/// <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()) { }
/// <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"); }
public GLBlendFunc(GraphicsInterface gi, BlendingFactorSrc srcBlend, BlendingFactorDest dstBlend) :base(gi) { fSrcBlendFactor = srcBlend; fDstBlendFactor = dstBlend; }
public BlendMode(BlendingFactorSrc source, BlendingFactorDest destination) : this() { Source = source; Destination = destination; }
/// <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) { }
public static void SetBlendMode(BlendingFactorSrc source, BlendingFactorDest destination) { GL.Enable(EnableCap.Blend); GL.BlendFunc(source, destination); }
/// <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; }
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(); }
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); }
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 );
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); }
public static void BlendFunc(BlendingFactorSrc sfactor, BlendingFactorDest dfactor) { Instance?.BlendFunc(sfactor, dfactor); }
public void BlendFunc(BlendingFactorSrc src, BlendingFactorDest dest) { GL.BlendFunc(src, dest); }