Added ui labels for debugging and playability

This commit is contained in:
2026-04-22 17:18:15 +02:00
parent a324ff0d16
commit e1778fb446
8 changed files with 110 additions and 13 deletions

View File

@@ -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();