From 59c5ebe9bef4ed3f75c69756ed9c08c6c50198fb Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 4 Oct 2025 08:38:41 +0200 Subject: [PATCH] Implementar toggle de escalado INTEGER/STRETCH en fullscreen (F5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Funcionalidad: - Tecla F5 alterna entre escalado INTEGER y STRETCH - Solo activo en modo fullscreen F3 (no aplica en F4) - INTEGER: Mantiene aspecto 4:3 con bandas negras - STRETCH: Estira imagen a pantalla completa - Texto informativo: 'SCALING: INTEGER' o 'SCALING: STRETCH' Implementación: - Variable integer_scaling_enabled_ (true por defecto) - toggleIntegerScaling() cambia SDL_RendererLogicalPresentation - Solo funciona si fullscreen_enabled_ == true - Ignora la tecla si no estás en modo F3 README actualizado: - Añadida tecla F5 en controles de ventana - Actualizada descripción de F3 - Nueva característica en lista principal Comportamiento: - Por defecto: INTEGER (mantiene aspecto) - Presionar F5: Cambia a STRETCH (pantalla completa) - Presionar F5 otra vez: Vuelve a INTEGER 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 6 ++++-- source/engine.cpp | 27 +++++++++++++++++++++++++++ source/engine.h | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f84ef6f..4c3a8bf 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ El nombre refleja su proposito: **ViBe** (vibe-coding experimental) + **Physics* - **Transiciones LERP**: Cambios de tema suaves y fluidos (0.5s) sin reiniciar escenario - **Hot-swap de sprites**: Cambio de textura dinamico (ball.png ↔ ball_small.png) con tecla N - **Sistema de zoom dinamico**: F1/F2 para ajustar el zoom de ventana (1x-10x) -- **Modos fullscreen**: F3 para fullscreen normal, F4 para real fullscreen con resolucion nativa +- **Modos fullscreen**: F3 para fullscreen normal (mantiene aspecto), F4 para real fullscreen con resolucion nativa +- **Escalado configurable**: F5 alterna entre INTEGER (mantiene aspecto) y STRETCH (pantalla completa) en modo F3 - **Gravedad multidireccional**: Gravedad hacia abajo, arriba, izquierda o derecha - **8 Figuras 3D**: Esfera, Wave Grid, Helix, Torus, Cubo, Cilindro, Icosaedro, Atom - **Interactividad**: Controles de teclado para modificar el comportamiento @@ -35,8 +36,9 @@ El nombre refleja su proposito: **ViBe** (vibe-coding experimental) + **Physics* |-------|--------| | `F1` | **Zoom out (reducir zoom ventana)** | | `F2` | **Zoom in (aumentar zoom ventana)** | -| `F3` | **Toggle fullscreen normal** | +| `F3` | **Toggle fullscreen normal (mantiene aspecto)** | | `F4` | **Toggle real fullscreen (resolucion nativa)** | +| `F5` | **Toggle escalado INTEGER/STRETCH (solo en modo F3)** | ### Controles de Temas | Tecla | Accion | diff --git a/source/engine.cpp b/source/engine.cpp index b8ddf36..368b5b5 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -463,6 +463,11 @@ void Engine::handleEvents() { case SDLK_F4: toggleRealFullscreen(); break; + + // Toggle escalado entero/estirado (solo en fullscreen F3) + case SDLK_F5: + toggleIntegerScaling(); + break; } } } @@ -784,6 +789,28 @@ void Engine::toggleRealFullscreen() { } } +void Engine::toggleIntegerScaling() { + // Solo permitir cambio si estamos en modo fullscreen normal (F3) + if (!fullscreen_enabled_) { + return; // No hacer nada si no estamos en fullscreen + } + + integer_scaling_enabled_ = !integer_scaling_enabled_; + + // Aplicar el nuevo modo de escalado + SDL_RendererLogicalPresentation presentation = integer_scaling_enabled_ + ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE + : SDL_LOGICAL_PRESENTATION_STRETCH; + + SDL_SetRenderLogicalPresentation(renderer_, SCREEN_WIDTH, SCREEN_HEIGHT, presentation); + + // Mostrar texto informativo + text_ = integer_scaling_enabled_ ? "SCALING: INTEGER" : "SCALING: STRETCH"; + text_pos_ = (current_screen_width_ - static_cast(text_.length() * 8)) / 2; + show_text_ = true; + text_init_time_ = SDL_GetTicks(); +} + std::string Engine::gravityDirectionToString(GravityDirection direction) const { switch (direction) { case GravityDirection::DOWN: return "DOWN"; diff --git a/source/engine.h b/source/engine.h index 2bb2ace..13d2f50 100644 --- a/source/engine.h +++ b/source/engine.h @@ -61,6 +61,7 @@ private: std::string vsync_text_ = "VSYNC ON"; bool fullscreen_enabled_ = false; bool real_fullscreen_enabled_ = false; + bool integer_scaling_enabled_ = true; // Escalado entero (mantiene aspecto) por defecto // Auto-restart system Uint64 all_balls_stopped_start_time_ = 0; // Momento cuando todas se pararon @@ -121,6 +122,7 @@ private: void toggleVSync(); void toggleFullscreen(); void toggleRealFullscreen(); + void toggleIntegerScaling(); std::string gravityDirectionToString(GravityDirection direction) const; void initializeThemes(); void checkAutoRestart();