diff options
Diffstat (limited to 'src/game/interface.cpp')
-rw-r--r-- | src/game/interface.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/game/interface.cpp b/src/game/interface.cpp index 2a52220..148f790 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -1,4 +1,5 @@ #include "game.hpp" +#include <iomanip> namespace interface { @@ -141,6 +142,8 @@ void state_t::render_to(render::state_t *render) { size_t w = window->getSize().x, h = window->getSize().y; v2f_t x; + std::stringstream ss; + double fps; if (select.selecting) render->render_hlrect(select.rect, sf::Color(200, 100, 50)); @@ -160,6 +163,27 @@ void state_t::render_to(render::state_t *render) render->render_text(x, em, entry.text, render::ALIGN_LEFT_TOP, sf::Color::White); x[1] += em; } + + x = v2f_t(0.0f, h - em * 1.5); + ss << "S/T/E: "; + ss << render->stats.sectors << "/"; + ss << render->stats.tiles << "/"; + ss << render->stats.entities; + render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White); + + perf_hist_index = (perf_hist_index + 1) % count(perf_hist); + perf_hist[perf_hist_index] = 1.0 / render->dt; + + fps = 0.0; + for (size_t i = 0; i < count(perf_hist); i++) + fps += perf_hist[i]; + fps /= count(perf_hist); + + x[1] -= em; + ss.str(std::string()); + ss << std::fixed << std::setprecision(1); + ss << "FPS: " << fps; + render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White); } } // namespace interface |