Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
BlendState.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using SiliconStudio.Core.Mathematics;
4 using SiliconStudio.Core.ReferenceCounting;
5 using SiliconStudio.Core.Serialization.Contents;
6 
7 namespace SiliconStudio.Paradox.Graphics
8 {
9  /// <summary>
10  /// Describes a blend state.
11  /// </summary>
12  [ContentSerializer(typeof(BlendStateSerializer))]
13  public partial class BlendState : GraphicsResourceBase
14  {
15  // For FakeBlendState.
16  protected BlendState()
17  {
18  }
19 
20  // For FakeBlendState.
21  protected BlendState(BlendStateDescription description)
22  {
23  Description = description;
24  }
25 
26  /// <summary>
27  /// Initializes a new instance of the <see cref="BlendState"/> class.
28  /// </summary>
29  /// <param name="graphicsDevice">The graphics device.</param>
30  /// <param name="blendStateDescription">The blend state description.</param>
31  public static BlendState New(GraphicsDevice graphicsDevice, BlendStateDescription blendStateDescription)
32  {
33  BlendState blendState;
34  lock (graphicsDevice.CachedBlendStates)
35  {
36  if (graphicsDevice.CachedBlendStates.TryGetValue(blendStateDescription, out blendState))
37  {
38  // TODO: Appropriate destroy
39  blendState.AddReferenceInternal();
40  }
41  else
42  {
43  blendState = new BlendState(graphicsDevice, blendStateDescription);
44  graphicsDevice.CachedBlendStates.Add(blendStateDescription, blendState);
45  }
46  }
47  return blendState;
48  }
49 
50  protected override void Destroy()
51  {
52  lock (GraphicsDevice.CachedBlendStates)
53  {
54  GraphicsDevice.CachedBlendStates.Remove(Description);
55  }
56 
57  base.Destroy();
58  }
59 
60  /// <summary>
61  /// Gets the blend state description.
62  /// </summary>
64 
65  /// <summary>
66  /// Gets or sets the four-component (RGBA) blend factor for alpha blending.
67  /// </summary>
69 
70  /// <summary>
71  /// Gets or sets a bitmask which defines which samples can be written during multisampling. The default is 0xffffffff.
72  /// </summary>
73  public int MultiSampleMask;
74  }
75 }
BlendState(BlendStateDescription description)
Definition: BlendState.cs:21
Color4 BlendFactor
Gets or sets the four-component (RGBA) blend factor for alpha blending.
Definition: BlendState.cs:68
Represents a color in the form of rgba.
Definition: Color4.cs:42
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
int MultiSampleMask
Gets or sets a bitmask which defines which samples can be written during multisampling. The default is 0xffffffff.
Definition: BlendState.cs:73
static BlendState New(GraphicsDevice graphicsDevice, BlendStateDescription blendStateDescription)
Initializes a new instance of the BlendState class.
Definition: BlendState.cs:31
override void Destroy()
Disposes of object resources.
Definition: BlendState.cs:50
readonly BlendStateDescription Description
Gets the blend state description.
Definition: BlendState.cs:63