summaryrefslogtreecommitdiff
path: root/fps.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-03-01 19:37:00 +0000
committerMatt Turner <mattst88@gmail.com>2008-03-01 19:37:00 +0000
commita8921d2baf7fe632839ec4c1a6f55db9c78f1c1c (patch)
tree145b9cd15e2770bedfb274708885511969813b31 /fps.c
parent8490c68f5d3fbb4d3e0030467dd785beca10c3f1 (diff)
Move frames per second stuff into separate files
git-svn-id: svn://mattst88.com/svn/glpong/trunk@14 449aeecc-241a-0410-943f-e2f883e2d7a2
Diffstat (limited to 'fps.c')
-rw-r--r--fps.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fps.c b/fps.c
new file mode 100644
index 0000000..4379e38
--- /dev/null
+++ b/fps.c
@@ -0,0 +1,27 @@
+#include <time.h>
+
+#include "SDL.h"
+#include "SDL_opengl.h"
+
+#include "text.h"
+#include "fps.h"
+
+static clock_t start;
+static GLfloat fps;
+
+void
+GLPong_FPSInit() {
+ start = SDL_GetTicks();
+}
+
+void
+GLPong_FPSCount() {
+ // 10.0f is the number of frames we let draw before calculating FPS
+ fps = 10.0f / (SDL_GetTicks() - start) * 1000; // 1 sec / 1 millisec == 1000
+ start = SDL_GetTicks();
+}
+
+void
+GLPong_FPSPrint() {
+ printf("%.2f frames per second\n", fps);
+}