summaryrefslogtreecommitdiff
path: root/src/game/interface.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-16 14:52:57 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-16 14:55:33 +0100
commit87559f480badc2be26279bd1822980e7ce5dbba5 (patch)
tree7a2efd491089f4cc8683dd2c3f4648f1ff03b2ac /src/game/interface.cpp
parent8e81450c561b626b919ecce37b61491cbcc8c103 (diff)
Show some performance stats.
Diffstat (limited to 'src/game/interface.cpp')
-rw-r--r--src/game/interface.cpp24
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