Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made DPI-awareness configurable (issue #6)

It is now possible to indicate that an application is not DPI-aware. In
that case, OpenTK will let the operating system handle DPI scaling. This
results in worse visuals (pixel doubling) but allows non DPI-aware
applications to continue working.
  • Loading branch information...
commit 1475b3d42710d57278cd4762652253585b078663 1 parent 32a5e0f
@thefiddler thefiddler authored
View
5 Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs
@@ -79,7 +79,10 @@ class Sdl2NativeWindow : INativeWindow, IInputDriver
flags |= WindowFlags.OPENGL;
flags |= WindowFlags.RESIZABLE;
flags |= WindowFlags.HIDDEN;
- flags |= WindowFlags.ALLOW_HIGHDPI;
+ if (Toolkit.Options.EnableHighResolution)
+ {
+ flags |= WindowFlags.ALLOW_HIGHDPI;
+ }
if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 ||
(flags & WindowFlags.FULLSCREEN) != 0)
View
11 Source/OpenTK/Platform/Windows/WinFactory.cs
@@ -50,10 +50,13 @@ public WinFactory()
if (System.Environment.OSVersion.Version.Major >= 6)
{
- // Enable high-dpi support
- // Only available on Windows Vista and higher
- bool result = Functions.SetProcessDPIAware();
- Debug.Print("SetProcessDPIAware() returned {0}", result);
+ if (Toolkit.Options.EnableHighResolution)
+ {
+ // Enable high-dpi support
+ // Only available on Windows Vista and higher
+ bool result = Functions.SetProcessDPIAware();
+ Debug.Print("SetProcessDPIAware() returned {0}", result);
+ }
}
}
View
7 Source/OpenTK/Toolkit.cs
@@ -134,6 +134,7 @@ public static Toolkit Init(ToolkitOptions options)
{
initialized = true;
Configuration.Init(options);
+ Options = options;
// The actual initialization takes place in the
// platform-specific factory constructors.
@@ -145,6 +146,12 @@ public static Toolkit Init(ToolkitOptions options)
#endregion
+ #region Internal Members
+
+ internal static ToolkitOptions Options { get; private set; }
+
+ #endregion
+
#region IDisposable Members
/// <summary>
View
11 Source/OpenTK/ToolkitOptions.cs
@@ -68,6 +68,7 @@ public class ToolkitOptions
static ToolkitOptions()
{
Default = new ToolkitOptions();
+ Default.EnableHighResolution = false;
}
/// <summary>
@@ -77,6 +78,16 @@ static ToolkitOptions()
public PlatformBackend Backend { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether high
+ /// resolution modes are supported on high-DPI
+ /// ("Retina") displays. Enabled by default.
+ /// Set to false for applications that are not
+ /// DPI-aware (e.g. WinForms.)
+ /// </summary>
+ /// <seealso cref="http://msdn.microsoft.com/en-us/library/windows/desktop/ee308410(v=vs.85).aspx"/>
+ public bool EnableHighResolution { get; set; }
+
+ /// <summary>
/// Gets a <c>ToolkitOptions</c> instance with
/// default values.
/// </summary>
Please sign in to comment.
Something went wrong with that request. Please try again.