diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index b1cb6ce9d..6905a8856 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -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()