This commit is contained in:
2022-05-22 22:25:20 +02:00
parent 2e76523bf4
commit 8affda125e
4 changed files with 33 additions and 3 deletions

View File

@ -7,7 +7,11 @@
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_keycode.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_timer.h>
#include <fmt/format.h>
#include <spdlog/spdlog.h>
#include <queue>
#include <stdexcept>
@ -42,9 +46,20 @@ int App::run() {
running = true;
uint32_t second_start = SDL_GetTicks();
unsigned frames = 0;
while (running) {
uint32_t now = SDL_GetTicks();
if (now - second_start > 5000) {
spdlog::info("{} FPS", frames / 5);
second_start = now;
frames = 0;
}
handle_events();
render();
frames++;
SDL_Delay(1);
}

View File

@ -5,6 +5,7 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <fmt/format.h>
#include <cstdint>