Skip to content

Commit

Permalink
Change: Alter init of OpenTK, to attempt to workaround HiDPI issues o…
Browse files Browse the repository at this point in the history
…n Win32

#1104
#1066
  • Loading branch information
leezer3 committed Jan 8, 2025
1 parent 3e2c268 commit cfb56ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
27 changes: 15 additions & 12 deletions source/ObjectViewer/ProgramS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,20 @@ internal static void Main(string[] args)

CurrentRoute = new CurrentRoute(CurrentHost, Renderer);
Options.LoadOptions();
Renderer = new NewRenderer(CurrentHost, Interface.CurrentOptions, FileSystem);
// n.b. Init the toolkit before the renderer
var options = new ToolkitOptions
{
Backend = PlatformBackend.PreferX11,
};

if (CurrentHost.Platform == HostPlatform.MicrosoftWindows)
{
// We're managing our own DPI
options.EnableHighResolution = false;
SetProcessDPIAware();
}
Toolkit.Init(options);
Renderer = new NewRenderer(CurrentHost, Interface.CurrentOptions, FileSystem);


TrainManager = new TrainManager(CurrentHost, Renderer, Interface.CurrentOptions, FileSystem);
Expand Down Expand Up @@ -145,17 +158,7 @@ internal static void Main(string[] args)
}
}

var options = new ToolkitOptions
{
Backend = PlatformBackend.PreferX11
};

if (CurrentHost.Platform == HostPlatform.MicrosoftWindows)
{
// Tell Windows that the main game is managing it's own DPI
SetProcessDPIAware();
}
Toolkit.Init(options);

// --- load language ---
string folder = Program.FileSystem.GetDataFolder("Languages");
Translations.LoadLanguageFiles(folder);
Expand Down
15 changes: 12 additions & 3 deletions source/RouteViewer/ProgramR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ internal static void Main(string[] args)
FileSystem.CreateFileSystem();
Sounds = new Sounds(CurrentHost);
Options.LoadOptions();
// n.b. Init the toolkit before the renderer
var options = new ToolkitOptions
{
Backend = PlatformBackend.PreferX11,
};

if (CurrentHost.Platform == HostPlatform.MicrosoftWindows)
{
// We're managing our own DPI
options.EnableHighResolution = false;
SetProcessDPIAware();
}
Renderer = new NewRenderer(CurrentHost, Interface.CurrentOptions, FileSystem);
CurrentRoute = new CurrentRoute(CurrentHost, Renderer);
TrainManager = new TrainManager(CurrentHost, Renderer, Interface.CurrentOptions, FileSystem);
Expand Down Expand Up @@ -156,9 +168,6 @@ internal static void Main(string[] args)
SetProcessDPIAware();
}

var options = new ToolkitOptions();
options.Backend = PlatformBackend.PreferX11;
Toolkit.Init(options);
string folder = Program.FileSystem.GetDataFolder("Languages");
Translations.LoadLanguageFiles(folder);
Interface.CurrentOptions.ObjectOptimizationBasicThreshold = 1000;
Expand Down

0 comments on commit cfb56ee

Please sign in to comment.