From bd98ae8441459c5f2fc0afb89e74d671dc2a7b39 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 24 Oct 2022 17:22:24 -0700 Subject: [PATCH] fix validation error when TextBatch is empty --- src/Graphics/Font/TextBatch.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Graphics/Font/TextBatch.cs b/src/Graphics/Font/TextBatch.cs index 375a963..119fbde 100644 --- a/src/Graphics/Font/TextBatch.cs +++ b/src/Graphics/Font/TextBatch.cs @@ -101,8 +101,11 @@ namespace MoonWorks.Graphics.Font IndexBuffer = new Buffer(GraphicsDevice, BufferUsageFlags.Index, indexDataLengthInBytes); } - commandBuffer.SetBufferData(VertexBuffer, vertexDataPointer, 0, vertexDataLengthInBytes); - commandBuffer.SetBufferData(IndexBuffer, indexDataPointer, 0, indexDataLengthInBytes); + if (vertexDataLengthInBytes > 0 && indexDataLengthInBytes > 0) + { + commandBuffer.SetBufferData(VertexBuffer, vertexDataPointer, 0, vertexDataLengthInBytes); + commandBuffer.SetBufferData(IndexBuffer, indexDataPointer, 0, indexDataLengthInBytes); + } PrimitiveCount = vertexCount / 2; // FIXME: is this jank? }