Answers for "print fps sfml"

C++
0

print fps sfml

void print_fps(){
  static sf::Clock clock; // google "static with variables", if you need
  static sf::Time last_time = clock.getElapsedTime();
  sf::Time current_time = clock.getElapsedTime();
  float fps = 1.f / (current_time.asSeconds() - last_time.asSeconds());
  last_time = current_time;

  printf("FPS: %f\n", fps);
}

// put this function somewhere in main cycle
Posted by: Guest on May-07-2022

Browse Popular Code Answers by Language