From 82c84d80ccc2ed6593423b33f5105894ef840a75 Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Sun, 14 Jul 2024 12:21:17 +0200 Subject: [PATCH] Update high DPI handling --- src/core/Core/Application.cpp | 5 ++++- src/core/Core/Window.cpp | 1 - src/core/Platform/Linux/DPIHandler.cpp | 5 ----- src/core/Platform/Mac/DPIHandler.cpp | 7 ------- src/core/Platform/Windows/DPIHandler.cpp | 5 ----- vendor/CMakeLists.txt | 2 +- 6 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/core/Core/Application.cpp b/src/core/Core/Application.cpp index 02a870f..21b7b32 100644 --- a/src/core/Core/Application.cpp +++ b/src/core/Core/Application.cpp @@ -147,9 +147,12 @@ ExitStatus App::Application::run() { // Rendering ImGui::Render(); + SDL_RenderSetScale(m_window->get_native_renderer(), + io.DisplayFramebufferScale.x, + io.DisplayFramebufferScale.y); SDL_SetRenderDrawColor(m_window->get_native_renderer(), 100, 100, 100, 255); SDL_RenderClear(m_window->get_native_renderer()); - ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData()); + ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), m_window->get_native_renderer()); SDL_RenderPresent(m_window->get_native_renderer()); } diff --git a/src/core/Core/Window.cpp b/src/core/Core/Window.cpp index 12a8201..0728d51 100644 --- a/src/core/Core/Window.cpp +++ b/src/core/Core/Window.cpp @@ -33,7 +33,6 @@ Window::Window(const Settings& settings) { SDL_RendererInfo info; SDL_GetRendererInfo(m_renderer, &info); - DPIHandler::set_render_scale(m_renderer); APP_DEBUG("Current SDL_Renderer: {}", info.name); } diff --git a/src/core/Platform/Linux/DPIHandler.cpp b/src/core/Platform/Linux/DPIHandler.cpp index 707ba1d..c26a5dc 100644 --- a/src/core/Platform/Linux/DPIHandler.cpp +++ b/src/core/Platform/Linux/DPIHandler.cpp @@ -26,11 +26,6 @@ WindowSize DPIHandler::get_dpi_aware_window_size(const Window::Settings& setting return {settings.width, settings.height}; } -void DPIHandler::set_render_scale([[maybe_unused]] SDL_Renderer* renderer) { - APP_PROFILE_FUNCTION(); - // do nothing -} - void DPIHandler::set_global_font_scaling([[maybe_unused]] ImGuiIO* io) { APP_PROFILE_FUNCTION(); // do nothing diff --git a/src/core/Platform/Mac/DPIHandler.cpp b/src/core/Platform/Mac/DPIHandler.cpp index eb86229..389d29e 100644 --- a/src/core/Platform/Mac/DPIHandler.cpp +++ b/src/core/Platform/Mac/DPIHandler.cpp @@ -30,13 +30,6 @@ WindowSize DPIHandler::get_dpi_aware_window_size(const Window::Settings& setting return {settings.width, settings.height}; } -void DPIHandler::set_render_scale(SDL_Renderer* renderer) { - APP_PROFILE_FUNCTION(); - - auto scale{get_scale()}; - SDL_RenderSetScale(renderer, scale, scale); -} - void DPIHandler::set_global_font_scaling(ImGuiIO* io) { APP_PROFILE_FUNCTION(); diff --git a/src/core/Platform/Windows/DPIHandler.cpp b/src/core/Platform/Windows/DPIHandler.cpp index 0d7e52d..9f038a1 100644 --- a/src/core/Platform/Windows/DPIHandler.cpp +++ b/src/core/Platform/Windows/DPIHandler.cpp @@ -29,11 +29,6 @@ WindowSize DPIHandler::get_dpi_aware_window_size(const Window::Settings& setting return {width, height}; } -void DPIHandler::set_render_scale([[maybe_unused]] SDL_Renderer* renderer) { - APP_PROFILE_FUNCTION(); - // do nothing -} - void DPIHandler::set_global_font_scaling([[maybe_unused]] ImGuiIO* io) { APP_PROFILE_FUNCTION(); // do nothing diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index a3b0e87..5c368aa 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -17,7 +17,7 @@ FetchContent_Declare( FetchContent_Declare( imgui GIT_REPOSITORY "https://github.com/ocornut/imgui.git" - GIT_TAG 527b2c45af2f8964f95826bd16ab7c7ed372ae41 # Branch: docking, date: 02.07.2024, 19:05 GMT+1 + GIT_TAG 527b2c45af2f8964f95826bd16ab7c7ed372ae41 # Branch: docking, date: 02.07.2024, 19:05 GMT+2 ) FetchContent_Declare(