mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
add config option sdl_renderer_driver
This commit is contained in:
parent
f383260a98
commit
93ec526482
9 changed files with 56 additions and 8 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
@ -38,3 +39,18 @@ void send_log_impl(const char *format, ...) {
|
||||||
void throw_exception(const char *text) {
|
void throw_exception(const char *text) {
|
||||||
throw std::runtime_error(std::string("Invoked crash:") + text);
|
throw std::runtime_error(std::string("Invoked crash:") + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string exception_to_string(const std::exception& e) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << e.what();
|
||||||
|
|
||||||
|
try {
|
||||||
|
std::rethrow_if_nested(e);
|
||||||
|
} catch (const std::exception& nested) {
|
||||||
|
oss << " Reason: " << exception_to_string(nested);
|
||||||
|
} catch (...) {
|
||||||
|
oss << " Reason: unknown exception of crash";
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::move(oss).str();
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
std::string exception_to_string(const std::exception& e);
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,7 +15,8 @@ void send_log_impl(const char *format, ...);
|
||||||
void display_error(const char *format, ...);
|
void display_error(const char *format, ...);
|
||||||
void throw_exception(const char *text);
|
void throw_exception(const char *text);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "../../game/skeldal.h"
|
#include "../../game/skeldal.h"
|
||||||
#include "../getopt.h"
|
#include "../getopt.h"
|
||||||
#include "../platform.h"
|
#include "../platform.h"
|
||||||
|
#include "../error.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
std::cerr << "ERROR: " << exception_to_string(e) << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "map_file.h"
|
#include "map_file.h"
|
||||||
#include "../error.h"
|
#include "../error.h"
|
||||||
}
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void *map_file_to_memory(const char *name, size_t *sz);
|
void *map_file_to_memory(const char *name, size_t *sz);
|
||||||
void unmap_file(void *ptr, size_t sz);
|
void unmap_file(void *ptr, size_t sz);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ char game_display_init(const INI_CONFIG_SECTION *display_section, const char *ti
|
||||||
else cfg.crt_filter = SDLContext::CrtFilterType::autoselect;
|
else cfg.crt_filter = SDLContext::CrtFilterType::autoselect;
|
||||||
|
|
||||||
cfg.cursor_size = ini_get_int(display_section, "cursor_size", 100)*0.01f;
|
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;
|
screen_pitch = 640;
|
||||||
get_sdl_global_context().init_video(cfg, title);
|
get_sdl_global_context().init_video(cfg, title);
|
||||||
|
|
|
@ -219,6 +219,9 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) {
|
||||||
_enable_crt = false;
|
_enable_crt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.hint_renderer) {
|
||||||
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, config.hint_renderer);
|
||||||
|
}
|
||||||
|
|
||||||
_fullscreen_mode = config.fullscreen;
|
_fullscreen_mode = config.fullscreen;
|
||||||
_mouse_size = config.cursor_size;
|
_mouse_size = config.cursor_size;
|
||||||
|
@ -294,7 +297,15 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) {
|
||||||
done.wait(false);
|
done.wait(false);
|
||||||
if (e) {
|
if (e) {
|
||||||
_render_thread.join();
|
_render_thread.join();
|
||||||
|
try {
|
||||||
std::rethrow_exception(e);
|
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."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
CrtFilterType crt_filter;
|
CrtFilterType crt_filter;
|
||||||
int composer;
|
int composer;
|
||||||
const char *scale_quality;
|
const char *scale_quality;
|
||||||
|
const char *hint_renderer;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
int aspect_x;
|
int aspect_x;
|
||||||
int aspect_y;
|
int aspect_y;
|
||||||
|
@ -238,8 +239,8 @@ protected:
|
||||||
std::unique_ptr<SDL_Texture, SDL_Deleter> _crt_effect;
|
std::unique_ptr<SDL_Texture, SDL_Deleter> _crt_effect;
|
||||||
std::unique_ptr<SDL_Texture, SDL_Deleter> _mouse;
|
std::unique_ptr<SDL_Texture, SDL_Deleter> _mouse;
|
||||||
unique_value<SDL_AudioDeviceID, SDL_Audio_Deleter> _audio;
|
unique_value<SDL_AudioDeviceID, SDL_Audio_Deleter> _audio;
|
||||||
SDL_Texture *_visible_texture;
|
SDL_Texture *_visible_texture = nullptr;
|
||||||
SDL_Texture *_hidden_texture;
|
SDL_Texture *_hidden_texture = nullptr;
|
||||||
|
|
||||||
|
|
||||||
bool _fullscreen_mode = false;
|
bool _fullscreen_mode = false;
|
||||||
|
@ -256,7 +257,7 @@ protected:
|
||||||
std::queue<uint16_t> _keyboard_queue;
|
std::queue<uint16_t> _keyboard_queue;
|
||||||
SDL_Rect _mouse_rect;
|
SDL_Rect _mouse_rect;
|
||||||
SDL_Point _mouse_finger;
|
SDL_Point _mouse_finger;
|
||||||
float _mouse_size;
|
float _mouse_size = 1;
|
||||||
SpriteList _sprites;
|
SpriteList _sprites;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
# composer = auto - choose best supported driver
|
# composer = auto - choose best supported driver
|
||||||
# hardware,hw - use hardware for composition
|
# hardware,hw - use hardware for composition
|
||||||
# software,sw - use software for composition
|
# software,sw - use software for composition
|
||||||
|
# sdl_renderer_driver - help SDL to choose optimal rederer
|
||||||
|
# direct3d,direct3d11,direct3d12
|
||||||
|
# opengl,opengles2,opengles
|
||||||
|
# metal,software
|
||||||
# scale_quality = auto - best for hardware composer, nearest for software comporser
|
# scale_quality = auto - best for hardware composer, nearest for software comporser
|
||||||
# best - best scale quality (SDL = linear)
|
# best - best scale quality (SDL = linear)
|
||||||
# linear - use linear filtering (Direct3D and OpenGL)
|
# linear - use linear filtering (Direct3D and OpenGL)
|
||||||
|
@ -47,6 +51,7 @@
|
||||||
#crt_filter=auto
|
#crt_filter=auto
|
||||||
#scale_quality=auto
|
#scale_quality=auto
|
||||||
#composer=auto
|
#composer=auto
|
||||||
|
#sdl_renderer_driver=software
|
||||||
#aspect_ratio=4:3
|
#aspect_ratio=4:3
|
||||||
#cursor_size=100
|
#cursor_size=100
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue