//
// Created by m on 7/18/23.
//

#include <fmt/format.h>
#include "fpscounterrenderingstep.hpp"

void FpsCounterRenderingStep::render_step(Renderer *renderer) {
    const double frames = 1;
    const double smooth = 0.9;
    std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
    std::chrono::duration<double> dur = end - this->lastFrame;
    renderer->draw_text(std::nullopt, fmt::format("{:.2f}", frames/dur.count()), 0, 0);
    this->lastFrame = end;
}

FpsCounterRenderingStep::FpsCounterRenderingStep() {
    this->lastFrame = std::chrono::high_resolution_clock::now();
}
