Skip to content

Instantly share code, notes, and snippets.

@ainsleyrutterford
Created April 14, 2019 15:27
Show Gist options
  • Save ainsleyrutterford/5607ffa09a174a079f30190e1391b766 to your computer and use it in GitHub Desktop.
Save ainsleyrutterford/5607ffa09a174a079f30190e1391b766 to your computer and use it in GitHub Desktop.
FPS coutner SDL
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