summaryrefslogtreecommitdiff
path: root/src/FPS.cxx
diff options
context:
space:
mode:
authorDenis Oliver Kropp <dok@directfb.org>2010-10-19 15:56:15 +0200
committerDenis Oliver Kropp <dok@directfb.org>2010-10-19 15:56:15 +0200
commit27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e (patch)
treeefee63b09d2f9b73e2ae73a9448660a3cf73c4e6 /src/FPS.cxx
downloadpluggit-27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e.tar.gz
pluggit-27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e.tar.bz2
pluggit-27d1e03d7bdf8fcfe7292c06e40bc3e2fca9158e.zip
pluggit
Diffstat (limited to 'src/FPS.cxx')
-rw-r--r--src/FPS.cxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/FPS.cxx b/src/FPS.cxx
new file mode 100644
index 0000000..3c0dd54
--- /dev/null
+++ b/src/FPS.cxx
@@ -0,0 +1,43 @@
+namespace PluggIt {
+
+class FPS
+{
+ private int frames;
+ private char str[20];
+
+ private Clock clock;
+
+
+ public FPS() {
+ Reset();
+ }
+
+ public void Reset() {
+ frames = 0;
+ str[0] = 0;
+
+ clock.Reset();
+ }
+
+ public void Count( float interval ) {
+ float time = clock.GetTime();
+
+ frames++;
+
+ if (time >= interval) {
+ float fps = frames / time;
+
+ snprintf( str, sizeof(str), "%.1f", fps );
+
+ frames = 0;
+ clock.Reset();
+ }
+ }
+
+ public const char *GetFPS() {
+ return str;
+ }
+};
+
+}
+