singletons

This commit is contained in:
2026-04-17 21:27:30 +02:00
parent 5889df2a47
commit 513eacf356
27 changed files with 536 additions and 505 deletions

View File

@@ -15,7 +15,6 @@ namespace Rendering {
}
#endif
class Asset;
class Text;
class Screen {
@@ -30,8 +29,12 @@ class Screen {
static constexpr int WASM_RENDER_SCALE = 3;
#endif
// Constructor y destructor
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset);
// Singleton API
static void init(SDL_Window *window, SDL_Renderer *renderer); // Crea la instancia
static void destroy(); // Libera la instancia
static auto get() -> Screen *; // Obtiene el puntero a la instancia
// Destructor (público por requisitos de `delete` desde destroy())
~Screen();
// Render loop
@@ -77,11 +80,17 @@ class Screen {
// Retornen false si GPU off / shaders off / llista buida (igual que a aee_plus).
auto nextPreset() -> bool;
auto prevPreset() -> bool;
auto getCurrentPresetName() const -> const char*;
auto getCurrentPresetName() const -> const char *;
void applyCurrentPostFXPreset(); // Escriu el preset PostFX actiu al backend
void applyCurrentCrtPiPreset(); // Escriu el preset CrtPi actiu al backend
private:
// Constructor privado (usar Screen::init)
Screen(SDL_Window *window, SDL_Renderer *renderer);
// Instancia única
static Screen *instance;
// Helpers internos de setVideoMode
void applyFullscreen(bool fullscreen); // SDL_SetWindowFullscreen + visibilidad del cursor
void applyWindowedLayout(); // Calcula windowWidth/Height/dest + SDL_SetWindowSize + SDL_SetWindowPosition
@@ -104,7 +113,6 @@ class Screen {
// Objetos y punteros
SDL_Window *window; // Ventana de la aplicación
SDL_Renderer *renderer; // El renderizador de la ventana
Asset *asset; // Objeto con el listado de recursos
SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa
// Variables