From b04e0f81cd7e12541efc10dcb2686702fe530db1 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Tue, 5 Aug 2025 20:43:54 +0300 Subject: [PATCH] fix: triangle batch not drawing shapes because not setting rasterizer state properly --- .../Engine.Integration.MonoGame/TriangleBatch.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Engine.Integration/Engine.Integration.MonoGame/TriangleBatch.cs b/Engine.Integration/Engine.Integration.MonoGame/TriangleBatch.cs index bc9ec50..1612526 100644 --- a/Engine.Integration/Engine.Integration.MonoGame/TriangleBatch.cs +++ b/Engine.Integration/Engine.Integration.MonoGame/TriangleBatch.cs @@ -14,11 +14,11 @@ public class TriangleBatch : ITriangleBatch private Matrix _view; private Matrix _projection; private readonly BasicEffect basicEffect; + private readonly RasterizerState rasterizerState = new() { CullMode = CullMode.None }; public TriangleBatch(GraphicsDevice graphicsDevice) { this.graphicsDevice = graphicsDevice; - this.graphicsDevice.RasterizerState = new RasterizerState() { CullMode = CullMode.None }; basicEffect = new(graphicsDevice); basicEffect.VertexColorEnabled = true; } @@ -58,6 +58,7 @@ public class TriangleBatch : ITriangleBatch private void Flush() { + graphicsDevice.RasterizerState = rasterizerState; basicEffect.Projection = _projection; basicEffect.View = _view; vertexBuffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), 1024, BufferUsage.WriteOnly);