From 2c6d41c87a895f1c97a15e62a8b1047153d29e96 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Wed, 13 Nov 2024 11:16:30 -0500 Subject: [PATCH] macOS: Fix issue causing only part of the window to be rendered to (#3756) The fundamental issue is related to hiDPI / Retina displays, I don't think our rendering code is setup properly to handle the scaling between the two (which you can derive by comparing `SDL_GetWindowSize` and `SDL_GL_GetDrawableSize`). So rather than opening that can of worms, I just removed the window flag. Also fixed an unrelated issue for displaying resolution options when in windowed mode, it was previously only adding options to the list if they were invalid for full-screen. Fixes #3099 --- game/graphics/pipelines/opengl.cpp | 7 ++++--- game/system/hid/display_manager.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index f1e1dbb9a8..83fd439afa 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -220,9 +220,10 @@ static std::shared_ptr gl_make_display(int width, // TODO - SDL2 doesn't seem to support HDR (and neither does windows) // Related - // https://answers.microsoft.com/en-us/windows/forum/all/hdr-monitor-low-brightness-after-exiting-full/999f7ee9-7ba3-4f9c-b812-bbeb9ff8dcc1 - SDL_Window* window = - SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, - SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); + SDL_Window* window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + // TODO - rendering code on hiDPI/Retina displays is not adequate, solve it properly so that + // `SDL_WINDOW_ALLOW_HIGHDPI` can be added back to the window flags. prof().end_event(); if (!window) { sdl_util::log_error("gl_make_display failed - Could not create display window"); diff --git a/game/system/hid/display_manager.cpp b/game/system/hid/display_manager.cpp index dc510b31c9..f74a2c26bf 100644 --- a/game/system/hid/display_manager.cpp +++ b/game/system/hid/display_manager.cpp @@ -404,6 +404,7 @@ void DisplayManager::update_resolutions() { } lg::info("[DISPLAY]: {}x{} is supported", new_res.width, new_res.height); m_available_resolutions.push_back(new_res); + m_available_window_sizes.push_back(new_res); } // Sort by area @@ -411,7 +412,7 @@ void DisplayManager::update_resolutions() { [](const Resolution& a, const Resolution& b) -> bool { return a.width * a.height > b.width * b.height; }); - std::sort(m_available_resolutions.begin(), m_available_resolutions.end(), + std::sort(m_available_window_sizes.begin(), m_available_window_sizes.end(), [](const Resolution& a, const Resolution& b) -> bool { return a.width * a.height > b.width * b.height; });