add config option sdl_renderer_driver

This commit is contained in:
Ondřej Novák 2025-05-01 21:21:22 +02:00
parent f383260a98
commit 93ec526482
9 changed files with 56 additions and 8 deletions

View file

@ -41,6 +41,7 @@ char game_display_init(const INI_CONFIG_SECTION *display_section, const char *ti
else cfg.crt_filter = SDLContext::CrtFilterType::autoselect;
cfg.cursor_size = ini_get_int(display_section, "cursor_size", 100)*0.01f;
cfg.hint_renderer = ini_get_string(display_section, "sdl_renderer_driver", NULL);
screen_pitch = 640;
get_sdl_global_context().init_video(cfg, title);

View file

@ -219,6 +219,9 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) {
_enable_crt = false;
}
if (config.hint_renderer) {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, config.hint_renderer);
}
_fullscreen_mode = config.fullscreen;
_mouse_size = config.cursor_size;
@ -294,7 +297,15 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) {
done.wait(false);
if (e) {
_render_thread.join();
std::rethrow_exception(e);
try {
std::rethrow_exception(e);
} catch (...) {
std::throw_with_nested(
std::runtime_error("Oops! The app couldn't start properly (problem during SDL initialization). "
"This may be caused by outdated or missing graphics or audio drivers."
"To fix this, please try the following: Restart your computer and try again/"
"Make sure your graphics and sound drivers are up to date."));
}
}

View file

@ -33,6 +33,7 @@ public:
CrtFilterType crt_filter;
int composer;
const char *scale_quality;
const char *hint_renderer;
bool fullscreen;
int aspect_x;
int aspect_y;
@ -238,8 +239,8 @@ protected:
std::unique_ptr<SDL_Texture, SDL_Deleter> _crt_effect;
std::unique_ptr<SDL_Texture, SDL_Deleter> _mouse;
unique_value<SDL_AudioDeviceID, SDL_Audio_Deleter> _audio;
SDL_Texture *_visible_texture;
SDL_Texture *_hidden_texture;
SDL_Texture *_visible_texture = nullptr;
SDL_Texture *_hidden_texture = nullptr;
bool _fullscreen_mode = false;
@ -256,7 +257,7 @@ protected:
std::queue<uint16_t> _keyboard_queue;
SDL_Rect _mouse_rect;
SDL_Point _mouse_finger;
float _mouse_size;
float _mouse_size = 1;
SpriteList _sprites;