ImGui widget for displaying and configuring FPS metrics and frame pacing. More...
Namespaces Index
| namespace | helios |
|
|
|
| namespace | ext |
|
Platform-specific extensions and backend implementations. More...
|
|
| namespace | imgui |
|
|
|
| namespace | widgets |
|
Debug and developer widgets for ImGui overlays. More...
|
|
Classes Index
| class | FpsWidget |
|
Debug widget for real-time FPS metrics and frame pacing configuration. More...
|
|
Description
ImGui widget for displaying and configuring FPS metrics and frame pacing.
File Listing
The file content with the documentation metadata removed is:
11export module helios.ext.imgui.widgets.FpsWidget;
13import helios.ext.imgui.ImGuiWidget;
14import helios.engine.tooling.FpsMetrics;
15import helios.engine.tooling.FramePacer;
16import helios.engine.tooling.FrameStats;
69 float targetFpsInput_ = 0.0f;
80 bool showInSeconds_ = false;
92 int historySizeInput_ = 60;
105 ) : fpsMetrics_(fpsMetrics), framePacer_(framePacer)
108 historySizeInput_ = static_cast<int>(fpsMetrics_->getHistorySize());
111 targetFpsInput_ = framePacer_->getTargetFps();
124 ImGui::SetNextWindowPos(ImVec2(10, 10), ImGuiCond_FirstUseEver);
125 ImGui::SetNextWindowSize(ImVec2(320, 250), ImGuiCond_FirstUseEver);
127 if (ImGui::Begin("FPS Metrics", nullptr, ImGuiWindowFlags_NoCollapse)) {
130 ImGui::SeparatorText("Timing Info");
132 float displayFrameTime = showInSeconds_ ? fpsMetrics_->getFrameTimeSeconds() : fpsMetrics_->getFrameTimeMs();
133 float displayWorkTime = showInSeconds_ ? fpsMetrics_->getWorkTimeSeconds() : fpsMetrics_->getWorkTimeMs();
134 float displayIdleTime = showInSeconds_ ? fpsMetrics_->getIdleTimeSeconds() : fpsMetrics_->getIdleTimeMs();
135 const char* unit = showInSeconds_ ? "s" : "ms";
136 const char* format = showInSeconds_ ? "%.5f %s" : "%.2f %s";
138 ImGui::Text("FPS: %.1f", fpsMetrics_->getFps());
139 ImGui::Text("Avg Frame: "); ImGui::SameLine(); ImGui::Text(format, displayFrameTime, unit);
140 ImGui::Text("CPU Work: "); ImGui::SameLine(); ImGui::Text(format, displayWorkTime, unit);
141 ImGui::Text("Idle/Wait: "); ImGui::SameLine(); ImGui::Text(format, displayIdleTime, unit);
142 ImGui::Text("Frame #: %llu", fpsMetrics_->getFrameCount());
145 ImGui::SeparatorText("Settings");
148 if (ImGui::Checkbox("Show in Seconds", &showInSeconds_)) {
153 if (ImGui::InputInt("History Size", &historySizeInput_, 1, 10)) {
154 if (historySizeInput_ < 1) historySizeInput_ = 1;
155 if (historySizeInput_ > 1000) historySizeInput_ = 1000;
157 fpsMetrics_->setHistorySize(static_cast<size_t>(historySizeInput_));
162 ImGui::SeparatorText("Frame Pacing Config");
164 targetFpsInput_ = framePacer_->getTargetFps();
167 if (ImGui::Button("Uncapped (0)")) {
168 framePacer_->setTargetFps(0.0f);
169 targetFpsInput_ = 0.0f;
172 if (ImGui::Button("30 FPS")) {
173 framePacer_->setTargetFps(30.0f);
174 targetFpsInput_ = 30.0f;
177 if (ImGui::Button("60 FPS")) {
178 framePacer_->setTargetFps(60.0f);
179 targetFpsInput_ = 60.0f;
182 if (ImGui::Button("120 FPS")) {
183 framePacer_->setTargetFps(120.0f);
184 targetFpsInput_ = 120.0f;
187 if (ImGui::Button("144 FPS")) {
188 framePacer_->setTargetFps(144.0f);
189 targetFpsInput_ = 144.0f;
193 float sliderFps = targetFpsInput_;
194 if (ImGui::DragFloat("Target FPS", &sliderFps, 1.0f, 0.0f, 300.0f, "%.0f")) {
195 framePacer_->setTargetFps(sliderFps);
196 targetFpsInput_ = sliderFps;
198 if (ImGui::IsItemHovered()) {
199 ImGui::SetTooltip("Set to 0 for unlimited (V-Sync might still limit)");
204 const auto& history = fpsMetrics_->getHistory();
205 if (!history.empty()) {
206 ImGui::SeparatorText("History");
208 std::vector<float> frameTimes;
209 frameTimes.reserve(history.size());
211 for (const auto& s : history) {
212 frameTimes.push_back(s.totalFrameTime * 1000.0f);
215 ImGui::PlotLines("Frame Time (ms)",
217 static_cast<int>(frameTimes.size()),
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.