Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
RasterizerState.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.ReferenceCounting;
4 using SiliconStudio.Core.Serialization.Contents;
5 
6 namespace SiliconStudio.Paradox.Graphics
7 {
8  [ContentSerializer(typeof(RasterizerStateSerializer))]
9  public partial class RasterizerState : GraphicsResourceBase
10  {
11  // For FakeRasterizerState.
12  protected RasterizerState()
13  {
14  }
15 
16  // For FakeRasterizerState.
18  {
19  Description = description;
20  }
21 
22  /// <summary>
23  /// Gets the rasterizer state description.
24  /// </summary>
26 
27  /// <summary>
28  /// Initializes a new instance of the <see cref="IRasterizerState"/> class.
29  /// </summary>
30  /// <param name="graphicsDevice">The graphics device.</param>
31  /// <param name="rasterizerStateDescription">The rasterizer state description.</param>
32  public static RasterizerState New(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
33  {
34  RasterizerState rasterizerState;
35  lock (graphicsDevice.CachedRasterizerStates)
36  {
37  if (graphicsDevice.CachedRasterizerStates.TryGetValue(rasterizerStateDescription, out rasterizerState))
38  {
39  // TODO: Appropriate destroy
40  rasterizerState.AddReferenceInternal();
41  }
42  else
43  {
44  rasterizerState = new RasterizerState(graphicsDevice, rasterizerStateDescription);
45  graphicsDevice.CachedRasterizerStates.Add(rasterizerStateDescription, rasterizerState);
46  }
47  }
48  return rasterizerState;
49  }
50 
51  protected override void Destroy()
52  {
53  lock (GraphicsDevice.CachedRasterizerStates)
54  {
55  GraphicsDevice.CachedRasterizerStates.Remove(Description);
56  }
57 
58  base.Destroy();
59  }
60  }
61 }
override void Destroy()
Disposes of object resources.
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.
readonly RasterizerStateDescription Description
Gets the rasterizer state description.
static RasterizerState New(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
Initializes a new instance of the IRasterizerState class.
RasterizerState(RasterizerStateDescription description)