mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-01 11:38:18 +00:00
Added support for high-dpi mode on Windows.
The platform factory for windows now calls SetProcessDPIAware in order to enable support for high-dpi modes. The relevant DllImport has been added to API.cs
This commit is contained in:
parent
c7e04c6097
commit
2e1bcaf280
|
@ -945,6 +945,30 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region SetProcessDPIAware
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the current process as dots per inch (dpi) aware.
|
||||||
|
/// Note: SetProcessDPIAware is subject to a possible race condition
|
||||||
|
/// if a DLL caches dpi settings during initialization.
|
||||||
|
/// For this reason, it is recommended that dpi-aware be set through
|
||||||
|
/// the application (.exe) manifest rather than by calling SetProcessDPIAware.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// If the function succeeds, the return value is true.
|
||||||
|
/// Otherwise, the return value is false.
|
||||||
|
/// </returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// DLLs should accept the dpi setting of the host process
|
||||||
|
/// rather than call SetProcessDPIAware themselves.
|
||||||
|
/// To be set properly, dpiAware should be specified as part
|
||||||
|
/// of the application (.exe) manifest.
|
||||||
|
/// </remarks>
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
internal static extern BOOL SetProcessDPIAware();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Input functions
|
#region Input functions
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
|
@ -39,6 +40,17 @@ namespace OpenTK.Platform.Windows
|
||||||
readonly object SyncRoot = new object();
|
readonly object SyncRoot = new object();
|
||||||
IInputDriver2 inputDriver;
|
IInputDriver2 inputDriver;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region IPlatformFactory Members
|
#region IPlatformFactory Members
|
||||||
|
|
||||||
public virtual INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
public virtual INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||||
|
|
Loading…
Reference in a new issue