GroveEngine/modules/BgfxRenderer/Debug/DebugOverlay.h
StillHammer 4932017244 feat(BgfxRenderer): Add debug overlay with FPS and stats display
- Create DebugOverlay class using bgfx debug text API
- Display FPS (color-coded: green >55, yellow >30, red <30)
- Show frame time, sprite count, draw calls
- Show GPU/CPU timing and texture stats from bgfx
- Add "debugOverlay" config option to enable at startup
- Smooth FPS display over 250ms intervals

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 21:23:29 +08:00

47 lines
1.2 KiB
C++

#pragma once
#include <cstdint>
#include <string>
namespace grove {
/**
* @brief Debug overlay for displaying runtime stats
*
* Uses bgfx debug text to display FPS, frame time, sprite count, etc.
* Can be toggled on/off at runtime.
*/
class DebugOverlay {
public:
DebugOverlay() = default;
// Enable/disable overlay
void setEnabled(bool enabled) { m_enabled = enabled; }
bool isEnabled() const { return m_enabled; }
void toggle() { m_enabled = !m_enabled; }
// Update stats (call each frame)
void update(float deltaTime, uint32_t spriteCount, uint32_t drawCalls);
// Render the overlay (call after bgfx::frame setup, before submit)
void render(uint16_t screenWidth, uint16_t screenHeight);
private:
bool m_enabled = false;
// Stats tracking
float m_deltaTime = 0.0f;
float m_fps = 0.0f;
float m_frameTimeMs = 0.0f;
uint32_t m_spriteCount = 0;
uint32_t m_drawCalls = 0;
// FPS smoothing
float m_fpsAccum = 0.0f;
int m_fpsFrameCount = 0;
float m_smoothedFps = 0.0f;
static constexpr float FPS_UPDATE_INTERVAL = 0.25f; // Update FPS display every 250ms
};
} // namespace grove