minor change for the dispose exception for disposables.
This commit is contained in:
parent
bfdc36a3e2
commit
edd2e94a6a
@ -44,7 +44,7 @@ namespace RecrownedAthenaeum.Render
|
||||
public void Begin(PrimitiveType primitiveType)
|
||||
{
|
||||
if (began) throw new InvalidOperationException("Begin is being called twice before being ended.");
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
|
||||
this.primitiveType = primitiveType;
|
||||
verticesPerPrimitive = 0;
|
||||
switch (primitiveType)
|
||||
@ -63,7 +63,7 @@ namespace RecrownedAthenaeum.Render
|
||||
/// </summary>
|
||||
public void End()
|
||||
{
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
|
||||
|
||||
if (!began) throw new InvalidOperationException("Begin must be called before ending.");
|
||||
Flush();
|
||||
@ -77,7 +77,7 @@ namespace RecrownedAthenaeum.Render
|
||||
public void AddVertex(Vector2 vertex, Color color)
|
||||
{
|
||||
if (!began) throw new InvalidOperationException("Begin needs to be called before adding vertex.");
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
|
||||
if (bufferPosition + verticesPerPrimitive >= MaxVertices && (bufferPosition % MaxVertices == 0))
|
||||
{
|
||||
if (primitiveType != PrimitiveType.LineStrip && primitiveType != PrimitiveType.TriangleStrip)
|
||||
@ -99,7 +99,7 @@ namespace RecrownedAthenaeum.Render
|
||||
public void Flush()
|
||||
{
|
||||
if (!began) throw new InvalidOperationException("Begin needs to be called before flushing.");
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
|
||||
if (bufferPosition == 0) return;
|
||||
|
||||
graphicsDevice.DrawUserPrimitives(primitiveType, vertices.ToArray(), 0, bufferPosition / verticesPerPrimitive);
|
||||
@ -121,7 +121,7 @@ namespace RecrownedAthenaeum.Render
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace RecrownedAthenaeum.Render
|
||||
public void Begin(bool filled)
|
||||
{
|
||||
filling = filled;
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(GetType().Name);
|
||||
if (began) throw new InvalidOperationException("Cannot begin twice.");
|
||||
primitiveBatch.Begin(filled ? PrimitiveType.TriangleStrip : PrimitiveType.LineStrip);
|
||||
began = true;
|
||||
@ -37,7 +37,7 @@ namespace RecrownedAthenaeum.Render
|
||||
|
||||
public void End()
|
||||
{
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(GetType().Name);
|
||||
if (!began) throw new InvalidOperationException("Cannot end before beginning.");
|
||||
primitiveBatch.End();
|
||||
began = false;
|
||||
@ -55,7 +55,7 @@ namespace RecrownedAthenaeum.Render
|
||||
/// <param name="rotation">Rotation of rectangle. Default is 0 radians.</param>
|
||||
public void Rectangle(int x, int y, int width, int height, Color color, double rotation = 0)
|
||||
{
|
||||
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
|
||||
if (disposed) throw new ObjectDisposedException(GetType().Name);
|
||||
if (!began) throw new InvalidOperationException("Renderer must be started by calling Begin.");
|
||||
Vector2[] corners = new Vector2[4];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user