More correct way to enabled DPI awareness
This commit is contained in:
parent
df1c09235f
commit
5f5f29fa68
2 changed files with 22 additions and 2 deletions
|
|
@ -761,8 +761,7 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation)
|
|||
{
|
||||
setupConsole("Vulkan validation output");
|
||||
}
|
||||
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
|
||||
setupDPIAwareness();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1004,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;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <windows.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <ShellScalingAPI.h>
|
||||
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
#include <android/native_activity.h>
|
||||
#include <android/asset_manager.h>
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue