Merge pull request #396 from bjornblissing/feature/DPIAwareScaling

Applications declared as DPI-aware in the Windows environment
This commit is contained in:
OpenSceneGraph git repository
2017-11-30 14:13:21 +00:00
committed by GitHub
5 changed files with 71 additions and 4 deletions

View File

@@ -19,9 +19,6 @@
#include <osgDB/FileUtils>
#ifdef WIN32
#if !defined(__MINGW32__)
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
#endif

View File

@@ -144,6 +144,26 @@ static CloseTouchInputHandleFunc *closeTouchInputHandleFunc = NULL;
static GetTouchInputInfoFunc *getTouchInputInfoFunc = NULL;
static GetPointerTypeFunc *getPointerTypeFunc = NULL;
// DPI Awareness
#if(WINVER >= 0x0603)
#ifndef DPI_ENUMS_DECLARED
typedef enum PROCESS_DPI_AWARENESS {
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;
#endif // DPI_ENUMS_DECLARED
typedef
BOOL
(WINAPI SetProcessDpiAwarenessFunc(
PROCESS_DPI_AWARENESS dpi_awareness));
static SetProcessDpiAwarenessFunc *setProcessDpiAwareness = NULL;
#endif
@@ -765,6 +785,21 @@ Win32WindowingSystem::Win32WindowingSystem()
FreeLibrary( hModule);
}
}
#if(WINVER >= 0x0603)
// For Windows 8.1 and higher
//
// Per monitor DPI aware.This app checks for the DPI when it is created and adjusts the scale factor
// whenever the DPI changes.These applications are not automatically scaled by the system.
HMODULE hModuleShore = LoadLibrary("Shcore");
if (hModuleShore) {
setProcessDpiAwareness = (SetProcessDpiAwarenessFunc *) GetProcAddress(hModuleShore, "SetProcessDpiAwareness");
if (setProcessDpiAwareness) {
(*setProcessDpiAwareness)(PROCESS_DPI_AWARENESS::PROCESS_PER_MONITOR_DPI_AWARE);
}
}
#endif
}
Win32WindowingSystem::~Win32WindowingSystem()