migrant a SDL3
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
// IWYU pragma: no_include <bits/chrono.h>
|
||||
#include "director.h"
|
||||
#include <SDL3/SDL.h> // Para SDL_Init, SDL_Quit, SDL_INIT_EV...
|
||||
#include <SDL3/SDL_audio.h> // Para AUDIO_S16
|
||||
#include <SDL3/SDL_audio.h> // Para SDL_AudioFormat
|
||||
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||
#include <SDL3/SDL_error.h> // Para SDL_GetError
|
||||
#include <SDL3/SDL_events.h> // Para SDL_DISABLE
|
||||
#include <SDL3/SDL.h> // Para SDL_GAMEPAD_BUTTON_B, SDL_CO...
|
||||
#include <SDL3/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
|
||||
#include <SDL3/SDL_mouse.h> // Para SDL_ShowCursor
|
||||
#include <SDL3/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
|
||||
#include <SDL3/SDL_stdinc.h> // Para Uint32, SDL_bool
|
||||
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
|
||||
#include <SDL3/SDL_gamepad.h> // Para SDL_GamepadButton
|
||||
#include <SDL3/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DRIVER
|
||||
#include <SDL3/SDL_init.h> // Para SDL_Init, SDL_Quit, SDL_INIT_VIDEO
|
||||
#include <SDL3/SDL_log.h> // Para SDL_Log
|
||||
#include <SDL3/SDL_mouse.h> // Para SDL_HideCursor
|
||||
#include <SDL3/SDL_scancode.h> // Para SDL_Scancode
|
||||
#include <SDL3/SDL_stdinc.h> // Para SDL_free, SDL_PRIu32, Uint32
|
||||
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOOLONG
|
||||
#include <stdio.h> // Para printf, perror
|
||||
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
||||
#include <unistd.h> // Para getuid
|
||||
#include <algorithm> // Para min
|
||||
#include <chrono> // Para chrono
|
||||
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, rand
|
||||
#include <iostream> // Para basic_ostream, operator<<, basi...
|
||||
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, srand
|
||||
#include <ctime> // Para time
|
||||
#include <iostream> // Para basic_ostream, operator<<, cout, endl
|
||||
#include <memory> // Para make_unique, unique_ptr
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para operator+, char_traits, allocator
|
||||
#include <vector> // Para vector
|
||||
#include "asset.h" // Para Asset, AssetType
|
||||
#include "credits.h" // Para Credits
|
||||
#include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_...
|
||||
#include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_MOD...
|
||||
#include "hiscore_table.h" // Para HiScoreTable
|
||||
#include "input.h" // Para Input, InputAction
|
||||
#include "instructions.h" // Para Instructions
|
||||
#include "intro.h" // Para Intro
|
||||
#include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV...
|
||||
#include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundVolume
|
||||
#include "lang.h" // Para Code, loadFromFile
|
||||
#include "logo.h" // Para Logo
|
||||
#include "manage_hiscore_table.h" // Para ManageHiScoreTable
|
||||
#include "notifier.h" // Para Notifier
|
||||
#include "on_screen_help.h" // Para OnScreenHelp
|
||||
#include "options.h" // Para Options, options, OptionsContro...
|
||||
#include "param.h" // Para Param, ParamGame, param, loadPa...
|
||||
#include "options.h" // Para Options, options, GamepadOptions
|
||||
#include "param.h" // Para Param, ParamGame, param, loadParam...
|
||||
#include "resource.h" // Para Resource
|
||||
#include "screen.h" // Para Screen
|
||||
#include "section.h" // Para Name, Options, name, options
|
||||
@@ -69,9 +69,8 @@ Director::Director(int argc, const char *argv[])
|
||||
|
||||
std::cout << "Game start" << std::endl;
|
||||
|
||||
// Inicia la semilla aleatoria
|
||||
unsigned int seed = static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
std::srand(seed);
|
||||
// Inicia la semilla aleatoria usando el tiempo actual en segundos
|
||||
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
||||
|
||||
// Comprueba los parametros del programa
|
||||
checkProgramArguments(argc, argv);
|
||||
@@ -296,15 +295,31 @@ bool Director::initSDL()
|
||||
else
|
||||
{
|
||||
// Obtiene información sobre la pantalla
|
||||
auto DM = SDL_GetCurrentDisplayMode(0);
|
||||
int i, num_displays = 0;
|
||||
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
|
||||
if (displays)
|
||||
{
|
||||
for (i = 0; i < num_displays; ++i)
|
||||
{
|
||||
SDL_DisplayID instance_id = displays[i];
|
||||
const char *name = SDL_GetDisplayName(instance_id);
|
||||
|
||||
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
|
||||
options.video.window.max_zoom = std::min(DM->w / param.game.width, DM->h / param.game.height);
|
||||
options.video.window.zoom = std::min(options.video.window.zoom, options.video.window.max_zoom);
|
||||
SDL_Log("Display %" SDL_PRIu32 ": %s", instance_id, name ? name : "Unknown");
|
||||
}
|
||||
|
||||
// Muestra información sobre el tamaño de la pantalla y de la ventana de juego
|
||||
std::cout << "\nCurrent display mode: " << DM->w << "x" << DM->h << " @ " << DM->refresh_rate << "Hz" << std::endl;
|
||||
std::cout << "Window resolution : " << param.game.width << "x" << param.game.height << " x" << options.video.window.zoom << std::endl;
|
||||
auto DM = SDL_GetCurrentDisplayMode(displays[0]);
|
||||
|
||||
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
|
||||
options.video.window.max_zoom = std::min(DM->w / param.game.width, DM->h / param.game.height);
|
||||
options.video.window.zoom = std::min(options.video.window.zoom, options.video.window.max_zoom);
|
||||
|
||||
// Muestra información sobre el tamaño de la pantalla y de la ventana de juego
|
||||
std::cout << "\nCurrent display mode: " << DM->w << "x" << DM->h << " @ " << DM->refresh_rate << "Hz" << std::endl;
|
||||
std::cout << "Window resolution : " << param.game.width << "x" << param.game.height << " x" << options.video.window.zoom << std::endl;
|
||||
options.video.info = std::to_string(DM->w) + " X " + std::to_string(DM->h) + " AT " + std::to_string(DM->refresh_rate) + " HZ";
|
||||
|
||||
SDL_free(displays);
|
||||
}
|
||||
|
||||
// Establece el filtro de la textura
|
||||
/*if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(static_cast<int>(options.video.filter)).c_str()))
|
||||
@@ -327,7 +342,7 @@ bool Director::initSDL()
|
||||
else
|
||||
{
|
||||
// Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones
|
||||
//Uint32 flags = 0;
|
||||
// Uint32 flags = 0;
|
||||
if (options.video.v_sync)
|
||||
{
|
||||
// flags = SDL_RENDERER_PRESENTVSYNC;
|
||||
|
||||
Reference in New Issue
Block a user