added fps counter

This commit is contained in:
Ryan Connelly 2012-11-03 21:06:02 +11:00
parent 2e545ebd38
commit dece42d76e

19
main.c
View File

@ -105,7 +105,12 @@ void run_game(void)
render_vxl_redraw(&tcam, map); render_vxl_redraw(&tcam, map);
int quitflag = 0; int quitflag = 0;
while(!quitflag)
int frame_prev = 0;
int frame_now = 0;
int fps = 0;
while(!quitflag)
{ {
// update angles // update angles
@ -160,6 +165,18 @@ void run_game(void)
if(mvx != 0.0f || mvy != 0.0f || mvz != 0.0f) if(mvx != 0.0f || mvy != 0.0f || mvz != 0.0f)
render_vxl_redraw(&tcam, map); render_vxl_redraw(&tcam, map);
frame_now = SDL_GetTicks();
fps++;
if(frame_now - frame_prev > 1000)
{
char buf[16];
sprintf(buf, "buldthensnip | FPS: %d", fps);
SDL_WM_SetCaption(buf, 0);
fps = 0;
frame_prev = SDL_GetTicks();
}
//printf("%.2f",); //printf("%.2f",);
SDL_LockSurface(screen); SDL_LockSurface(screen);