From 72687732f1c0a9f91810c81e923d38f3aac39416 Mon Sep 17 00:00:00 2001
From: Maniekko <157877453+Maniekko@users.noreply.github.com>
Date: Fri, 22 Mar 2024 20:58:27 +0300
Subject: [PATCH 1/2] XML documentation for Graphics-related classes omg
---
MonoGame.Framework/Graphics/GraphicsDevice.cs | 281 ++++++++++++++----
.../Graphics/GraphicsResource.cs | 32 +-
MonoGame.Framework/GraphicsDeviceManager.cs | 13 +
3 files changed, 270 insertions(+), 56 deletions(-)
diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.cs b/MonoGame.Framework/Graphics/GraphicsDevice.cs
index 8159e9cd0cb..a245666f347 100644
--- a/MonoGame.Framework/Graphics/GraphicsDevice.cs
+++ b/MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -11,7 +11,11 @@
namespace Microsoft.Xna.Framework.Graphics
-{
+{
+ ///
+ /// Performs primitive-based rendering, creates resources,
+ /// handles system-level variables, adjusts gamma ramp levels, and creates shaders.
+ ///
public partial class GraphicsDevice : IDisposable
{
///
@@ -85,13 +89,27 @@ public partial class GraphicsDevice : IDisposable
private readonly RenderTargetBinding[] _tempRenderTargetBinding = new RenderTargetBinding[1];
internal GraphicsCapabilities GraphicsCapabilities { get; private set; }
-
+
+ ///
+ /// Gets the collection of vertex textures that support texture lookup
+ /// in the vertex shader using the texldl statement.
+ /// The vertex engine contains four texture sampler stages.
+ ///
public TextureCollection VertexTextures { get; private set; }
-
+
+ ///
+ /// Returns the collection of vertex sampler states.
+ ///
public SamplerStateCollection VertexSamplerStates { get; private set; }
-
+
+ ///
+ /// Returns the collection of textures that have been assigned to the texture stages of the device.
+ ///
public TextureCollection Textures { get; private set; }
-
+
+ ///
+ /// Retrieves a collection of objects for the current .
+ ///
public SamplerStateCollection SamplerStates { get; private set; }
///
@@ -136,14 +154,34 @@ private bool PixelShaderDirty
// Use WeakReference for the global resources list as we do not know when a resource
// may be disposed and collected. We do not want to prevent a resource from being
// collected by holding a strong reference to it in this list.
- private readonly List _resources = new List();
-
- // TODO Graphics Device events need implementing
- public event EventHandler DeviceLost;
- public event EventHandler DeviceReset;
- public event EventHandler DeviceResetting;
- public event EventHandler ResourceCreated;
- public event EventHandler ResourceDestroyed;
+ private readonly List _resources = new List();
+
+ // TODO Graphics Device events need implementing
+ ///
+ /// Occurs when a GraphicsDevice is about to be lost (for example, immediately before a reset).
+ ///
+ public event EventHandler DeviceLost;
+ ///
+ /// Occurs after a GraphicsDevice is reset, allowing an application to recreate all resources.
+ ///
+ public event EventHandler DeviceReset;
+ ///
+ /// Occurs when a GraphicsDevice is resetting,
+ /// allowing the application to cancel the default handling of the reset.
+ ///
+ public event EventHandler DeviceResetting;
+ ///
+ /// Occurs when a resource is created.
+ ///
+ public event EventHandler ResourceCreated;
+ ///
+ /// Occurs when a resource is destroyed.
+ ///
+ public event EventHandler ResourceDestroyed;
+ ///
+ /// Occurs when is called
+ /// or when this object is finalized and collected by the garbage collector.
+ ///
public event EventHandler Disposing;
internal event EventHandler PresentationChanged;
@@ -151,7 +189,10 @@ private bool PixelShaderDirty
private int _maxVertexBufferSlots;
internal int MaxTextureSlots;
internal int MaxVertexTextureSlots;
-
+
+ ///
+ /// Gets a value that indicates whether the object is disposed.
+ ///
public bool IsDisposed
{
get
@@ -159,7 +200,10 @@ public bool IsDisposed
return _isDisposed;
}
}
-
+
+ ///
+ /// Gets a value that indicates whether the associated content was lost.
+ ///
public bool IsContentLost {
get {
// We will just return IsDisposed for now
@@ -185,7 +229,10 @@ internal DepthFormat ActiveDepthFormat
: PresentationParameters.DepthStencilFormat;
}
}
-
+
+ ///
+ /// Gets the graphics adapter.
+ ///
public GraphicsAdapter Adapter
{
get;
@@ -323,7 +370,8 @@ private void Setup()
EffectCache = new Dictionary();
}
-
+
+ ///
~GraphicsDevice()
{
Dispose(false);
@@ -387,7 +435,11 @@ internal void Initialize()
// Set the default render target.
ApplyRenderTargets(null);
}
-
+
+ ///
+ /// Gets or sets rasterizer state.
+ /// The default value is .
+ ///
public RasterizerState RasterizerState
{
get
@@ -445,7 +497,11 @@ public Color BlendFactor
_blendFactorDirty = true;
}
}
-
+
+ ///
+ /// Gets or sets a system-defined instance of a blend state object initialized for alpha blending.
+ /// The default value is .
+ ///
public BlendState BlendState
{
get { return _blendState; }
@@ -486,7 +542,11 @@ public BlendState BlendState
_blendStateDirty = true;
}
}
-
+
+ ///
+ /// Gets or sets a system-defined instance of a depth-stencil state object.
+ /// The default value is .
+ ///
public DepthStencilState DepthStencilState
{
get { return _depthStencilState; }
@@ -539,7 +599,11 @@ internal void ApplyState(bool applyShaders)
PlatformApplyState(applyShaders);
}
-
+
+ ///
+ /// Clears resource buffers.
+ ///
+ /// Set this color value in all buffers.
public void Clear(Color color)
{
var options = ClearOptions.Target;
@@ -552,7 +616,12 @@ public void Clear(Color color)
_graphicsMetrics._clearCount++;
}
}
-
+
+ ///
+ /// Set this color value in all buffers.
+ /// Options for clearing a buffer.
+ /// Set this depth value in the buffer.
+ /// Set this stencil value in the buffer.
public void Clear(ClearOptions options, Color color, float depth, int stencil)
{
PlatformClear(options, color.ToVector4(), depth, stencil);
@@ -561,9 +630,10 @@ public void Clear(ClearOptions options, Color color, float depth, int stencil)
{
_graphicsMetrics._clearCount++;
}
- }
-
- public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
+ }
+
+ ///
+ public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
{
PlatformClear(options, color, depth, stencil);
@@ -572,13 +642,15 @@ public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
_graphicsMetrics._clearCount++;
}
}
-
+
+ ///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
-
+
+ ///
protected virtual void Dispose(bool disposing)
{
if (!_isDisposed)
@@ -642,7 +714,12 @@ internal void RemoveResourceReference(WeakReference resourceReference)
_resources.Remove(resourceReference);
}
}
-
+
+ ///
+ /// Presents the display with the contents of the next buffer
+ /// in the sequence of back buffers owned by the .
+ ///
+ /// A render target is active.
public void Present()
{
// We cannot present with a RT set on the device.
@@ -661,7 +738,10 @@ public void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle,
*/
partial void PlatformReset();
-
+
+ ///
+ /// Resets the presentation parameters for the current .
+ ///
public void Reset()
{
PlatformReset();
@@ -674,7 +754,14 @@ public void Reset()
EventHelpers.Raise(this, PresentationChanged, new PresentationEventArgs(PresentationParameters));
EventHelpers.Raise(this, DeviceReset, EventArgs.Empty);
}
-
+
+ ///
+ /// Resets the current with the specified .
+ ///
+ /// Presentation parameters to set.
+ ///
+ /// is
+ ///
public void Reset(PresentationParameters presentationParameters)
{
if (presentationParameters == null)
@@ -714,7 +801,10 @@ internal void OnDeviceReset()
{
EventHelpers.Raise(this, DeviceReset, EventArgs.Empty);
}
-
+
+ ///
+ /// Retrieves the display mode's spatial resolution, color resolution, and refresh frequency.
+ ///
public DisplayMode DisplayMode
{
get
@@ -722,7 +812,10 @@ public DisplayMode DisplayMode
return Adapter.CurrentDisplayMode;
}
}
-
+
+ ///
+ /// Retrieves the status of the device.
+ ///
public GraphicsDeviceStatus GraphicsDeviceStatus
{
get
@@ -730,13 +823,19 @@ public GraphicsDeviceStatus GraphicsDeviceStatus
return GraphicsDeviceStatus.Normal;
}
}
-
+
+ ///
+ /// Gets the presentation parameters associated with this graphics device.
+ ///
public PresentationParameters PresentationParameters
{
get;
private set;
}
-
+
+ ///
+ /// Gets or sets a viewport identifying the portion of the render target to receive draw calls.
+ ///
public Viewport Viewport
{
get
@@ -751,12 +850,19 @@ public Viewport Viewport
}
}
- private readonly GraphicsProfile _graphicsProfile;
+ private readonly GraphicsProfile _graphicsProfile;
+ ///
+ /// Gets the graphics profile.
+ /// The default value is .
+ ///
public GraphicsProfile GraphicsProfile
{
get { return _graphicsProfile; }
}
-
+
+ ///
+ /// Gets or sets the rectangle used for scissor testing. By default, the size matches the render target size.
+ ///
public Rectangle ScissorRectangle
{
get
@@ -773,7 +879,10 @@ public Rectangle ScissorRectangle
_scissorRectangleDirty = true;
}
}
-
+
+ ///
+ /// Gets the amount of render targets bound to this device.
+ ///
public int RenderTargetCount
{
get
@@ -781,7 +890,14 @@ public int RenderTargetCount
return _currentRenderTargetCount;
}
}
-
+
+ ///
+ /// Sets a new render target for this .
+ ///
+ ///
+ /// A new render target for the device, or
+ /// to set the device render target to the back buffer of the device.
+ ///
public void SetRenderTarget(RenderTarget2D renderTarget)
{
if (renderTarget == null)
@@ -794,7 +910,10 @@ public void SetRenderTarget(RenderTarget2D renderTarget)
SetRenderTargets(_tempRenderTargetBinding);
}
}
-
+
+ ///
+ ///
+ /// The cube map face type.
public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
{
if (renderTarget == null)
@@ -807,7 +926,11 @@ public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFa
SetRenderTargets(_tempRenderTargetBinding);
}
}
-
+
+ ///
+ /// Sets an array of render targets.
+ ///
+ /// An array of render targets.
public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{
// Avoid having to check for null and zero length.
@@ -905,7 +1028,11 @@ internal void ApplyRenderTargets(RenderTargetBinding[] renderTargets)
if (clearTarget)
Clear(DiscardColor);
}
-
+
+ ///
+ /// Gets render target surfaces.
+ ///
+ /// An array of bound render targets.
public RenderTargetBinding[] GetRenderTargets()
{
// Return a correctly sized copy our internal array.
@@ -913,20 +1040,38 @@ public RenderTargetBinding[] GetRenderTargets()
Array.Copy(_currentRenderTargetBindings, bindings, _currentRenderTargetCount);
return bindings;
}
-
+
+ ///
+ /// Gets render target surfaces.
+ ///
+ ///
+ /// When this method returns, contains an array of that description of bound render targets.
+ /// This parameter is treated as uninitialized.
+ ///
public void GetRenderTargets(RenderTargetBinding[] outTargets)
{
Debug.Assert(outTargets.Length == _currentRenderTargetCount, "Invalid outTargets array length!");
Array.Copy(_currentRenderTargetBindings, outTargets, _currentRenderTargetCount);
}
-
+
+ ///
+ /// Sets or binds a vertex buffer to a device.
+ ///
+ /// A vertex buffer.
public void SetVertexBuffer(VertexBuffer vertexBuffer)
{
_vertexBuffersDirty |= (vertexBuffer == null)
? _vertexBuffers.Clear()
: _vertexBuffers.Set(vertexBuffer, 0);
}
-
+
+ ///
+ ///
+ /// The offset (in bytes) from the beginning of the buffer.
+ ///
+ /// is less than 0
+ /// OR is greater than or equal to .VertexCount.
+ ///
public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
{
// Validate vertexOffset.
@@ -941,7 +1086,14 @@ public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
? _vertexBuffers.Clear()
: _vertexBuffers.Set(vertexBuffer, vertexOffset);
}
-
+
+ ///
+ /// Sets the vertex buffers.
+ ///
+ /// An array of vertex buffers.
+ ///
+ /// Length of is more than max allowed number of vertex buffers.
+ ///
public void SetVertexBuffers(params VertexBufferBinding[] vertexBuffers)
{
if (vertexBuffers == null || vertexBuffers.Length == 0)
@@ -968,7 +1120,10 @@ private void SetIndexBuffer(IndexBuffer indexBuffer)
_indexBuffer = indexBuffer;
_indexBufferDirty = true;
}
-
+
+ ///
+ /// Gets or sets index data. The default value is .
+ ///
public IndexBuffer Indices { set { SetIndexBuffer(value); } get { return _indexBuffer; } }
internal Shader VertexShader
@@ -1008,7 +1163,10 @@ internal void SetConstantBuffer(ShaderStage stage, int slot, ConstantBuffer buff
else
_pixelConstantBuffers[slot] = buffer;
}
-
+
+ ///
+ /// Gets a value that indicates whether the resources were lost.
+ ///
public bool ResourcesLost { get; set; }
///
@@ -1363,25 +1521,44 @@ public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex,
_graphicsMetrics._drawCount++;
_graphicsMetrics._primitiveCount += (primitiveCount * instanceCount);
}
- }
-
+ }
+
///
/// Gets the Pixel data of what is currently drawn on screen.
/// The format is whatever the current format of the backbuffer is.
///
- /// A byte[] of size (ViewPort.Width * ViewPort.Height * 4)
+ /// A byte[] of size (ViewPort.Width * ViewPort.Height * 4)
+ /// Array of data.
public void GetBackBufferData(T[] data) where T : struct
{
if (data == null)
throw new ArgumentNullException("data");
GetBackBufferData(null, data, 0, data.Length);
}
-
+
+ ///
+ ///
+ ///
+ /// The first element to use.
+ /// The number of elements to use.
public void GetBackBufferData(T[] data, int startIndex, int elementCount) where T : struct
{
GetBackBufferData(null, data, startIndex, elementCount);
}
-
+
+ ///
+ ///
+ ///
+ /// The section of the back buffer to copy.
+ /// indicates the data will be copied from the entire back buffer.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// is
+ ///
+ ///
public void GetBackBufferData(Rectangle? rect, T[] data, int startIndex, int elementCount)
where T : struct
{
diff --git a/MonoGame.Framework/Graphics/GraphicsResource.cs b/MonoGame.Framework/Graphics/GraphicsResource.cs
index d1c50611580..eac6c850ec2 100644
--- a/MonoGame.Framework/Graphics/GraphicsResource.cs
+++ b/MonoGame.Framework/Graphics/GraphicsResource.cs
@@ -7,6 +7,9 @@
namespace Microsoft.Xna.Framework.Graphics
{
+ ///
+ /// Queries and prepares resources.
+ ///
public abstract class GraphicsResource : IDisposable
{
bool disposed;
@@ -23,6 +26,7 @@ internal GraphicsResource()
}
+ ///
~GraphicsResource()
{
// Pass false so the managed objects are not released
@@ -40,6 +44,7 @@ internal protected virtual void GraphicsDeviceResetting()
}
+ ///
public void Dispose()
{
// Dispose of managed objects as well
@@ -80,8 +85,15 @@ protected virtual void Dispose(bool disposing)
}
}
+ ///
+ /// Occurs when is called
+ /// or when this object is finalized and collected by the garbage collector.
+ ///
public event EventHandler Disposing;
-
+
+ ///
+ /// Gets the associated with this .
+ ///
public GraphicsDevice GraphicsDevice
{
get
@@ -110,7 +122,10 @@ internal set
graphicsDevice.AddResourceReference(_selfReference);
}
}
-
+
+ ///
+ /// Gets a value that indicates whether the object is disposed.
+ ///
public bool IsDisposed
{
get
@@ -118,11 +133,20 @@ public bool IsDisposed
return disposed;
}
}
-
+
+ ///
+ /// Gets the name of the resource.
+ ///
public string Name { get; set; }
-
+
+ ///
+ /// Gets the resource tags for this resource.
+ ///
public Object Tag { get; set; }
+ ///
+ /// Gets a string representation of the current instance.
+ ///
public override string ToString()
{
return string.IsNullOrEmpty(Name) ? base.ToString() : Name;
diff --git a/MonoGame.Framework/GraphicsDeviceManager.cs b/MonoGame.Framework/GraphicsDeviceManager.cs
index 6f088b35d55..852714aa392 100644
--- a/MonoGame.Framework/GraphicsDeviceManager.cs
+++ b/MonoGame.Framework/GraphicsDeviceManager.cs
@@ -96,6 +96,7 @@ public GraphicsDeviceManager(Game game)
_game.Services.AddService(typeof(IGraphicsDeviceService), this);
}
+ ///
~GraphicsDeviceManager()
{
Dispose(false);
@@ -149,6 +150,13 @@ void IGraphicsDeviceManager.CreateDevice()
CreateDevice();
}
+ ///
+ /// Begins the drawing process.
+ ///
+ ///
+ /// if the drawing process begins successfully;
+ /// otherwise.
+ ///
public bool BeginDraw()
{
if (_graphicsDevice == null)
@@ -158,6 +166,9 @@ public bool BeginDraw()
return true;
}
+ ///
+ /// Ends the drawing process and calls for the current graphics device.
+ ///
public void EndDraw()
{
if (_graphicsDevice != null && _drawBegun)
@@ -259,12 +270,14 @@ private GraphicsDeviceInformation DoPreparingDeviceSettings()
#region IDisposable Members
+ ///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
+ ///
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
From 1caea0778a7c967464971716a611f74c51d90ad2 Mon Sep 17 00:00:00 2001
From: "Simon (Darkside) Jackson"
Date: Fri, 10 May 2024 12:27:19 +0100
Subject: [PATCH 2/2] Minor formatting updates
---
MonoGame.Framework/Graphics/GraphicsDevice.cs | 388 +++++++++---------
MonoGame.Framework/GraphicsDeviceManager.cs | 2 +-
2 files changed, 197 insertions(+), 193 deletions(-)
diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.cs b/MonoGame.Framework/Graphics/GraphicsDevice.cs
index a245666f347..aae397c0fc2 100644
--- a/MonoGame.Framework/Graphics/GraphicsDevice.cs
+++ b/MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -11,10 +11,10 @@
namespace Microsoft.Xna.Framework.Graphics
-{
- ///
- /// Performs primitive-based rendering, creates resources,
- /// handles system-level variables, adjusts gamma ramp levels, and creates shaders.
+{
+ ///
+ /// Performs primitive-based rendering, creates resources,
+ /// handles system-level variables, adjusts gamma ramp levels, and creates shaders.
///
public partial class GraphicsDevice : IDisposable
{
@@ -89,26 +89,26 @@ public partial class GraphicsDevice : IDisposable
private readonly RenderTargetBinding[] _tempRenderTargetBinding = new RenderTargetBinding[1];
internal GraphicsCapabilities GraphicsCapabilities { get; private set; }
-
- ///
- /// Gets the collection of vertex textures that support texture lookup
- /// in the vertex shader using the texldl statement.
- /// The vertex engine contains four texture sampler stages.
+
+ ///
+ /// Gets the collection of vertex textures that support texture lookup
+ /// in the vertex shader using the texldl statement.
+ /// The vertex engine contains four texture sampler stages.
///
public TextureCollection VertexTextures { get; private set; }
-
- ///
- /// Returns the collection of vertex sampler states.
+
+ ///
+ /// Returns the collection of vertex sampler states.
///
public SamplerStateCollection VertexSamplerStates { get; private set; }
-
- ///
- /// Returns the collection of textures that have been assigned to the texture stages of the device.
+
+ ///
+ /// Returns the collection of textures that have been assigned to the texture stages of the device.
///
public TextureCollection Textures { get; private set; }
-
- ///
- /// Retrieves a collection of objects for the current .
+
+ ///
+ /// Retrieves a collection of objects for the current .
///
public SamplerStateCollection SamplerStates { get; private set; }
@@ -154,33 +154,38 @@ private bool PixelShaderDirty
// Use WeakReference for the global resources list as we do not know when a resource
// may be disposed and collected. We do not want to prevent a resource from being
// collected by holding a strong reference to it in this list.
- private readonly List _resources = new List();
-
- // TODO Graphics Device events need implementing
- ///
- /// Occurs when a GraphicsDevice is about to be lost (for example, immediately before a reset).
+ private readonly List _resources = new List();
+
+ // TODO Graphics Device events need implementing
+ ///
+ /// Occurs when a GraphicsDevice is about to be lost (for example, immediately before a reset).
///
- public event EventHandler DeviceLost;
- ///
- /// Occurs after a GraphicsDevice is reset, allowing an application to recreate all resources.
+ public event EventHandler DeviceLost;
+
+ ///
+ /// Occurs after a GraphicsDevice is reset, allowing an application to recreate all resources.
///
- public event EventHandler DeviceReset;
- ///
- /// Occurs when a GraphicsDevice is resetting,
- /// allowing the application to cancel the default handling of the reset.
+ public event EventHandler DeviceReset;
+
+ ///
+ /// Occurs when a GraphicsDevice is resetting,
+ /// allowing the application to cancel the default handling of the reset.
///
- public event EventHandler DeviceResetting;
- ///
- /// Occurs when a resource is created.
+ public event EventHandler DeviceResetting;
+
+ ///
+ /// Occurs when a resource is created.
///
- public event EventHandler ResourceCreated;
- ///
- /// Occurs when a resource is destroyed.
+ public event EventHandler ResourceCreated;
+
+ ///
+ /// Occurs when a resource is destroyed.
///
- public event EventHandler ResourceDestroyed;
- ///
- /// Occurs when is called
- /// or when this object is finalized and collected by the garbage collector.
+ public event EventHandler ResourceDestroyed;
+
+ ///
+ /// Occurs when is called
+ /// or when this object is finalized and collected by the garbage collector.
///
public event EventHandler Disposing;
@@ -189,9 +194,9 @@ private bool PixelShaderDirty
private int _maxVertexBufferSlots;
internal int MaxTextureSlots;
internal int MaxVertexTextureSlots;
-
- ///
- /// Gets a value that indicates whether the object is disposed.
+
+ ///
+ /// Gets a value that indicates whether the object is disposed.
///
public bool IsDisposed
{
@@ -200,10 +205,10 @@ public bool IsDisposed
return _isDisposed;
}
}
-
- ///
- /// Gets a value that indicates whether the associated content was lost.
- ///
+
+ ///
+ /// Gets a value that indicates whether the associated content was lost.
+ ///
public bool IsContentLost {
get {
// We will just return IsDisposed for now
@@ -229,9 +234,9 @@ internal DepthFormat ActiveDepthFormat
: PresentationParameters.DepthStencilFormat;
}
}
-
- ///
- /// Gets the graphics adapter.
+
+ ///
+ /// Gets the graphics adapter.
///
public GraphicsAdapter Adapter
{
@@ -337,8 +342,7 @@ private void Setup()
#endif
// Initialize the main viewport
- _viewport = new Viewport (0, 0,
- DisplayMode.Width, DisplayMode.Height);
+ _viewport = new Viewport (0, 0, DisplayMode.Width, DisplayMode.Height);
_viewport.MaxDepth = 1.0f;
PlatformSetup();
@@ -370,7 +374,7 @@ private void Setup()
EffectCache = new Dictionary();
}
-
+
///
~GraphicsDevice()
{
@@ -435,10 +439,10 @@ internal void Initialize()
// Set the default render target.
ApplyRenderTargets(null);
}
-
- ///
- /// Gets or sets rasterizer state.
- /// The default value is .
+
+ ///
+ /// Gets or sets rasterizer state.
+ /// The default value is .
///
public RasterizerState RasterizerState
{
@@ -497,10 +501,10 @@ public Color BlendFactor
_blendFactorDirty = true;
}
}
-
- ///
- /// Gets or sets a system-defined instance of a blend state object initialized for alpha blending.
- /// The default value is .
+
+ ///
+ /// Gets or sets a system-defined instance of a blend state object initialized for alpha blending.
+ /// The default value is .
///
public BlendState BlendState
{
@@ -542,10 +546,10 @@ public BlendState BlendState
_blendStateDirty = true;
}
}
-
- ///
- /// Gets or sets a system-defined instance of a depth-stencil state object.
- /// The default value is .
+
+ ///
+ /// Gets or sets a system-defined instance of a depth-stencil state object.
+ /// The default value is .
///
public DepthStencilState DepthStencilState
{
@@ -599,10 +603,10 @@ internal void ApplyState(bool applyShaders)
PlatformApplyState(applyShaders);
}
-
- ///
- /// Clears resource buffers.
- ///
+
+ ///
+ /// Clears resource buffers.
+ ///
/// Set this color value in all buffers.
public void Clear(Color color)
{
@@ -616,11 +620,11 @@ public void Clear(Color color)
_graphicsMetrics._clearCount++;
}
}
-
- ///
- /// Set this color value in all buffers.
- /// Options for clearing a buffer.
- /// Set this depth value in the buffer.
+
+ ///
+ /// Set this color value in all buffers.
+ /// Options for clearing a buffer.
+ /// Set this depth value in the buffer.
/// Set this stencil value in the buffer.
public void Clear(ClearOptions options, Color color, float depth, int stencil)
{
@@ -630,9 +634,9 @@ public void Clear(ClearOptions options, Color color, float depth, int stencil)
{
_graphicsMetrics._clearCount++;
}
- }
-
- ///
+ }
+
+ ///
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
{
PlatformClear(options, color, depth, stencil);
@@ -642,14 +646,14 @@ public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
_graphicsMetrics._clearCount++;
}
}
-
+
///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
-
+
///
protected virtual void Dispose(bool disposing)
{
@@ -714,11 +718,11 @@ internal void RemoveResourceReference(WeakReference resourceReference)
_resources.Remove(resourceReference);
}
}
-
- ///
- /// Presents the display with the contents of the next buffer
- /// in the sequence of back buffers owned by the .
- ///
+
+ ///
+ /// Presents the display with the contents of the next buffer
+ /// in the sequence of back buffers owned by the .
+ ///
/// A render target is active.
public void Present()
{
@@ -738,9 +742,9 @@ public void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle,
*/
partial void PlatformReset();
-
- ///
- /// Resets the presentation parameters for the current .
+
+ ///
+ /// Resets the presentation parameters for the current .
///
public void Reset()
{
@@ -754,13 +758,13 @@ public void Reset()
EventHelpers.Raise(this, PresentationChanged, new PresentationEventArgs(PresentationParameters));
EventHelpers.Raise(this, DeviceReset, EventArgs.Empty);
}
-
- ///
- /// Resets the current with the specified .
- ///
- /// Presentation parameters to set.
- ///
- /// is
+
+ ///
+ /// Resets the current with the specified .
+ ///
+ /// Presentation parameters to set.
+ ///
+ /// is
///
public void Reset(PresentationParameters presentationParameters)
{
@@ -801,9 +805,9 @@ internal void OnDeviceReset()
{
EventHelpers.Raise(this, DeviceReset, EventArgs.Empty);
}
-
- ///
- /// Retrieves the display mode's spatial resolution, color resolution, and refresh frequency.
+
+ ///
+ /// Retrieves the display mode's spatial resolution, color resolution, and refresh frequency.
///
public DisplayMode DisplayMode
{
@@ -812,9 +816,9 @@ public DisplayMode DisplayMode
return Adapter.CurrentDisplayMode;
}
}
-
- ///
- /// Retrieves the status of the device.
+
+ ///
+ /// Retrieves the status of the device.
///
public GraphicsDeviceStatus GraphicsDeviceStatus
{
@@ -823,18 +827,18 @@ public GraphicsDeviceStatus GraphicsDeviceStatus
return GraphicsDeviceStatus.Normal;
}
}
-
- ///
- /// Gets the presentation parameters associated with this graphics device.
+
+ ///
+ /// Gets the presentation parameters associated with this graphics device.
///
public PresentationParameters PresentationParameters
{
get;
private set;
}
-
- ///
- /// Gets or sets a viewport identifying the portion of the render target to receive draw calls.
+
+ ///
+ /// Gets or sets a viewport identifying the portion of the render target to receive draw calls.
///
public Viewport Viewport
{
@@ -850,18 +854,18 @@ public Viewport Viewport
}
}
- private readonly GraphicsProfile _graphicsProfile;
- ///
- /// Gets the graphics profile.
- /// The default value is .
+ private readonly GraphicsProfile _graphicsProfile;
+ ///
+ /// Gets the graphics profile.
+ /// The default value is .
///
public GraphicsProfile GraphicsProfile
{
get { return _graphicsProfile; }
}
-
- ///
- /// Gets or sets the rectangle used for scissor testing. By default, the size matches the render target size.
+
+ ///
+ /// Gets or sets the rectangle used for scissor testing. By default, the size matches the render target size.
///
public Rectangle ScissorRectangle
{
@@ -879,9 +883,9 @@ public Rectangle ScissorRectangle
_scissorRectangleDirty = true;
}
}
-
- ///
- /// Gets the amount of render targets bound to this device.
+
+ ///
+ /// Gets the amount of render targets bound to this device.
///
public int RenderTargetCount
{
@@ -890,14 +894,14 @@ public int RenderTargetCount
return _currentRenderTargetCount;
}
}
-
- ///
- /// Sets a new render target for this .
- ///
- ///
- /// A new render target for the device, or
- /// to set the device render target to the back buffer of the device.
- ///
+
+ ///
+ /// Sets a new render target for this .
+ ///
+ ///
+ /// A new render target for the device, or
+ /// to set the device render target to the back buffer of the device.
+ ///
public void SetRenderTarget(RenderTarget2D renderTarget)
{
if (renderTarget == null)
@@ -910,9 +914,9 @@ public void SetRenderTarget(RenderTarget2D renderTarget)
SetRenderTargets(_tempRenderTargetBinding);
}
}
-
- ///
- ///
+
+ ///
+ ///
/// The cube map face type.
public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
{
@@ -926,10 +930,10 @@ public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFa
SetRenderTargets(_tempRenderTargetBinding);
}
}
-
- ///
- /// Sets an array of render targets.
- ///
+
+ ///
+ /// Sets an array of render targets.
+ ///
/// An array of render targets.
public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{
@@ -1028,10 +1032,10 @@ internal void ApplyRenderTargets(RenderTargetBinding[] renderTargets)
if (clearTarget)
Clear(DiscardColor);
}
-
- ///
- /// Gets render target surfaces.
- ///
+
+ ///
+ /// Gets render target surfaces.
+ ///
/// An array of bound render targets.
public RenderTargetBinding[] GetRenderTargets()
{
@@ -1040,37 +1044,37 @@ public RenderTargetBinding[] GetRenderTargets()
Array.Copy(_currentRenderTargetBindings, bindings, _currentRenderTargetCount);
return bindings;
}
-
- ///
- /// Gets render target surfaces.
- ///
- ///
- /// When this method returns, contains an array of that description of bound render targets.
- /// This parameter is treated as uninitialized.
+
+ ///
+ /// Gets render target surfaces.
+ ///
+ ///
+ /// When this method returns, contains an array of that description of bound render targets.
+ /// This parameter is treated as uninitialized.
///
public void GetRenderTargets(RenderTargetBinding[] outTargets)
{
Debug.Assert(outTargets.Length == _currentRenderTargetCount, "Invalid outTargets array length!");
Array.Copy(_currentRenderTargetBindings, outTargets, _currentRenderTargetCount);
}
-
- ///
- /// Sets or binds a vertex buffer to a device.
- ///
- /// A vertex buffer.
+
+ ///
+ /// Sets or binds a vertex buffer to a device.
+ ///
+ /// A vertex buffer.
public void SetVertexBuffer(VertexBuffer vertexBuffer)
{
_vertexBuffersDirty |= (vertexBuffer == null)
? _vertexBuffers.Clear()
: _vertexBuffers.Set(vertexBuffer, 0);
}
-
- ///
- ///
- /// The offset (in bytes) from the beginning of the buffer.
- ///
- /// is less than 0
- /// OR is greater than or equal to .VertexCount.
+
+ ///
+ ///
+ /// The offset (in bytes) from the beginning of the buffer.
+ ///
+ /// is less than 0
+ /// OR is greater than or equal to .VertexCount.
///
public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
{
@@ -1086,13 +1090,13 @@ public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
? _vertexBuffers.Clear()
: _vertexBuffers.Set(vertexBuffer, vertexOffset);
}
-
- ///
- /// Sets the vertex buffers.
- ///
- /// An array of vertex buffers.
- ///
- /// Length of is more than max allowed number of vertex buffers.
+
+ ///
+ /// Sets the vertex buffers.
+ ///
+ /// An array of vertex buffers.
+ ///
+ /// Length of is more than max allowed number of vertex buffers.
///
public void SetVertexBuffers(params VertexBufferBinding[] vertexBuffers)
{
@@ -1120,9 +1124,9 @@ private void SetIndexBuffer(IndexBuffer indexBuffer)
_indexBuffer = indexBuffer;
_indexBufferDirty = true;
}
-
- ///
- /// Gets or sets index data. The default value is .
+
+ ///
+ /// Gets or sets index data. The default value is .
///
public IndexBuffer Indices { set { SetIndexBuffer(value); } get { return _indexBuffer; } }
@@ -1163,10 +1167,10 @@ internal void SetConstantBuffer(ShaderStage stage, int slot, ConstantBuffer buff
else
_pixelConstantBuffers[slot] = buffer;
}
-
- ///
- /// Gets a value that indicates whether the resources were lost.
- ///
+
+ ///
+ /// Gets a value that indicates whether the resources were lost.
+ ///
public bool ResourcesLost { get; set; }
///
@@ -1521,44 +1525,44 @@ public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex,
_graphicsMetrics._drawCount++;
_graphicsMetrics._primitiveCount += (primitiveCount * instanceCount);
}
- }
-
+ }
+
///
/// Gets the Pixel data of what is currently drawn on screen.
/// The format is whatever the current format of the backbuffer is.
///
- /// A byte[] of size (ViewPort.Width * ViewPort.Height * 4)
- /// Array of data.
+ /// A byte[] of size (ViewPort.Width * ViewPort.Height * 4)
+ /// Array of data.
public void GetBackBufferData(T[] data) where T : struct
{
if (data == null)
throw new ArgumentNullException("data");
GetBackBufferData(null, data, 0, data.Length);
}
-
- ///
- ///
- ///
- /// The first element to use.
- /// The number of elements to use.
+
+ ///
+ /// A byte[] of size (ViewPort.Width * ViewPort.Height * 4)
+ /// Array of data.
+ /// The first element to use.
+ /// The number of elements to use.
public void GetBackBufferData(T[] data, int startIndex, int elementCount) where T : struct
{
GetBackBufferData(null, data, startIndex, elementCount);
}
-
- ///
- ///
- ///
- /// The section of the back buffer to copy.
- /// indicates the data will be copied from the entire back buffer.
- ///
- ///
- ///
- ///
- ///
- /// is
- ///
- ///
+
+ ///
+ /// A byte[] of size (ViewPort.Width * ViewPort.Height * 4)
+ ///
+ /// The section of the back buffer to copy.
+ /// indicates the data will be copied from the entire back buffer.
+ ///
+ /// Array of data.
+ /// The first element to use.
+ /// The number of elements to use.
+ ///
+ /// is
+ ///
+ ///
public void GetBackBufferData(Rectangle? rect, T[] data, int startIndex, int elementCount)
where T : struct
{
diff --git a/MonoGame.Framework/GraphicsDeviceManager.cs b/MonoGame.Framework/GraphicsDeviceManager.cs
index 852714aa392..4bc23cd25c4 100644
--- a/MonoGame.Framework/GraphicsDeviceManager.cs
+++ b/MonoGame.Framework/GraphicsDeviceManager.cs
@@ -16,7 +16,6 @@ public partial class GraphicsDeviceManager : IGraphicsDeviceService, IDisposable
private readonly Game _game;
private GraphicsDevice _graphicsDevice;
private bool _initialized = false;
-
private int _preferredBackBufferHeight;
private int _preferredBackBufferWidth;
private SurfaceFormat _preferredBackBufferFormat;
@@ -30,6 +29,7 @@ public partial class GraphicsDeviceManager : IGraphicsDeviceService, IDisposable
private bool _preferHalfPixelOffset = false;
private bool _wantFullScreen;
private GraphicsProfile _graphicsProfile;
+
// dirty flag for ApplyChanges
private bool _shouldApplyChanges;