Here's a crude example:
Code: Select all
void fps(void)
{
static int frames = 0;
static int lasttime = time(NULL);
frames++;
int tmp = time(NULL);
if (tmp != lasttime)
{
lasttime = tmp;
printf("%d fps\n", frames);
frames = 0;
}
}
It should be called once for every iteration of your main/rendering loop. Note that the first value it prints out will be inaccurate (that's one reason why it's crude).
The concept is quite simple, just think about it for a bit if you don't get it.