summaryrefslogtreecommitdiff
path: root/fps.c
blob: ca2787ad004399b94c83df7bda535924d0536b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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();
}

INLINE GLfloat
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();
	return fps;
}