mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
only allow clearing a static sprite batch when batching
This commit is contained in:
parent
4a8a55fde3
commit
eb323bea01
1 changed files with 14 additions and 15 deletions
|
@ -7,7 +7,7 @@ using MLEM.Extensions;
|
||||||
namespace MLEM.Misc {
|
namespace MLEM.Misc {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A static sprite batch is a variation of <see cref="SpriteBatch"/> that keeps all batched items in a <see cref="VertexBuffer"/>, allowing for them to be drawn multiple times.
|
/// A static sprite batch is a variation of <see cref="SpriteBatch"/> that keeps all batched items in a <see cref="VertexBuffer"/>, allowing for them to be drawn multiple times.
|
||||||
/// To add items to a static sprite batch, use <see cref="ClearBatch"/> to clear currently batched items, <see cref="BeginBatch"/> to begin batching, <c>Add</c> and its various overloads to add batch items, <see cref="Remove"/> to remove them again, and <see cref="EndBatch"/> to end batching.
|
/// To add items to a static sprite batch, use <see cref="BeginBatch"/> to begin batching, <see cref="ClearBatch"/> to clear currently batched items, <c>Add</c> and its various overloads to add batch items, <see cref="Remove"/> to remove them again, and <see cref="EndBatch"/> to end batching.
|
||||||
/// To draw the batched items, call <see cref="Draw"/>.
|
/// To draw the batched items, call <see cref="Draw"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StaticSpriteBatch : IDisposable {
|
public class StaticSpriteBatch : IDisposable {
|
||||||
|
@ -43,7 +43,6 @@ namespace MLEM.Misc {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Begins batching.
|
/// Begins batching.
|
||||||
/// Call this method before calling <c>Add</c> or any of its overloads.
|
/// Call this method before calling <c>Add</c> or any of its overloads.
|
||||||
/// Note that, if <see cref="ClearBatch"/> was not called, items that are batched will be appended to the existing batch.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="InvalidOperationException">Thrown if this batch is currently batching already</exception>
|
/// <exception cref="InvalidOperationException">Thrown if this batch is currently batching already</exception>
|
||||||
public void BeginBatch() {
|
public void BeginBatch() {
|
||||||
|
@ -109,19 +108,6 @@ namespace MLEM.Misc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clears the batch, removing all currently batched vertices.
|
|
||||||
/// After this operation, <see cref="Vertices"/> will return 0.
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="InvalidOperationException">Thrown if this batch is currently batching</exception>
|
|
||||||
public void ClearBatch() {
|
|
||||||
if (this.batching)
|
|
||||||
throw new InvalidOperationException("Cannot clear while batching");
|
|
||||||
this.vertices.Clear();
|
|
||||||
this.texture = null;
|
|
||||||
this.batchChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draws this batch's content onto the <see cref="GraphicsDevice"/>'s current render target (or the back buffer) with the given settings.
|
/// Draws this batch's content onto the <see cref="GraphicsDevice"/>'s current render target (or the back buffer) with the given settings.
|
||||||
/// Note that this method should not be called while a regular <see cref="SpriteBatch"/> is currently active.
|
/// Note that this method should not be called while a regular <see cref="SpriteBatch"/> is currently active.
|
||||||
|
@ -340,6 +326,19 @@ namespace MLEM.Misc {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears the batch, removing all currently batched vertices.
|
||||||
|
/// After this operation, <see cref="Vertices"/> will return 0.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="InvalidOperationException">Thrown if this method is called before <see cref="BeginBatch"/> was called</exception>
|
||||||
|
public void ClearBatch() {
|
||||||
|
if (!this.batching)
|
||||||
|
throw new InvalidOperationException("Not batching");
|
||||||
|
this.vertices.Clear();
|
||||||
|
this.texture = null;
|
||||||
|
this.batchChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.spriteEffect.Dispose();
|
this.spriteEffect.Dispose();
|
||||||
|
|
Loading…
Reference in a new issue