From 9e8dc702403e7a9e8f4d59aa94204c7b66732068 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 12 Sep 2017 11:18:16 -0300 Subject: [PATCH] HiDPI support on Windows.. yes this is all it took. --- platform/windows/os_windows.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index cee54ff69f8..b2b33cce030 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -937,6 +937,13 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau return (dpiX + dpiY) / 2; } +typedef enum _SHC_PROCESS_DPI_AWARENESS { + SHC_PROCESS_DPI_UNAWARE = 0, + SHC_PROCESS_SYSTEM_DPI_AWARE = 1, + SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2 +} SHC_PROCESS_DPI_AWARENESS; + + void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { main_loop = NULL; @@ -944,6 +951,21 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int WNDCLASSEXW wc; + if (is_hidpi_allowed()) { + HMODULE Shcore = LoadLibraryW(L"Shcore.dll");; + + if (Shcore != NULL) { + typedef HRESULT (WINAPI *SetProcessDpiAwareness_t)(SHC_PROCESS_DPI_AWARENESS); + + SetProcessDpiAwareness_t SetProcessDpiAwareness = (SetProcessDpiAwareness_t)GetProcAddress(Shcore, "SetProcessDpiAwareness"); + + if (SetProcessDpiAwareness) { + SetProcessDpiAwareness(SHC_PROCESS_SYSTEM_DPI_AWARE); + } + } + } + + video_mode = p_desired; //printf("**************** desired %s, mode %s\n", p_desired.fullscreen?"true":"false", video_mode.fullscreen?"true":"false"); RECT WindowRect;