From e24f06ed900a14cbb6effae0acfbc66833daace8 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 4 Oct 2025 13:34:00 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Resoluci=C3=B3n=20din=C3=A1mica=20CLI=20?= =?UTF-8?q?respeta=20par=C3=A1metros=20personalizados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problema: - Al usar -w/-h, la ventana se creaba correcta - Pero el renderizado interno seguía usando SCREEN_WIDTH/HEIGHT (320x240) - Resultado: ventana grande con área de juego pequeña en esquina Solución: - Añadidas variables base_screen_width/height_ - Guardan resolución configurada por CLI (o default) - current_screen_* ahora se inicializa con valores base - toggleRealFullscreen() restaura a resolución base, no constantes Cambios: - engine.h: Añadir base_screen_width/height_ - engine.cpp: Inicializar con valores CLI - engine.cpp: Usar base_* al salir de fullscreen real Ahora funciona: ./vibe3_physics -w 1920 -h 1080 # Renderiza en 1920x1080 ✅ ./vibe3_physics # Renderiza en 1280x720 ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- source/engine.cpp | 18 ++++++++++++------ source/engine.h | 6 +++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/engine.cpp b/source/engine.cpp index f9ede7a..efa726d 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -57,6 +57,12 @@ bool Engine::initialize(int width, int height, bool fullscreen) { int logical_width = (width > 0) ? width : SCREEN_WIDTH; int logical_height = (height > 0) ? height : SCREEN_HEIGHT; + // Guardar resolución base (configurada por CLI) + base_screen_width_ = logical_width; + base_screen_height_ = logical_height; + current_screen_width_ = logical_width; + current_screen_height_ = logical_height; + if (!SDL_Init(SDL_INIT_VIDEO)) { std::cout << "¡SDL no se pudo inicializar! Error de SDL: " << SDL_GetError() << std::endl; success = false; @@ -891,16 +897,16 @@ void Engine::toggleRealFullscreen() { // Ocultar cursor en real fullscreen SDL_HideCursor(); } else { - // Volver a resolución original - current_screen_width_ = SCREEN_WIDTH; - current_screen_height_ = SCREEN_HEIGHT; + // Volver a resolución base (configurada por CLI o default) + current_screen_width_ = base_screen_width_; + current_screen_height_ = base_screen_height_; // Restaurar ventana normal SDL_SetWindowFullscreen(window_, false); - SDL_SetWindowSize(window_, SCREEN_WIDTH * WINDOW_ZOOM, SCREEN_HEIGHT * WINDOW_ZOOM); + SDL_SetWindowSize(window_, base_screen_width_ * WINDOW_ZOOM, base_screen_height_ * WINDOW_ZOOM); - // Restaurar presentación lógica original - SDL_SetRenderLogicalPresentation(renderer_, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); + // Restaurar presentación lógica base + SDL_SetRenderLogicalPresentation(renderer_, base_screen_width_, base_screen_height_, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); // Reinicar la escena con resolución original initBalls(scenario_); diff --git a/source/engine.h b/source/engine.h index 1ee435d..451c285 100644 --- a/source/engine.h +++ b/source/engine.h @@ -64,7 +64,11 @@ private: bool real_fullscreen_enabled_ = false; ScalingMode current_scaling_mode_ = ScalingMode::INTEGER; // Modo de escalado actual (F5) - // Resolución dinámica para modo real fullscreen + // Resolución base (configurada por CLI o default) + int base_screen_width_ = SCREEN_WIDTH; + int base_screen_height_ = SCREEN_HEIGHT; + + // Resolución dinámica actual (cambia en fullscreen real) int current_screen_width_ = SCREEN_WIDTH; int current_screen_height_ = SCREEN_HEIGHT;