Enable High DPI mode in SDL (#490)

This commit is contained in:
David Chavez 2022-06-17 03:08:47 +02:00 committed by GitHub
parent ac8acaeba4
commit 587c46cacf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,8 +34,8 @@ static SDL_Window *wnd;
static SDL_GLContext ctx;
static int inverted_scancode_table[512];
static int vsync_enabled = 0;
static unsigned int window_width = DESIRED_SCREEN_WIDTH;
static unsigned int window_height = DESIRED_SCREEN_HEIGHT;
static int window_width = DESIRED_SCREEN_WIDTH;
static int window_height = DESIRED_SCREEN_HEIGHT;
static bool fullscreen_state;
static void (*on_fullscreen_changed_callback)(bool is_now_fullscreen);
static bool (*on_key_down_callback)(int scancode);
@ -145,7 +145,8 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) {
int len = sprintf(title, "%s (%s)", game_name, GFX_API_NAME);
wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
if (start_in_fullscreen) {
set_fullscreen(true, false);
@ -244,8 +245,7 @@ static void gfx_sdl_handle_events(void) {
#endif
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
window_width = event.window.data1;
window_height = event.window.data2;
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
}
break;
case SDL_QUIT: