diff options
author | Matt Turner <mattst88@gmail.com> | 2010-01-21 15:38:03 -0500 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2011-04-04 17:14:35 -0400 |
commit | ce7f4caaf9fa41e383efbc4854106558b3ff0e19 (patch) | |
tree | 67fa037c36f5470e7d2a57a722cec778f9b55bae /fps.c | |
parent | bf6f824b24b18197eabb7737f8bac8cc8a4baa8c (diff) |
Rework GLPong_Init and text init.
Signed-off-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'fps.c')
-rw-r--r-- | fps.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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; +} + |