b746578bc8
Sustituye en bloque las cabeceras de los archivos por una sola línea de copyright. Cero rastro de "Visente", "Sergi" o "1999" en el árbol del proyecto. Se eliminan también las variantes "© 2025 Port a C++20", "© 2025 Port a C++20 con SDL3" y "© 2025 Orni Attack" (con todas sus colas descriptivas como "Arquitectura de entidades" o "Sistema de física"), que en este punto eran ruido histórico. Aplicado con un par de sed (find -type f, excluyendo source/external y source/legacy): 1. \|^// © 1999 Visente i Sergi (versión Pascal)$|d 2. s|^// © 2025 (Port a C++20.*|Orni Attack.*)$|// © 2026 JailDesigner| Verificado: la única variante de cabecera tras el sweep es "// © 2026 JailDesigner". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
70 lines
2.8 KiB
C++
70 lines
2.8 KiB
C++
// sdl_manager.hpp - Gestor de inicialización de SDL3
|
|
// © 2026 JailDesigner
|
|
//
|
|
// Tras la Fase 7 de la migración, el rendering ya no usa SDL_Renderer:
|
|
// SDLManager posee un GpuFrameRenderer (SDL3 GPU) que es el contexto único
|
|
// de dibujo del juego. El resto del código accede vía getRenderer() →
|
|
// Rendering::Renderer* (alias del GpuFrameRenderer).
|
|
|
|
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "core/rendering/render_context.hpp"
|
|
|
|
class SDLManager {
|
|
public:
|
|
SDLManager(); // Constructor per defecte (usa Defaults::)
|
|
SDLManager(int width, int height, bool fullscreen); // Constructor con configuración
|
|
~SDLManager();
|
|
|
|
// No permetre còpia ni assignació
|
|
SDLManager(const SDLManager&) = delete;
|
|
auto operator=(const SDLManager&) -> SDLManager& = delete;
|
|
|
|
// [NUEVO] Gestió de finestra dinàmica
|
|
void increaseWindowSize(); // F2: +100px
|
|
void decreaseWindowSize(); // F1: -100px
|
|
void toggleFullscreen(); // F3
|
|
void toggleVSync(); // F4
|
|
auto handleWindowEvent(const SDL_Event& event) -> bool; // Per a SDL_EVENT_WINDOW_RESIZED
|
|
|
|
// Funciones principals (renderizado)
|
|
void clear(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0);
|
|
void present();
|
|
|
|
// Getters
|
|
auto getRenderer() -> Rendering::Renderer* { return &gpu_renderer_; }
|
|
[[nodiscard]] auto getScaleFactor() const -> float { return zoom_factor_; }
|
|
|
|
// [NUEVO] Actualitzar context de renderizado (factor de scale global)
|
|
void updateRenderingContext() const;
|
|
|
|
private:
|
|
SDL_Window* finestra_;
|
|
Rendering::Renderer gpu_renderer_; // GpuFrameRenderer (SDL3 GPU)
|
|
|
|
// [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_;
|
|
|
|
// [ZOOM SYSTEM]
|
|
float zoom_factor_; // Current zoom (0.5x to max_zoom_)
|
|
int windowed_width_; // Saved size before fullscreen
|
|
int windowed_height_; // Saved size before fullscreen
|
|
float max_zoom_; // Maximum zoom (calculated from display)
|
|
|
|
// [NUEVO] Funciones internes
|
|
void calculateMaxWindowSize(); // Llegir resolució del display
|
|
void calculateMaxZoom(); // Calculate max zoom from display
|
|
void applyZoom(float new_zoom); // Apply zoom and resize window
|
|
void applyWindowSize(int width, int height); // Canviar mida + centrar
|
|
void updateViewport(); // Configurar viewport con letterbox
|
|
|
|
};
|