documentation.

This commit is contained in:
2019-01-14 00:34:35 -06:00
parent 32c2f25196
commit 40c7772559
15 changed files with 315 additions and 56 deletions

View File

@@ -5,23 +5,42 @@ using System;
namespace RecrownedAthenaeum.Render
{
/// <summary>
/// Renders rectangles using the <see cref="PrimitiveBatch"/>.
/// </summary>
public class RectangleRenderer : IDisposable
{
/// <summary>
/// The <see cref="PrimitiveBatch"/> used.
/// </summary>
public readonly PrimitiveBatch primitiveBatch;
private bool disposed;
private bool began;
private bool filling;
/// <summary>
/// Creates a rectangle renderer with the given <see cref="PrimitiveBatch"/>.
/// </summary>
/// <param name="primitiveBatch"></param>
public RectangleRenderer(PrimitiveBatch primitiveBatch)
{
this.primitiveBatch = primitiveBatch;
}
/// <summary>
/// Creates a rectangle renderer.
/// </summary>
/// <param name="graphicsDevice">The graphics device used to create the <see cref="PrimitiveBatch"/></param>
/// <param name="camera">The camera containing the matrix to be used for the transformations.</param>
public RectangleRenderer(GraphicsDevice graphicsDevice, Camera2D camera) : this(new PrimitiveBatch(graphicsDevice, camera, 4))
{
}
/// <summary>
/// Begins the render batch.
/// </summary>
/// <param name="filled">Whether or not to fill the rectangle.</param>
public void Begin(bool filled)
{
filling = filled;
@@ -31,6 +50,9 @@ namespace RecrownedAthenaeum.Render
began = true;
}
/// <summary>
/// Ends the batch.
/// </summary>
public void End()
{
if (disposed) throw new ObjectDisposedException(GetType().Name);
@@ -77,25 +99,39 @@ namespace RecrownedAthenaeum.Render
}
}
/// <summary>
/// Attempts to dispose of this object.
/// </summary>
public void Dispose()
{
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
Dispose(true);
GC.SuppressFinalize(this);
}
public void Dispose(bool disposing)
/// <summary>
/// An overridable of disposable.
/// </summary>
/// <param name="disposing">Only true when called by user code dispose. Destructor calling this results in false.</param>
public virtual void Dispose(bool disposing)
{
disposed = true;
if (!disposed && disposing)
{
disposed = true;
if (primitiveBatch != null)
{
primitiveBatch.Dispose();
}
}
else
{
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
}
}
/// <summary>
/// Destructor.
/// </summary>
~RectangleRenderer ()
{
Dispose(false);
}
}
}