feat: ImGui debug overlay — FPS, camera position, entity count
- ImGui.NET 1.91.6.1 integrated into Engine.Graphics.Vulkan - VulkanImGui.cs: font atlas upload (staging → VkImage), sampler, descriptor set (COMBINED_IMAGE_SAMPLER), separate pipeline with alpha blending, no depth write, dynamic scissor - ImGui shaders: imgui.vert (ortho MVP push constant) + imgui.frag (font texture sampler) - Dynamic vertex/index buffers (HOST_VISIBLE, grow on demand) - IRenderer interface: BeginImGuiFrame/EndImGuiFrame default methods - Program.cs: debug window with FPS, camera pos/target, entity count - 0 critical validation errors, ~750 FPS with physics + ImGui
This commit is contained in:
@@ -6,6 +6,7 @@ using Engine.Graphics.Loaders;
|
||||
using Engine.Graphics.Vulkan;
|
||||
using Engine.Physics;
|
||||
using Flecs.NET.Core;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace CortexEngine.App;
|
||||
|
||||
@@ -41,6 +42,13 @@ class Program
|
||||
|
||||
CreateScene(world);
|
||||
|
||||
var hasImGui = renderer.GetType().Name == "VulkanRenderer";
|
||||
if (hasImGui)
|
||||
{
|
||||
ImGui.GetIO().DisplaySize = new System.Numerics.Vector2(window.Width, window.Height);
|
||||
Console.WriteLine("[App] ImGui initialized.");
|
||||
}
|
||||
|
||||
var lastWidth = window.Width;
|
||||
var lastHeight = window.Height;
|
||||
var frames = 0;
|
||||
@@ -82,6 +90,30 @@ class Program
|
||||
|
||||
physicsWorld.Update((float)timing.DeltaTime);
|
||||
physicsWorld.SyncTransforms(world);
|
||||
|
||||
if (hasImGui)
|
||||
{
|
||||
renderer.BeginImGuiFrame();
|
||||
|
||||
ImGui.Begin("Cortex Engine Debug");
|
||||
ImGui.Text($"FPS: {frames}");
|
||||
ImGui.Text($"Delta: {timing.DeltaTime * 1000.0:F2} ms");
|
||||
|
||||
var cam = cameraEntity.Get<Camera>();
|
||||
ImGui.Separator();
|
||||
ImGui.Text($"Camera Pos: ({cam.Position.X:F2}, {cam.Position.Y:F2}, {cam.Position.Z:F2})");
|
||||
ImGui.Text($"Camera Target: ({cam.Target.X:F2}, {cam.Target.Y:F2}, {cam.Target.Z:F2})");
|
||||
ImGui.Separator();
|
||||
|
||||
var entityCount = 0;
|
||||
world.Each((Entity e, ref Transform _) => entityCount++);
|
||||
ImGui.Text($"Entities: {entityCount}");
|
||||
ImGui.Text("WASD: move | RMB: look | Q/E: up/down | Shift: boost");
|
||||
ImGui.End();
|
||||
|
||||
renderer.EndImGuiFrame();
|
||||
}
|
||||
|
||||
renderer.RenderWorld(world);
|
||||
|
||||
frames++;
|
||||
|
||||
Reference in New Issue
Block a user