DPI-scaling should affect resolution

The correct resolution will now be reported depending on whether the
application is DPI-aware.
This commit is contained in:
Stefanos A. 2013-12-02 23:37:00 +01:00
parent d215075bff
commit c480911843
2 changed files with 17 additions and 4 deletions

View file

@ -1625,6 +1625,7 @@ namespace OpenTK.Platform.Windows
internal const byte PFD_UNDERLAY_PLANE = unchecked((byte)-1);
// Device mode types (found in wingdi.h)
internal const int DM_LOGPIXELS = 0x00020000;
internal const int DM_BITSPERPEL = 0x00040000;
internal const int DM_PELSWIDTH = 0x00080000;
internal const int DM_PELSHEIGHT = 0x00100000;

View file

@ -124,10 +124,12 @@ namespace OpenTK.Platform.Windows
{
VerifyMode(dev1, monitor_mode);
float scale = GetScale(ref monitor_mode);
opentk_dev_current_res = new DisplayResolution(
monitor_mode.Position.X, monitor_mode.Position.Y,
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
(int)(monitor_mode.Position.X / scale), (int)(monitor_mode.Position.Y / scale),
(int)(monitor_mode.PelsWidth / scale), (int)(monitor_mode.PelsHeight / scale),
monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);
opentk_dev_primary =
(dev1.StateFlags & DisplayDeviceStateFlags.PrimaryDevice) != DisplayDeviceStateFlags.None;
}
@ -138,9 +140,10 @@ namespace OpenTK.Platform.Windows
{
VerifyMode(dev1, monitor_mode);
float scale = GetScale(ref monitor_mode);
DisplayResolution res = new DisplayResolution(
monitor_mode.Position.X, monitor_mode.Position.Y,
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
(int)(monitor_mode.Position.X / scale), (int)(monitor_mode.Position.Y / scale),
(int)(monitor_mode.PelsWidth / scale), (int)(monitor_mode.PelsHeight / scale),
monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);
opentk_dev_available_res.Add(res);
@ -167,6 +170,15 @@ namespace OpenTK.Platform.Windows
}
}
private float GetScale(ref DeviceMode monitor_mode)
{
float scale = 1.0f;
if ((monitor_mode.Fields & Constants.DM_LOGPIXELS) != 0)
{
scale = monitor_mode.LogPixels / 96.0f;
}
return scale;
}
static void VerifyMode(WindowsDisplayDevice device, DeviceMode mode)
{