Added ui labels for debugging and playability
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using Voxel.Graphics;
|
||||
using Voxel.UI;
|
||||
|
||||
namespace Voxel.Core
|
||||
{
|
||||
@@ -16,6 +18,8 @@ namespace Voxel.Core
|
||||
public event Action<float, float> Update;
|
||||
public event Action Tick;
|
||||
|
||||
private Label _fpsLabel = new Label("FPS: N/A", 16, 16, 24, Vector4.One);
|
||||
|
||||
private double _tickTime;
|
||||
public const double TICK_LENGTH = 1.0 / 20.0; // 20 TPS
|
||||
|
||||
@@ -55,14 +59,18 @@ namespace Voxel.Core
|
||||
timeElapsed += e.Time;
|
||||
float alpha = (float)(_tickTime / Window.TICK_LENGTH);
|
||||
float deltaTime = (float)e.Time;
|
||||
|
||||
if (timeElapsed >= 1)
|
||||
{
|
||||
Console.WriteLine("FPS: " + frames.ToString());
|
||||
_fpsLabel.Text = $"FPS: {frames}";
|
||||
timeElapsed = 0;
|
||||
frames = 0;
|
||||
}
|
||||
|
||||
Update.Invoke(deltaTime, alpha);
|
||||
|
||||
Renderer.RenderLabel(_fpsLabel);
|
||||
|
||||
Renderer.Render();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user