diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index f12e533a..9fc7dd09 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -761,6 +761,7 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation) { setupConsole("Vulkan validation output"); } + setupDPIAwareness(); #endif } @@ -1002,6 +1003,25 @@ void VulkanExampleBase::setupConsole(std::string title) SetConsoleTitle(TEXT(title.c_str())); } +void VulkanExampleBase::setupDPIAwareness() +{ + using SetProcessDpiAwarenessFunc = HRESULT(*)(PROCESS_DPI_AWARENESS); + + HMODULE shCore = LoadLibraryA("Shcore.dll"); + if (shCore) + { + SetProcessDpiAwarenessFunc setProcessDpiAwareness = + (SetProcessDpiAwarenessFunc)GetProcAddress(shCore, "SetProcessDpiAwareness"); + + if (setProcessDpiAwareness != nullptr) + { + setProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); + } + + FreeLibrary(shCore); + } +} + HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc) { this->windowInstance = hinstance; diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 5680fb74..547dd58d 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -13,6 +13,7 @@ #include #include #include +#include #elif defined(VK_USE_PLATFORM_ANDROID_KHR) #include #include @@ -254,6 +255,7 @@ public: #if defined(_WIN32) void setupConsole(std::string title); + void setupDPIAwareness(); HWND setupWindow(HINSTANCE hinstance, WNDPROC wndproc); void handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); #elif defined(VK_USE_PLATFORM_ANDROID_KHR)