60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
// sdl_manager.hpp - Gestor d'inicialització de SDL3
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#ifndef SDL_MANAGER_HPP
|
|
#define SDL_MANAGER_HPP
|
|
|
|
#include "core/rendering/color_oscillator.hpp"
|
|
#include <SDL3/SDL.h>
|
|
#include <cstdint>
|
|
|
|
class SDLManager {
|
|
public:
|
|
SDLManager(); // Constructor per defecte (usa Defaults::)
|
|
SDLManager(int width, int height,
|
|
bool fullscreen); // Constructor amb configuració
|
|
~SDLManager();
|
|
|
|
// No permetre còpia ni assignació
|
|
SDLManager(const SDLManager &) = delete;
|
|
SDLManager &operator=(const SDLManager &) = delete;
|
|
|
|
// [NUEVO] Gestió de finestra dinàmica
|
|
void increaseWindowSize(); // F2: +100px
|
|
void decreaseWindowSize(); // F1: -100px
|
|
void toggleFullscreen(); // F3
|
|
bool
|
|
handleWindowEvent(const SDL_Event &event); // Per a SDL_EVENT_WINDOW_RESIZED
|
|
|
|
// Funcions principals (renderitzat)
|
|
void neteja(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0);
|
|
void presenta();
|
|
|
|
// [NUEVO] Actualització de colors (oscil·lació)
|
|
void updateColors(float delta_time);
|
|
|
|
// Getters
|
|
SDL_Renderer *obte_renderer() { return renderer_; }
|
|
|
|
private:
|
|
SDL_Window *finestra_;
|
|
SDL_Renderer *renderer_;
|
|
|
|
// [NUEVO] Estat de la finestra
|
|
int current_width_; // Mida física actual
|
|
int current_height_;
|
|
bool is_fullscreen_;
|
|
int max_width_; // Calculat des del display
|
|
int max_height_;
|
|
|
|
// [NUEVO] Funcions internes
|
|
void calculateMaxWindowSize(); // Llegir resolució del display
|
|
void applyWindowSize(int width, int height); // Canviar mida + centrar
|
|
void updateLogicalPresentation(); // Actualitzar viewport
|
|
|
|
// [NUEVO] Oscil·lador de colors
|
|
Rendering::ColorOscillator color_oscillator_;
|
|
};
|
|
|
|
#endif // SDL_MANAGER_HPP
|