Fix: Resolución dinámica CLI respeta parámetros personalizados

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 <noreply@anthropic.com>
This commit is contained in:
2025-10-04 13:34:00 +02:00
parent c4ca49b006
commit e24f06ed90
2 changed files with 17 additions and 7 deletions

View File

@@ -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_);

View File

@@ -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;