feat(antialias): toggle F5 i indicador AA al debug overlay

Permet alternar l'AA geomètric en runtime:

- Action::TOGGLE_ANTIALIAS bound a F5.
- GlobalEvents::handle reacciona al scancode F5 cridant sdl.toggleAntialias().
- SDLManager::toggleAntialias muta cfg_->rendering.antialias i propaga a
  gpu_renderer_.setAntialias().
- GpuFrameRenderer manté l'estat antialias_enabled_ (true per defecte) i
  pushLine adapta extrusió i edge_dist en funció del flag — geometria nua
  quan està OFF, fade als bords quan està ON.
- RenderingConfig guanya el camp `antialias{1}` per coherència amb vsync;
  l'estat NO es persisteix al YAML de moment (decisió volgudament conservadora,
  podem afegir-ho en un commit a part si cal).
- DebugOverlay (F11) mostra una tercera línia "AA: ON/OFF" sota VSYNC per
  poder comparar a temps real.
This commit is contained in:
2026-05-20 21:39:24 +02:00
parent b10f2da647
commit 1ef9ca551f
10 changed files with 122 additions and 85 deletions
+53 -49
View File
@@ -5,10 +5,10 @@
#include <iostream>
#include "scene_context.hpp"
#include "core/input/input.hpp"
#include "core/input/mouse.hpp"
#include "core/rendering/sdl_manager.hpp"
#include "scene_context.hpp"
// Using declarations per simplificar el codi
using SceneManager::SceneContext;
@@ -16,55 +16,59 @@ using SceneType = SceneContext::SceneType;
namespace GlobalEvents {
auto handle(const SDL_Event& event, SDLManager& sdl, SceneContext& context) -> bool {
// 1. Permitir que Input procese el evento (para hotplug de gamepads)
auto event_msg = Input::get()->handleEvent(event);
if (!event_msg.empty()) {
std::cout << "[Input] " << event_msg << '\n';
}
// 2. Procesar SDL_EVENT_QUIT directamente (no es input de juego)
if (event.type == SDL_EVENT_QUIT) {
context.setNextScene(SceneType::EXIT);
SceneManager::actual = SceneType::EXIT;
return true;
}
// 3. Gestió del ratolí (auto-ocultar)
Mouse::handleEvent(event);
// 4. Procesar acciones globales directamente desde eventos SDL
// (NO usar Input::checkAction() para evitar desfase de timing)
if (event.type == SDL_EVENT_KEY_DOWN) {
switch (event.key.scancode) {
case SDL_SCANCODE_F1:
sdl.decreaseWindowSize();
return true;
case SDL_SCANCODE_F2:
sdl.increaseWindowSize();
return true;
case SDL_SCANCODE_F3:
sdl.toggleFullscreen();
return true;
case SDL_SCANCODE_F4:
sdl.toggleVSync();
return true;
case SDL_SCANCODE_ESCAPE:
context.setNextScene(SceneType::EXIT);
SceneManager::actual = SceneType::EXIT;
return true;
default:
// Tecla no global
break;
auto handle(const SDL_Event& event, SDLManager& sdl, SceneContext& context) -> bool {
// 1. Permitir que Input procese el evento (para hotplug de gamepads)
auto event_msg = Input::get()->handleEvent(event);
if (!event_msg.empty()) {
std::cout << "[Input] " << event_msg << '\n';
}
}
return false; // Event no processat
}
// 2. Procesar SDL_EVENT_QUIT directamente (no es input de juego)
if (event.type == SDL_EVENT_QUIT) {
context.setNextScene(SceneType::EXIT);
SceneManager::actual = SceneType::EXIT;
return true;
}
// 3. Gestió del ratolí (auto-ocultar)
Mouse::handleEvent(event);
// 4. Procesar acciones globales directamente desde eventos SDL
// (NO usar Input::checkAction() para evitar desfase de timing)
if (event.type == SDL_EVENT_KEY_DOWN) {
switch (event.key.scancode) {
case SDL_SCANCODE_F1:
sdl.decreaseWindowSize();
return true;
case SDL_SCANCODE_F2:
sdl.increaseWindowSize();
return true;
case SDL_SCANCODE_F3:
sdl.toggleFullscreen();
return true;
case SDL_SCANCODE_F4:
sdl.toggleVSync();
return true;
case SDL_SCANCODE_F5:
sdl.toggleAntialias();
return true;
case SDL_SCANCODE_ESCAPE:
context.setNextScene(SceneType::EXIT);
SceneManager::actual = SceneType::EXIT;
return true;
default:
// Tecla no global
break;
}
}
return false; // Event no processat
}
} // namespace GlobalEvents