Created
April 14, 2019 15:27
-
-
Save ainsleyrutterford/5607ffa09a174a079f30190e1391b766 to your computer and use it in GitHub Desktop.
FPS coutner SDL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uint32 fps_lasttime = SDL_GetTicks(); //the last recorded time. | |
Uint32 fps_current; //the current FPS. | |
Uint32 fps_frames = 0; //frames passed since the last recorded fps. | |
while (!quit) { | |
if (update()) { | |
fps_frames++; | |
if (fps_lasttime < SDL_GetTicks() - 1000) { | |
fps_lasttime = SDL_GetTicks(); | |
fps_current = fps_frames; | |
fps_frames = 0; | |
} | |
printf("Current FPS: %d\n", fps_current); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment