fix: triangle batch not drawing transparent colors properly
This commit is contained in:
@@ -39,7 +39,7 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
|
||||
Vector2 A = triangle.A.ToVector2();
|
||||
Vector2 B = triangle.B.ToVector2();
|
||||
Vector2 C = triangle.C.ToVector2();
|
||||
Color color = colorRGBA.ToColor();
|
||||
Color color = colorRGBA.ToPreMultipliedColor();
|
||||
|
||||
vertices[verticesIndex++] = new(new(A.X, A.Y, 0f), color);
|
||||
vertices[verticesIndex++] = new(new(B.X, B.Y, 0f), color);
|
||||
@@ -60,6 +60,8 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
|
||||
return;
|
||||
|
||||
graphicsDevice.RasterizerState = rasterizerState;
|
||||
graphicsDevice.BlendState = BlendState.AlphaBlend;
|
||||
|
||||
basicEffect.Projection = projection;
|
||||
basicEffect.View = view;
|
||||
vertexBuffer.SetData(vertices);
|
||||
@@ -67,8 +69,10 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
|
||||
graphicsDevice.SetVertexBuffer(vertexBuffer);
|
||||
|
||||
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
|
||||
{
|
||||
pass.Apply();
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, verticesIndex / 3);
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, verticesIndex / 3);
|
||||
}
|
||||
|
||||
verticesIndex = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user