Even more documentation.

This commit is contained in:
2019-01-14 01:26:46 -06:00
parent 40c7772559
commit b019b7cf10
16 changed files with 368 additions and 46 deletions

View File

@@ -6,9 +6,15 @@ using System.Collections.Generic;
namespace RecrownedAthenaeum.Render
{
/// <summary>
/// A batch used to draw primitive shapes by batching together vertices.
/// </summary>
public class PrimitiveBatch : IDisposable
{
List<VertexPositionColor> vertices;
/// <summary>
/// The maximum vertices expected. The further off this expectancy is from the true value, the less efficient.
/// </summary>
public int MaxVertices { get { return vertices.Capacity; } set { vertices.Capacity = value; } }
int bufferPosition;
BasicEffect basicEffect;
@@ -80,7 +86,8 @@ namespace RecrownedAthenaeum.Render
if (primitiveType != PrimitiveType.LineStrip && primitiveType != PrimitiveType.TriangleStrip)
{
Flush();
} else
}
else
{
throw new InvalidOperationException("Buffer size isn't large enough.");
}
@@ -103,23 +110,35 @@ namespace RecrownedAthenaeum.Render
bufferPosition = 0;
}
/// <summary>
/// Disposes this.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public void Dispose(bool disposing)
/// <summary>
/// Overridable dispose.
/// </summary>
/// <param name="disposing">True for when user called for this to be disposed. False otherwise.</param>
public virtual void Dispose(bool disposing)
{
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
disposed = true;
if (disposing && !disposed)
{
basicEffect.Dispose();
disposed = true;
}
else
{
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
}
}
/// <summary>
/// Destructor.
/// </summary>
~PrimitiveBatch()
{
Dispose(false);
}
}
}