summaryrefslogtreecommitdiff
path: root/fps.c
diff options
context:
space:
mode:
Diffstat (limited to 'fps.c')
-rw-r--r--fps.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fps.c b/fps.c
new file mode 100644
index 0000000..65ee4a0
--- /dev/null
+++ b/fps.c
@@ -0,0 +1,23 @@
+#include <time.h>
+
+#include "SDL.h"
+#include "SDL_opengl.h"
+
+#include "fps.h"
+
+static clock_t start;
+static GLfloat fps;
+
+void
+GLPong_FPSInit(void) {
+ start = SDL_GetTicks();
+}
+
+GLfloat
+GLPong_FPSCount(void) {
+ /* 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();
+ return fps;
+}
+