diff --git a/imgui.ini b/imgui.ini deleted file mode 100644 index 0b4e9c4..0000000 --- a/imgui.ini +++ /dev/null @@ -1,8 +0,0 @@ -[Window][Debug##Default] -Pos=60,60 -Size=400,400 - -[Window][Dear ImGui Demo] -Pos=551,12 -Size=550,680 - diff --git a/src/Application.cpp b/src/Application.cpp index eb5007f..4ab7b49 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -6,11 +6,13 @@ #include #include +#include #include #include #include +#include "Util.h" #include "VulkanRenderer.h" namespace Lunar { @@ -48,7 +50,19 @@ auto Application::run() -> void { SDL_Event e; + ImGuiIO &io = ImGui::GetIO(); + io.IniFilename = nullptr; + + uint64_t last { 0 }; + float fps { 0.0f }; while (m_running) { + uint64_t now { SDL_GetTicks() }; + uint64_t dt { now - last }; + last = now; + + if (dt > 0) + fps = 1000.0f / (float)dt; + while (SDL_PollEvent(&e)) { if (e.type == SDL_EVENT_QUIT) { m_running = false; @@ -66,7 +80,20 @@ auto Application::run() -> void ImGui_ImplVulkan_NewFrame(); ImGui::NewFrame(); + ImGui::ShowDemoWindow(); + + ImGui::SetNextWindowSize({ 100, 50 }); + ImGui::SetNextWindowPos({ 0, 0 }); + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4 { 0, 0, 0, 0.5f }); + if (ImGui::Begin("Debug Info", nullptr, + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) { + defer(ImGui::End()); + + ImGui::Text("%s", std::format("FPS: {:.2f}", fps).c_str()); + } + ImGui::PopStyleColor(); + ImGui::Render(); m_renderer->render();