title: Calculating FPS in game
body: <p>Hello i am programming a 2D game and i have found several ways how to calculate Frames per second but i didnot really get the architecture rules yet , one of them is :</p>
  
  <pre><code>//at the start of main function
  Uint32 startclock = 0;
  Uint32 deltaclock = 0;
  Uint32 currentFPS = 0;
  // at beginning of while(!end_of_game)
  startclock = SDL_GetTicks();
  //fps calculation inside loop
  deltaclock = SDL_GetTicks() - startclock;
  startclock = SDL_GetTicks();
  //evaluate the formula inside loop
  if ( deltaclock != 0 )
      currentFPS = 1000 / deltaclock;
  //now i can output the current fps
  </code></pre>
  
  <p>what i cant figure out is that , rendering a screen takes some time so should i put this part at the absolute end of the loop (after rendering getting input etc (absolute end) :</p>
  
  <pre><code>if ( deltaclock != 0 )
      currentFPS = 1000 / deltaclock;
  </code></pre>
  
  <p>so basicaly at the start of the game loop i get start clock then i run every single function like movement collision rendering etc and then i evaluate delta clock and based on that i count fps ? there are tons of fps calculation "formulas" but i need a real program architecture i mean:</p>
  
  <pre><code>//main game loop
  //get elapsed time
  //game logic
  //delta time a.k.a how much time it took to go through the game logic part
  //output the fps
  </code></pre>
  
  <p>thanks</p>