diff --git a/CHANGELOG.md b/CHANGELOG.md index f50598c..6610c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Additions Improvements - Improved EnumHelper.GetValues signature to return an array - Allow using external gesture handling alongside InputHandler through ExternalGestureHandling +- Discard old data when updating a StaticSpriteBatch Fixes - Fixed TokenizedString handling trailing spaces incorrectly in the last line of non-left aligned text diff --git a/MLEM/Graphics/StaticSpriteBatch.cs b/MLEM/Graphics/StaticSpriteBatch.cs index e9cf4cf..914c5de 100644 --- a/MLEM/Graphics/StaticSpriteBatch.cs +++ b/MLEM/Graphics/StaticSpriteBatch.cs @@ -42,7 +42,7 @@ namespace MLEM.Graphics { private readonly GraphicsDevice graphicsDevice; private readonly SpriteEffect spriteEffect; - private readonly List vertexBuffers = new List(); + private readonly List vertexBuffers = new List(); private readonly List textures = new List(); private readonly ISet items = new HashSet(); private IndexBuffer indices; @@ -439,8 +439,8 @@ namespace MLEM.Graphics { private void FillBuffer(int index, Texture2D texture, VertexPositionColorTexture[] data) { if (this.vertexBuffers.Count <= index) - this.vertexBuffers.Add(new VertexBuffer(this.graphicsDevice, VertexPositionColorTexture.VertexDeclaration, StaticSpriteBatch.MaxBatchItems * 4, BufferUsage.WriteOnly)); - this.vertexBuffers[index].SetData(data); + this.vertexBuffers.Add(new DynamicVertexBuffer(this.graphicsDevice, VertexPositionColorTexture.VertexDeclaration, StaticSpriteBatch.MaxBatchItems * 4, BufferUsage.WriteOnly)); + this.vertexBuffers[index].SetData(data, 0, data.Length, SetDataOptions.Discard); this.textures.Insert(index, texture); }