migrant a SDL3

This commit is contained in:
2025-03-27 08:14:37 +01:00
parent a9c869baf6
commit d2286905dc
83 changed files with 570 additions and 541 deletions

View File

@@ -6,7 +6,6 @@
#include <iterator> // Para istreambuf_iterator, operator==
#include <string> // Para allocator, char_traits, operator+, to_s...
#include "asset.h" // Para Asset
#include "dbgtxt.h" // Para dbg_print
#include "global_inputs.h" // Para service_pressed_counter
#include "jail_shader.h" // Para init, render
#include "mouse.h" // Para updateCursorVisibility
@@ -90,26 +89,22 @@ void Screen::renderScreen()
}
// Establece el modo de video
void Screen::setVideoMode(ScreenVideoMode mode)
void Screen::setFullscreenMode(bool mode)
{
// Actualiza las opciones
options.video.mode = mode;
options.video.fullscreen = mode;
// Configura el modo de pantalla
Uint32 flags = SDL_GetWindowFlags(window_);
if (flags != static_cast<Uint32>(options.video.mode))
{
SDL_SetWindowFullscreen(window_, static_cast<bool>(options.video.mode));
}
SDL_SetWindowFullscreen(window_, options.video.fullscreen);
initShaders();
}
// Camibia entre pantalla completa y ventana
void Screen::toggleVideoMode()
void Screen::toggleFullscreen()
{
options.video.mode = options.video.mode == ScreenVideoMode::WINDOW ? ScreenVideoMode::FULLSCREEN : ScreenVideoMode::WINDOW;
setVideoMode();
options.video.fullscreen = !options.video.fullscreen;
setFullscreenMode();
}
// Cambia el tamaño de la ventana
@@ -122,7 +117,7 @@ void Screen::setWindowZoom(int zoom)
// Reduce el tamaño de la ventana
bool Screen::decWindowZoom()
{
if (options.video.mode == ScreenVideoMode::WINDOW)
if (!options.video.fullscreen)
{
const int PREVIOUS_ZOOM = options.video.window.zoom;
--options.video.window.zoom;
@@ -141,7 +136,7 @@ bool Screen::decWindowZoom()
// Aumenta el tamaño de la ventana
bool Screen::incWindowZoom()
{
if (options.video.mode == ScreenVideoMode::WINDOW)
if (!options.video.fullscreen)
{
const int PREVIOUS_ZOOM = options.video.window.zoom;
++options.video.window.zoom;
@@ -245,7 +240,7 @@ void Screen::adjustWindowSize()
options.video.window.max_zoom = getMaxZoom();
// Establece el nuevo tamaño
if (options.video.mode == ScreenVideoMode::WINDOW)
if (!options.video.fullscreen)
{
const int WIDTH = param.game.width * options.video.window.zoom;
const int HEIGHT = param.game.height * options.video.window.zoom;
@@ -259,7 +254,7 @@ void Screen::adjustWindowSize()
const int NEW_POS_X = old_pos_x + (old_width - WIDTH) / 2;
const int NEW_POS_Y = old_pos_y + (old_height - HEIGHT) / 2;
SDL_FRect viewport = {0, 0, WIDTH, HEIGHT};
SDL_Rect viewport = {0, 0, WIDTH, HEIGHT};
SDL_SetRenderViewport(renderer_, &viewport);
SDL_SetWindowPosition(window_, std::max(NEW_POS_X, WINDOWS_DECORATIONS_), std::max(NEW_POS_Y, 0));