Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
PresentationParameters.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 System;
4 using SiliconStudio.Core.Mathematics;
5 
6 namespace SiliconStudio.Paradox.Graphics
7 {
8  /// <summary>
9  /// Describess how data will be displayed to the screen.
10  /// </summary>
11  public class PresentationParameters : IEquatable<PresentationParameters>
12  {
13  #region Fields
14 
15  /// <summary>
16  /// A <strong><see cref="SharpDX.DXGI.Format" /></strong> structure describing the display format.
17  /// </summary>
19 
20  /// <summary>
21  /// A value that describes the resolution height.
22  /// </summary>
23  public int BackBufferHeight;
24 
25  /// <summary>
26  /// A value that describes the resolution width.
27  /// </summary>
28  public int BackBufferWidth;
29 
30  /// <summary>
31  /// Gets or sets the depth stencil format
32  /// </summary>
34 
35  /// <summary>
36  /// A Window object. See remarks.
37  /// </summary>
38  /// <remarks>
39  /// A window object is platform dependent:
40  /// <ul>
41  /// <li>On Windows Desktop: This could a low level window/control handle (IntPtr), or directly a Winform Control object.</li>
42  /// <li>On Windows Metro: This could be SwapChainBackgroundPanel or SwapChainPanel object.</li>
43  /// </ul>
44  /// </remarks>
46 
47  /// <summary>
48  /// Gets or sets a value indicating whether the application is in full screen mode.
49  /// </summary>
50  public bool IsFullScreen;
51 
52  /// <summary>
53  /// Gets or sets a value indicating the number of sample locations during multisampling.
54  /// </summary>
56 
57  /// <summary>
58  /// Gets or sets the maximum rate at which the swap chain's back buffers can be presented to the front buffer.
59  /// </summary>
61 
62  /// <summary>
63  /// A structure describing the refresh rate in hertz
64  /// </summary>
66 
67  /// <summary>
68  /// The output (monitor) index to use when switching to fullscreen mode. Doesn't have any effect when windowed mode is used.
69  /// </summary>
71 
72  #endregion
73 
74  #region Constructors and Destructors
75 
76  /// <summary>
77  /// Initializes a new instance of the <see cref="PresentationParameters" /> class with default values.
78  /// </summary>
80  {
81  BackBufferWidth = 800;
82  BackBufferHeight = 480;
83  BackBufferFormat = PixelFormat.R8G8B8A8_UNorm;
84  PresentationInterval = PresentInterval.Immediate;
85  DepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt;
86  MultiSampleCount = MSAALevel.None;
87  IsFullScreen = false;
88  RefreshRate = new Rational(60, 1); // by default
89  }
90 
91  /// <summary>
92  /// Initializes a new instance of the <see cref="PresentationParameters" /> class with <see cref="PixelFormat.R8G8B8A8_UNorm"/>.
93  /// </summary>
94  /// <param name="backBufferWidth">Width of the back buffer.</param>
95  /// <param name="backBufferHeight">Height of the back buffer.</param>
96  /// <param name="deviceWindowHandle">The device window handle.</param>
97  public PresentationParameters(int backBufferWidth, int backBufferHeight, WindowHandle deviceWindowHandle)
98  : this(backBufferWidth, backBufferHeight, deviceWindowHandle, PixelFormat.R8G8B8A8_UNorm)
99  {
100  }
101 
102  /// <summary>
103  /// Initializes a new instance of the <see cref="PresentationParameters" /> class.
104  /// </summary>
105  /// <param name="backBufferWidth">Width of the back buffer.</param>
106  /// <param name="backBufferHeight">Height of the back buffer.</param>
107  /// <param name="deviceWindowHandle">The device window handle.</param>
108  /// <param name="backBufferFormat">The back buffer format.</param>
109  public PresentationParameters(int backBufferWidth, int backBufferHeight, WindowHandle deviceWindowHandle, PixelFormat backBufferFormat)
110  : this()
111  {
112  BackBufferWidth = backBufferWidth;
113  BackBufferHeight = backBufferHeight;
114  DeviceWindowHandle = deviceWindowHandle;
115  BackBufferFormat = backBufferFormat;
116  }
117 
118  #endregion
119 
120  #region Methods
121 
123  {
124  return (PresentationParameters)MemberwiseClone();
125  }
126 
127  public bool Equals(PresentationParameters other)
128  {
129  if (ReferenceEquals(null, other)) return false;
130  if (ReferenceEquals(this, other)) return true;
131  return BackBufferFormat == other.BackBufferFormat && BackBufferHeight == other.BackBufferHeight && BackBufferWidth == other.BackBufferWidth && DepthStencilFormat == other.DepthStencilFormat && Equals(DeviceWindowHandle, other.DeviceWindowHandle) && IsFullScreen.Equals(other.IsFullScreen) && MultiSampleCount == other.MultiSampleCount && PresentationInterval == other.PresentationInterval && RefreshRate.Equals(other.RefreshRate) && PreferredFullScreenOutputIndex == other.PreferredFullScreenOutputIndex;
132  }
133 
134  public override bool Equals(object obj)
135  {
136  if (ReferenceEquals(null, obj)) return false;
137  if (ReferenceEquals(this, obj)) return true;
138  if (obj.GetType() != this.GetType()) return false;
139  return Equals((PresentationParameters)obj);
140  }
141 
142  public override int GetHashCode()
143  {
144  unchecked
145  {
146  var hashCode = (int)BackBufferFormat;
147  hashCode = (hashCode * 397) ^ BackBufferHeight;
148  hashCode = (hashCode * 397) ^ BackBufferWidth;
149  hashCode = (hashCode * 397) ^ (int)DepthStencilFormat;
150  hashCode = (hashCode * 397) ^ (DeviceWindowHandle != null ? DeviceWindowHandle.GetHashCode() : 0);
151  hashCode = (hashCode * 397) ^ IsFullScreen.GetHashCode();
152  hashCode = (hashCode * 397) ^ (int)MultiSampleCount;
153  hashCode = (hashCode * 397) ^ (int)PresentationInterval;
154  hashCode = (hashCode * 397) ^ RefreshRate.GetHashCode();
155  hashCode = (hashCode * 397) ^ PreferredFullScreenOutputIndex;
156  return hashCode;
157  }
158  }
159 
160  public static bool operator ==(PresentationParameters left, PresentationParameters right)
161  {
162  return Equals(left, right);
163  }
164 
165  public static bool operator !=(PresentationParameters left, PresentationParameters right)
166  {
167  return !Equals(left, right);
168  }
169 
170  #endregion
171  }
172 }
173 
int PreferredFullScreenOutputIndex
The output (monitor) index to use when switching to fullscreen mode. Doesn't have any effect when win...
PresentationParameters(int backBufferWidth, int backBufferHeight, WindowHandle deviceWindowHandle, PixelFormat backBufferFormat)
Initializes a new instance of the PresentationParameters class.
A platform specific window handle.
Rational RefreshRate
A structure describing the refresh rate in hertz
MSAALevel
Multisample count level.
Definition: MSAALevel.cs:29
int BackBufferWidth
A value that describes the resolution width.
int BackBufferHeight
A value that describes the resolution height.
WindowHandle DeviceWindowHandle
A Window object. See remarks.
PixelFormat BackBufferFormat
A SharpDX.DXGI.Format structure describing the display format.
PresentationParameters(int backBufferWidth, int backBufferHeight, WindowHandle deviceWindowHandle)
Initializes a new instance of the PresentationParameters class with PixelFormat.R8G8B8A8_UNorm.
PresentInterval PresentationInterval
Gets or sets the maximum rate at which the swap chain's back buffers can be presented to the front bu...
PresentInterval
Defines flags that describe the relationship between the adapter refresh rate and the rate at which P...
MSAALevel MultiSampleCount
Gets or sets a value indicating the number of sample locations during multisampling.
PixelFormat DepthStencilFormat
Gets or sets the depth stencil format
PresentationParameters()
Initializes a new instance of the PresentationParameters class with default values.
bool IsFullScreen
Gets or sets a value indicating whether the application is in full screen mode.
PixelFormat
Defines various types of pixel formats.
Definition: PixelFormat.cs:32
Describess how data will be displayed to the screen.