From dae2a5e857735e6e5242c2c4acd2b5128b8b95db Mon Sep 17 00:00:00 2001 From: David Chavez Date: Mon, 17 Jun 2024 11:00:09 +0200 Subject: [PATCH] Allow high dpi window --- include/zelda_config.h | 2 ++ lib/N64ModernRuntime | 2 +- src/game/config.cpp | 4 ++++ src/main/main.cpp | 14 +++++++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/zelda_config.h b/include/zelda_config.h index f5b206a..9bd9b86 100644 --- a/include/zelda_config.h +++ b/include/zelda_config.h @@ -12,6 +12,8 @@ namespace zelda64 { // TODO: Move loading configs to the runtime once we have a way to allow per-project customization. void load_config(); void save_config(); + + bool is_steam_deck(); void reset_input_bindings(); void reset_cont_input_bindings(); diff --git a/lib/N64ModernRuntime b/lib/N64ModernRuntime index 0c1811c..c916277 160000 --- a/lib/N64ModernRuntime +++ b/lib/N64ModernRuntime @@ -1 +1 @@ -Subproject commit 0c1811ca6f8291c6608f1d6626a73e863902ece9 +Subproject commit c91627740f958b0902f96ea6c579e690b1fef7a1 diff --git a/src/game/config.cpp b/src/game/config.cpp index ece24b6..0271013 100644 --- a/src/game/config.cpp +++ b/src/game/config.cpp @@ -493,3 +493,7 @@ void zelda64::save_config() { save_controls_config(recomp_dir / controls_filename); save_sound_config(recomp_dir / sound_filename); } + +bool zelda64::is_steam_deck() { + return ::is_steam_deck; +} diff --git a/src/main/main.cpp b/src/main/main.cpp index d3961a2..62b3454 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -120,7 +120,19 @@ bool SetImageAsIcon(const char* filename, SDL_Window* window) SDL_Window* window; ultramodern::renderer::WindowHandle create_window(ultramodern::gfx_callbacks_t::gfx_data_t) { - window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, SDL_WINDOW_RESIZABLE ); + uint32_t window_type = 0; + + float dpi_scale = 1; + if (!zelda64::is_steam_deck()) { + float ddpi, hdpi, vdpi; + SDL_GetDisplayDPI(0, &ddpi, &hdpi, &vdpi); + window_type |= SDL_WINDOW_ALLOW_HIGHDPI; + dpi_scale = ddpi / 96; + } + + auto res_width_dpi_scale = static_cast(800 * dpi_scale); + auto res_height_dpi_scale = static_cast(480 * dpi_scale); + window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, res_width_dpi_scale, res_height_dpi_scale, window_type | SDL_WINDOW_RESIZABLE ); #if defined(__linux__) SetImageAsIcon("icons/512.png",window); if (ultramodern::renderer::get_graphics_config().wm_option == ultramodern::renderer::WindowMode::Fullscreen) { // TODO: Remove once RT64 gets native fullscreen support on Linux