added fps counter
This commit is contained in:
parent
2e545ebd38
commit
dece42d76e
17
main.c
17
main.c
@ -105,6 +105,11 @@ void run_game(void)
|
|||||||
render_vxl_redraw(&tcam, map);
|
render_vxl_redraw(&tcam, map);
|
||||||
|
|
||||||
int quitflag = 0;
|
int quitflag = 0;
|
||||||
|
|
||||||
|
int frame_prev = 0;
|
||||||
|
int frame_now = 0;
|
||||||
|
int fps = 0;
|
||||||
|
|
||||||
while(!quitflag)
|
while(!quitflag)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -161,6 +166,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);
|
||||||
//memset(screen->pixels, 0x51, screen->h*screen->pitch);
|
//memset(screen->pixels, 0x51, screen->h*screen->pitch);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user