diff --git a/Engine.Integration/Engine.Integration.MonoGame/Behaviours/SpriteBatcher.cs b/Engine.Integration/Engine.Integration.MonoGame/Behaviours/SpriteBatcher.cs index 7ca0b88..c34d84f 100644 --- a/Engine.Integration/Engine.Integration.MonoGame/Behaviours/SpriteBatcher.cs +++ b/Engine.Integration/Engine.Integration.MonoGame/Behaviours/SpriteBatcher.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; + using Engine.Core; namespace Engine.Integration.MonoGame; @@ -12,6 +14,7 @@ public class SpriteBatcher : Behaviour, IFirstFrameUpdate, IDraw private ISpriteBatch spriteBatch = null!; private MonoGameCamera2D camera2D = null!; + private readonly RasterizerState rasterizerState = new() { CullMode = CullMode.CullClockwiseFace }; private readonly ActiveBehaviourCollectorOrdered drawableSprites = new(GetPriority(), SortByPriority()); public void FirstActiveFrame() @@ -26,7 +29,13 @@ public class SpriteBatcher : Behaviour, IFirstFrameUpdate, IDraw public void Draw() { - spriteBatch.Begin(transformMatrix: camera2D.ViewMatrix.ToXnaMatrix()); + Matrix4x4 transformMatrix = Matrix4x4.Identity + .ApplyTranslation(new Vector2D(camera2D.Viewport.X, camera2D.Viewport.Y) * .5f) + .ApplyScale(new Vector3D(1f, -1f, 1f)) + .ApplyMatrix(camera2D.ViewMatrix) + .Transposed; + + spriteBatch.Begin(transformMatrix: transformMatrix.ToXnaMatrix(), rasterizerState: rasterizerState); for (int i = 0; i < drawableSprites.Count; i++) drawableSprites[i].Draw(spriteBatch); spriteBatch.End();