afegit comptador de frames per segon
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
SDLManager::SDLManager()
|
||||
: finestra_(nullptr),
|
||||
renderer_(nullptr),
|
||||
fps_accumulator_(0.0f),
|
||||
fps_frame_count_(0),
|
||||
fps_display_(0),
|
||||
current_width_(Defaults::Window::WIDTH),
|
||||
current_height_(Defaults::Window::HEIGHT),
|
||||
is_fullscreen_(false),
|
||||
@@ -69,6 +72,9 @@ SDLManager::SDLManager()
|
||||
SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
: finestra_(nullptr),
|
||||
renderer_(nullptr),
|
||||
fps_accumulator_(0.0f),
|
||||
fps_frame_count_(0),
|
||||
fps_display_(0),
|
||||
current_width_(width),
|
||||
current_height_(height),
|
||||
is_fullscreen_(fullscreen),
|
||||
@@ -305,3 +311,35 @@ void SDLManager::updateColors(float delta_time) {
|
||||
// Actualitzar color global de línies
|
||||
Rendering::setLineColor(color_oscillator_.getCurrentLineColor());
|
||||
}
|
||||
|
||||
// [NUEVO] Actualitzar comptador de FPS
|
||||
void SDLManager::updateFPS(float delta_time) {
|
||||
// Acumular temps i frames
|
||||
fps_accumulator_ += delta_time;
|
||||
fps_frame_count_++;
|
||||
|
||||
// Actualitzar display cada 0.5 segons
|
||||
if (fps_accumulator_ >= 0.5f) {
|
||||
fps_display_ = static_cast<int>(fps_frame_count_ / fps_accumulator_);
|
||||
fps_frame_count_ = 0;
|
||||
fps_accumulator_ = 0.0f;
|
||||
|
||||
// Actualitzar títol de la finestra
|
||||
std::string title = std::format("{} v{} ({}) - {} FPS",
|
||||
Project::LONG_NAME,
|
||||
Project::VERSION,
|
||||
Project::COPYRIGHT,
|
||||
fps_display_);
|
||||
|
||||
if (finestra_) {
|
||||
SDL_SetWindowTitle(finestra_, title.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [NUEVO] Actualitzar títol de la finestra
|
||||
void SDLManager::setWindowTitle(const std::string& title) {
|
||||
if (finestra_) {
|
||||
SDL_SetWindowTitle(finestra_, title.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user