feat(rendering): on-screen debug overlay showing current biome and coordinates
Asset-free bitmap-text overlay: a 5x7 font (glyphs defined as verifiable ASCII-art) drawn as solid quads through a tiny 2D shader, white text with a drop shadow for legibility over any background. Renders 'BIOME: <name>' and 'XYZ: x, y, z' top-left, updating live. Adds Shader.SetVector2 and WorldGenerator.BiomeNameAt support; text scale and spawn-height offset read from Configuration.
This commit is contained in:
17
Core/Game.cs
17
Core/Game.cs
@@ -24,6 +24,7 @@ public sealed class Game : GameWindow
|
||||
private Shader _shader = null!;
|
||||
private Texture _texture = null!;
|
||||
private LoadingScreen _loading = null!;
|
||||
private DebugOverlay _debugOverlay = null!;
|
||||
private World.World _world = null!;
|
||||
private InMemoryChunkModificationStore _modStore = null!;
|
||||
private WorldGenerator _generator = null!;
|
||||
@@ -51,6 +52,7 @@ public sealed class Game : GameWindow
|
||||
this._shader = new Shader("Assets/shaders/chunk.vert", "Assets/shaders/chunk.frag");
|
||||
this._texture = new Texture("Assets/textures/VoxelShadeAtlas.png");
|
||||
this._loading = new LoadingScreen();
|
||||
this._debugOverlay = new DebugOverlay();
|
||||
|
||||
this._modStore = new InMemoryChunkModificationStore();
|
||||
this._world = new World.World(this._registry, this._modStore);
|
||||
@@ -60,11 +62,11 @@ public sealed class Game : GameWindow
|
||||
|
||||
// Spawn at terrain surface above (0, 0).
|
||||
int surfaceY = this._generator.SurfaceHeightAt(0, 0);
|
||||
Vector3 spawnPosition = new(0.5f, surfaceY + 2f, 0.5f);
|
||||
Vector3 spawnPosition = new(0.5f, surfaceY + this._cfg.SpawnHeightOffset, 0.5f);
|
||||
|
||||
this._player = new Player(this._cfg, spawnPosition, this.ClientSize.X / (float)this.ClientSize.Y);
|
||||
|
||||
var mesher = new ChunkMesher(this._texture.Width, this._texture.Height);
|
||||
ChunkMesher mesher = new(this._texture.Width, this._texture.Height);
|
||||
this._streamer = new ChunkStreamer(
|
||||
this._cfg,
|
||||
this._world,
|
||||
@@ -145,6 +147,16 @@ public sealed class Game : GameWindow
|
||||
renderer.Draw();
|
||||
});
|
||||
|
||||
Vector3 playerPos = this._player.Position;
|
||||
int px = (int)System.Math.Floor(playerPos.X);
|
||||
int py = (int)System.Math.Floor(playerPos.Y);
|
||||
int pz = (int)System.Math.Floor(playerPos.Z);
|
||||
this._debugOverlay.Draw(new[]
|
||||
{
|
||||
$"BIOME: {this._generator.BiomeNameAt(px, pz)}",
|
||||
$"XYZ: {px}, {py}, {pz}",
|
||||
}, this.ClientSize.X, this.ClientSize.Y, this._cfg.DebugOverlayTextScale);
|
||||
|
||||
this.SwapBuffers();
|
||||
}
|
||||
|
||||
@@ -159,6 +171,7 @@ public sealed class Game : GameWindow
|
||||
{
|
||||
Log.Information("Game shutting down");
|
||||
this._streamer?.Dispose();
|
||||
this._debugOverlay?.Dispose();
|
||||
this._loading?.Dispose();
|
||||
this._texture?.Dispose();
|
||||
this._shader?.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user