rexglue-skate3/include/rex/ui/overlay/debug_overlay.h
mchughalex b845372efa
Some checks failed
Build rexglue-sdk linux-arm64 / build (push) Failing after 46s
Build rexglue-sdk linux-amd64 / build (push) Failing after 2s
Build rexglue-sdk win-amd64 / build (push) Failing after 2s
Lint & Format Check / Format Check (push) Has been cancelled
add product version metadata
2026-06-04 19:56:26 +02:00

51 lines
1.3 KiB
C++

/**
* @file rex/ui/overlay/debug_overlay.h
*
* @brief ImGui debug overlay dialog for frame timing display.
*
* @copyright Copyright (c) 2026 Tom Clay <tomc@tctechstuff.com>
* All rights reserved.
*
* @license BSD 3-Clause License
* See LICENSE file in the project root for full license text.
*/
#pragma once
#include <rex/ui/imgui_dialog.h>
#include <array>
#include <cstdint>
#include <functional>
#include <string>
#include <string_view>
namespace rex::ui {
struct FrameStats {
double frame_time_ms = 0;
double fps = 0;
uint64_t frame_count = 0;
};
class DebugOverlayDialog : public ImGuiDialog {
public:
using FrameStatsProvider = std::function<FrameStats()>;
explicit DebugOverlayDialog(ImGuiDrawer* imgui_drawer, FrameStatsProvider stats_provider = {},
std::string_view build_stamp = {});
~DebugOverlayDialog();
void SetStatsProvider(FrameStatsProvider provider) { stats_provider_ = std::move(provider); }
protected:
void OnDraw(ImGuiIO& io) override;
private:
FrameStatsProvider stats_provider_;
std::string build_stamp_;
#ifdef REXGLUE_ENABLE_PERF_COUNTERS
static constexpr size_t kFrameHistorySize = 120;
std::array<float, kFrameHistorySize> frame_time_history_{};
size_t frame_history_idx_ = 0;
#endif
};
} // namespace rex::ui