From 097320cff73448c9e6cde359788c3185d37be813 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 30 Jun 2024 09:48:49 +0200 Subject: [PATCH] Asignada tecla F4 para activar/desactivar los shaders --- source/common/input.h | 3 +++ source/common/screen.cpp | 7 +++++++ source/common/screen.h | 3 +++ source/director.cpp | 5 +++-- source/title.cpp | 5 +++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/source/common/input.h b/source/common/input.h index 923e77a..5d5abd8 100644 --- a/source/common/input.h +++ b/source/common/input.h @@ -24,9 +24,12 @@ enum inputs_e input_fire_left, input_fire_center, input_fire_right, + + // Inputs estandar input_window_fullscreen, input_window_inc_size, input_window_dec_size, + input_video_shaders, // Input obligatorio input_number_of_inputs diff --git a/source/common/screen.cpp b/source/common/screen.cpp index 94593ef..88cab96 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -400,4 +400,11 @@ void Screen::doFlash() // Actualiza la lógica del efecto flashEffect.counter < flashEffect.lenght ? flashEffect.counter++ : flashEffect.enabled = false; } +} + +// Activa/desactiva los shaders +void Screen::switchShaders() +{ + options->video.shaders = !options->video.shaders; + setVideoMode(options->video.mode); } \ No newline at end of file diff --git a/source/common/screen.h b/source/common/screen.h index 236c860..58bfd86 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -136,6 +136,9 @@ public: // Pone la pantalla de color void flash(color_t color, int lenght); + + // Activa/desactiva los shaders + void switchShaders(); }; #endif diff --git a/source/director.cpp b/source/director.cpp index 118165a..a715a96 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -108,6 +108,7 @@ void Director::initInput() input->bindKey(input_window_dec_size, SDL_SCANCODE_F1); input->bindKey(input_window_inc_size, SDL_SCANCODE_F2); input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3); + input->bindKey(input_video_shaders, SDL_SCANCODE_F4); // Mando - Movimiento del jugador input->bindGameControllerButton(input_up, SDL_CONTROLLER_BUTTON_DPAD_UP); @@ -169,7 +170,7 @@ bool Director::initSDL() } } - if (options->video.shaders) + if (options->video.shaders || true) if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl")) { if (options->console) @@ -205,7 +206,7 @@ bool Director::initSDL() } // La aceleración se activa según las opciones - if (options->video.shaders) + if (options->video.shaders || true) { flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; } diff --git a/source/title.cpp b/source/title.cpp index d5c2817..555f096 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -264,6 +264,11 @@ void Title::checkInput() screen->incWindowSize(); } + else if (input->checkInput(input_video_shaders, REPEAT_FALSE)) + { + screen->switchShaders(); + } + else if (input->checkInput(input_accept, REPEAT_FALSE)) { fade->activate();