Skip to content

Instantly share code, notes, and snippets.

@ainsleyrutterford
Created April 14, 2019 15:27
Show Gist options
  • Select an option

  • Save ainsleyrutterford/5607ffa09a174a079f30190e1391b766 to your computer and use it in GitHub Desktop.

Select an option

Save ainsleyrutterford/5607ffa09a174a079f30190e1391b766 to your computer and use it in GitHub Desktop.

Revisions

  1. Ainsley Rutterford created this gist Apr 14, 2019.
    15 changes: 15 additions & 0 deletions fps.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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);
    }
    }