Fixed centering for non DPI-aware applications

This commit is contained in:
Stefanos A. 2013-12-02 23:37:22 +01:00
parent c480911843
commit 58ab194ba8

View file

@ -124,23 +124,24 @@ namespace OpenTK.Platform.Windows
// Move(this, EventArgs.Empty); // Move(this, EventArgs.Empty);
//}; //};
// CreateWindow takes values in pixels. int scale_width = width;
// According to the high-dpi guidelines, int scale_height = height;
// we need to scale these values by the
// current DPI.
// Search MSDN for "How to Ensure That
// Your Application Displays Properly on
// High-DPI Displays"
int scale_width = ScaleX(width);
int scale_height = ScaleY(height);
int scale_x = x; int scale_x = x;
int scale_y = y; int scale_y = y;
// If width or height were scaled, re-calculate if (Toolkit.Options.EnableHighResolution)
// the x and y coordinates to compensate {
if (width != scale_width) // CreateWindow takes values in pixels.
scale_x = x - UnscaleX(scale_width - width); // According to the high-dpi guidelines,
if (height != scale_height) // we need to scale these values by the
scale_y = y - UnscaleY(scale_height - height); // current DPI.
// Search MSDN for "How to Ensure That
// Your Application Displays Properly on
// High-DPI Displays"
scale_width = ScaleX(width);
scale_height = ScaleY(height);
scale_x = ScaleX(x);
scale_y = ScaleY(y);
}
// To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be // To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be
// bound to the top-level window, but rather to a child window docked in the parent. // bound to the top-level window, but rather to a child window docked in the parent.