Show More
Commit Description:
Add missing component and message.
Commit Description:
Add missing component and message.
References:
File last commit:
Show/Diff file:
Action:
FNA/src/Graphics/States/BlendState.cs
242 lines | 3.9 KiB | text/x-csharp | CSharpLexer
242 lines | 3.9 KiB | text/x-csharp | CSharpLexer
r0 | #region License | |||
/* FNA - XNA4 Reimplementation for Desktop Platforms | ||||
r690 | * Copyright 2009-2022 Ethan Lee and the MonoGame Team | |||
r0 | * | |||
* Released under the Microsoft Public License. | ||||
* See LICENSE for details. | ||||
*/ | ||||
#endregion | ||||
namespace Microsoft.Xna.Framework.Graphics | ||||
{ | ||||
public class BlendState : GraphicsResource | ||||
{ | ||||
#region Public Properties | ||||
public BlendFunction AlphaBlendFunction | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.alphaBlendFunction; | ||||
} | ||||
set | ||||
{ | ||||
state.alphaBlendFunction = value; | ||||
} | ||||
r0 | } | |||
public Blend AlphaDestinationBlend | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.alphaDestinationBlend; | ||||
} | ||||
set | ||||
{ | ||||
state.alphaDestinationBlend = value; | ||||
} | ||||
r0 | } | |||
public Blend AlphaSourceBlend | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.alphaSourceBlend; | ||||
} | ||||
set | ||||
{ | ||||
state.alphaSourceBlend = value; | ||||
} | ||||
r0 | } | |||
public BlendFunction ColorBlendFunction | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorBlendFunction; | ||||
} | ||||
set | ||||
{ | ||||
state.colorBlendFunction = value; | ||||
} | ||||
r0 | } | |||
public Blend ColorDestinationBlend | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorDestinationBlend; | ||||
} | ||||
set | ||||
{ | ||||
state.colorDestinationBlend = value; | ||||
} | ||||
r0 | } | |||
public Blend ColorSourceBlend | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorSourceBlend; | ||||
} | ||||
set | ||||
{ | ||||
state.colorSourceBlend = value; | ||||
} | ||||
r0 | } | |||
public ColorWriteChannels ColorWriteChannels | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorWriteEnable; | ||||
} | ||||
set | ||||
{ | ||||
state.colorWriteEnable = value; | ||||
} | ||||
r0 | } | |||
public ColorWriteChannels ColorWriteChannels1 | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorWriteEnable1; | ||||
} | ||||
set | ||||
{ | ||||
state.colorWriteEnable1 = value; | ||||
} | ||||
r0 | } | |||
public ColorWriteChannels ColorWriteChannels2 | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorWriteEnable2; | ||||
} | ||||
set | ||||
{ | ||||
state.colorWriteEnable2 = value; | ||||
} | ||||
r0 | } | |||
public ColorWriteChannels ColorWriteChannels3 | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.colorWriteEnable3; | ||||
} | ||||
set | ||||
{ | ||||
state.colorWriteEnable3 = value; | ||||
} | ||||
r0 | } | |||
public Color BlendFactor | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.blendFactor; | ||||
} | ||||
set | ||||
{ | ||||
state.blendFactor = value; | ||||
} | ||||
r0 | } | |||
public int MultiSampleMask | ||||
{ | ||||
r690 | get | |||
{ | ||||
return state.multiSampleMask; | ||||
} | ||||
set | ||||
{ | ||||
state.multiSampleMask = value; | ||||
} | ||||
r0 | } | |||
#endregion | ||||
#region Public BlendState Presets | ||||
public static readonly BlendState Additive = new BlendState( | ||||
"BlendState.Additive", | ||||
Blend.SourceAlpha, | ||||
Blend.SourceAlpha, | ||||
Blend.One, | ||||
Blend.One | ||||
); | ||||
public static readonly BlendState AlphaBlend = new BlendState( | ||||
"BlendState.AlphaBlend", | ||||
Blend.One, | ||||
Blend.One, | ||||
Blend.InverseSourceAlpha, | ||||
Blend.InverseSourceAlpha | ||||
); | ||||
public static readonly BlendState NonPremultiplied = new BlendState( | ||||
"BlendState.NonPremultiplied", | ||||
Blend.SourceAlpha, | ||||
Blend.SourceAlpha, | ||||
Blend.InverseSourceAlpha, | ||||
Blend.InverseSourceAlpha | ||||
); | ||||
public static readonly BlendState Opaque = new BlendState( | ||||
"BlendState.Opaque", | ||||
Blend.One, | ||||
Blend.One, | ||||
Blend.Zero, | ||||
Blend.Zero | ||||
); | ||||
#endregion | ||||
r690 | #region Internal FNA3D Variables | |||
internal FNA3D.FNA3D_BlendState state; | ||||
#endregion | ||||
r0 | #region Public Constructor | |||
public BlendState() | ||||
{ | ||||
AlphaBlendFunction = BlendFunction.Add; | ||||
AlphaDestinationBlend = Blend.Zero; | ||||
AlphaSourceBlend = Blend.One; | ||||
ColorBlendFunction = BlendFunction.Add; | ||||
ColorDestinationBlend = Blend.Zero; | ||||
ColorSourceBlend = Blend.One; | ||||
ColorWriteChannels = ColorWriteChannels.All; | ||||
ColorWriteChannels1 = ColorWriteChannels.All; | ||||
ColorWriteChannels2 = ColorWriteChannels.All; | ||||
ColorWriteChannels3 = ColorWriteChannels.All; | ||||
BlendFactor = Color.White; | ||||
MultiSampleMask = -1; // AKA 0xFFFFFFFF | ||||
} | ||||
#endregion | ||||
#region Private Constructor | ||||
private BlendState( | ||||
string name, | ||||
Blend colorSourceBlend, | ||||
Blend alphaSourceBlend, | ||||
Blend colorDestBlend, | ||||
Blend alphaDestBlend | ||||
) : this() { | ||||
Name = name; | ||||
ColorSourceBlend = colorSourceBlend; | ||||
AlphaSourceBlend = alphaSourceBlend; | ||||
ColorDestinationBlend = colorDestBlend; | ||||
AlphaDestinationBlend = alphaDestBlend; | ||||
} | ||||
#endregion | ||||
} | ||||
} | ||||