1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

dispose static sprite batch buffers properly

This commit is contained in:
Ell 2021-10-30 13:48:52 +02:00
parent 0809cd0218
commit 1c48a69371

View file

@ -103,6 +103,7 @@ namespace MLEM.Misc {
newIndices[index++] = (short) (item * 4 + 3); newIndices[index++] = (short) (item * 4 + 3);
newIndices[index++] = (short) (item * 4 + 2); newIndices[index++] = (short) (item * 4 + 2);
} }
this.indices?.Dispose();
this.indices = new IndexBuffer(this.graphicsDevice, IndexElementSize.SixteenBits, newIndices.Length, BufferUsage.WriteOnly); this.indices = new IndexBuffer(this.graphicsDevice, IndexElementSize.SixteenBits, newIndices.Length, BufferUsage.WriteOnly);
this.indices.SetData(newIndices); this.indices.SetData(newIndices);
} }
@ -316,6 +317,9 @@ namespace MLEM.Misc {
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() { public void Dispose() {
this.spriteEffect.Dispose(); this.spriteEffect.Dispose();
this.indices?.Dispose();
foreach (var buffer in this.vertexBuffers)
buffer.Dispose();
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }