Mainstate view ratio corrected, camera2D takes float dimensions now.

added additional debug logging.
This commit is contained in:
Harrison Deng 2020-07-06 12:23:56 -05:00
parent 319ade258e
commit 80adda7afb
3 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Numerics; using System.Numerics;
using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Graphics.Render;
using SlatedGameToolkit.Framework.Logging;
using SlatedGameToolkit.Framework.Utilities; using SlatedGameToolkit.Framework.Utilities;
namespace SlatedGameToolkit.Framework.Graphics namespace SlatedGameToolkit.Framework.Graphics
@ -176,6 +177,7 @@ namespace SlatedGameToolkit.Framework.Graphics
this.Width = width; this.Width = width;
this.Height = height; this.Height = height;
this.CameraFront = -Vector3.UnitZ; this.CameraFront = -Vector3.UnitZ;
Logger.Log(string.Format("Camera initial dimensions: {0}x{1}, ratio of view: {2}", width, height, width / height), LogLevel.DEBUG);
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace SlatedGameToolkit.Framework.Graphics
} }
} }
public Camera2D(int width, int height) : base(width, height) { public Camera2D(float width, float height) : base(width, height) {
this.Orthographic = true; this.Orthographic = true;
this.LockedOrientation = true; this.LockedOrientation = true;
this.CameraFront = -Vector3.UnitZ; this.CameraFront = -Vector3.UnitZ;

View File

@ -52,7 +52,9 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
public unsafe void Initialize(StateManager manager) public unsafe void Initialize(StateManager manager)
{ {
window = new WindowContext("SlatedGameToolkit Playground"); window = new WindowContext("SlatedGameToolkit Playground");
camera = new Camera2D(2, 2); Vector2 drawableDimensions = window.GetDrawableDimensions();
float ratio = drawableDimensions.Y / drawableDimensions.X;
camera = new Camera2D(2f, ratio * 2f);
renderer = new MeshBatch(camera); renderer = new MeshBatch(camera);
logoTexture = TextureLoader.Load2DTexture("Resources/Playground/yhdnbgnc.png"); logoTexture = TextureLoader.Load2DTexture("Resources/Playground/yhdnbgnc.png");
@ -71,7 +73,7 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
untextured = new RectangleMesh(null, Color.Red); untextured = new RectangleMesh(null, Color.Red);
untextured.Width = 0.15f; untextured.Width = 0.15f;
untextured.Height = 0.1f; untextured.Height = 0.15f;
untextured.X = 0.25f; untextured.X = 0.25f;
untextured.Y = - 0.15f; untextured.Y = - 0.15f;