Encompass-FNA-Template/ProjectName/Program.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2020-03-03 23:18:34 +00:00
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace ProjectName
{
2022-08-30 04:39:34 +00:00
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDllDirectory(string lpPathName);
2020-03-03 23:18:34 +00:00
2022-08-30 04:39:34 +00:00
static void Main(string[] args)
{
// https://github.com/FNA-XNA/FNA/wiki/4:-FNA-and-Windows-API#64-bit-support
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetDllDirectory(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitProcess ? "x64" : "x86"
));
}
2020-03-03 23:18:34 +00:00
2022-08-30 04:39:34 +00:00
// https://github.com/FNA-XNA/FNA/wiki/7:-FNA-Environment-Variables#fna_graphics_enable_highdpi
// NOTE: from documentation:
// Lastly, when packaging for macOS, be sure this is in your app bundle's Info.plist:
// <key>NSHighResolutionCapable</key>
// <string>True</string>
Environment.SetEnvironmentVariable("FNA_GRAPHICS_ENABLE_HIGHDPI", "1");
2020-03-03 23:18:34 +00:00
2022-08-30 04:39:34 +00:00
using (ProjectNameGame game = new ProjectNameGame())
{
bool isHighDPI = Environment.GetEnvironmentVariable("FNA_GRAPHICS_ENABLE_HIGHDPI") == "1";
if (isHighDPI)
Debug.WriteLine("HiDPI Enabled");
2020-03-03 23:18:34 +00:00
2022-08-30 04:39:34 +00:00
game.Run();
}
}
}
2020-03-03 23:18:34 +00:00
}