src/debug.cpp
raw| 1 | #ifdef HAVE_CONFIG_H |
| 2 | #include <config.h> |
| 3 | #endif |
| 4 | |
| 5 | #include "debug.h" |
| 6 | #include "SDL.h" |
| 7 | |
| 8 | int fps = 0; |
| 9 | |
| 10 | static int frames = 0; |
| 11 | static Uint32 fps_lasttick = 0; |
| 12 | |
| 13 | void debug_refreshFPS() { |
| 14 | /* Refresh frame counter twice per second */ |
| 15 | if ((SDL_GetTicks() - fps_lasttick) > 500) |
| 16 | { |
| 17 | fps = frames * (1000/500); |
| 18 | frames = 0; |
| 19 | fps_lasttick = SDL_GetTicks(); |
| 20 | } |
| 21 | frames++; |
| 22 | } |
| 23 | |
| 24 | void debug_logic() { |
| 25 | debug_refreshFPS(); |
| 26 | } |