Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
GraphicsAdapterFactory.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;
4 
5 namespace SiliconStudio.Paradox.Graphics
6 {
7  /// <summary>
8  /// Factory for <see cref="GraphicsAdapter"/>.
9  /// </summary>
10  public static partial class GraphicsAdapterFactory
11  {
12  private static readonly object StaticLock = new object();
13  private static ObjectCollector staticCollector = new ObjectCollector();
14  private static bool isInitialized = false;
15  private static GraphicsAdapter[] adapters;
16  private static GraphicsAdapter defaultAdapter;
17 
18  /// <summary>
19  /// Initializes the GraphicsAdapter. On Desktop and WinRT, this is done statically.
20  /// </summary>
21  public static void Initialize()
22  {
23  lock (StaticLock)
24  {
25  if (!isInitialized)
26  {
27  InitializeInternal();
28  isInitialized = true;
29  }
30  }
31  }
32 
33  /// <summary>
34  /// Perform a <see cref="Dispose"/> and <see cref="Initialize"/> to re-initialize all adapters informations.
35  /// </summary>
36  public static void Reset()
37  {
38  lock (StaticLock)
39  {
40  Dispose();
41  Initialize();
42  }
43  }
44 
45  /// <summary>
46  /// Dispose all statically cached value by this instance.
47  /// </summary>
48  public static void Dispose()
49  {
50  lock (StaticLock)
51  {
52  staticCollector.Dispose();
53  adapters = null;
54  defaultAdapter = null;
55  isInitialized = false;
56  }
57  }
58 
59  /// <summary>
60  /// Collection of available adapters on the system.
61  /// </summary>
62  public static GraphicsAdapter[] Adapters
63  {
64  get
65  {
66  lock (StaticLock)
67  {
68  Initialize();
69  return adapters;
70  }
71  }
72 
73  }
74 
75  /// <summary>
76  /// Gets the default adapter. This property can be <c>null</c>.
77  /// </summary>
78  public static GraphicsAdapter Default
79  {
80  get
81  {
82  lock (StaticLock)
83  {
84  Initialize();
85  return defaultAdapter;
86  }
87  }
88  }
89  }
90 }
A struct to dispose IDisposable, IReferencable instances and allocated unmanaged memory.
Use the default mode depending on the type of the field/property.
This class represents a graphics adapter.
static void Initialize()
Initializes the GraphicsAdapter. On Desktop and WinRT, this is done statically.
static void Dispose()
Dispose all statically cached value by this instance.
static void Reset()
Perform a Dispose and Initialize to re-initialize all adapters informations.