initial commit

master
Evan Hemsley 2020-03-03 15:18:34 -08:00
commit 181d21dd55
12 changed files with 1079 additions and 0 deletions

351
.gitignore vendored Normal file
View File

@ -0,0 +1,351 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "FNA"]
path = FNA
url = https://github.com/FNA-XNA/FNA.git

20
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Core Debugger",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build: Core Debug",
"program": "${workspaceFolder}/ProjectName/bin/Debug/netcoreapp3.1/ProjectName.dll",
"args": [],
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/netcoreapp3.1/lib64",
"DYLD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/netcoreapp3.1/osx"
},
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}

249
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,249 @@
{
"version": "2.0.0",
"options": {
"cwd": "${workspaceRoot}"
},
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d",
"/c"
]
}
}
},
"presentation": {
"reveal": "always",
"focus": true,
"panel": "shared"
},
"tasks": [
{
"label": "Build: Framework Release",
"command": "msbuild",
"args": [
"-restore:True",
"${workspaceFolder}/ProjectName.Framework.sln",
"-p:Configuration=Release"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
},
{
"label": "Run: Framework Release",
"command": "mono",
"args": [
"${workspaceFolder}/ProjectName/bin/Release/net461/ProjectName.exe"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Release/net461/lib64",
"DYLD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Release/net461/osx"
}
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Framework Release",
"dependsOn": [
"Build: Framework Release",
"Run: Framework Release"
],
"dependsOrder": "sequence",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build: Framework Debug",
"command": "msbuild",
"args": [
"-restore:True",
"${workspaceFolder}/ProjectName.Framework.sln",
"-p:Configuration=Debug"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Run: Framework Debug",
"command": "mono",
"args": [
"${workspaceFolder}/ProjectName/bin/Debug/net461/ProjectName.exe"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/net461/lib64",
"DYLD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/net461/osx"
}
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Framework Debug",
"dependsOn": [
"Build: Framework Debug",
"Run: Framework Debug"
],
"dependsOrder": "sequence",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Valgrind: Framework Debug",
"command": "valgrind",
"args": [
"-v",
"--vgdb-error=0",
"--leak-check=full",
"--log-file=${workspaceFolder}/valgrind.log",
"--smc-check=all",
"--suppressions=${workspaceFolder}/mono.supp",
"mono",
"--debug",
"${workspaceFolder}/ProjectName/bin/Debug/net461/ProjectName.exe"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/net461/lib64"
}
},
"type": "shell",
"dependsOn": [
"Build: Framework Debug"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Core Debug",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"Build: Core Debug",
"Run: Core Debug"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build: Core Debug",
"command": "dotnet",
"args": [
"build",
"./ProjectName.Core.sln",
"-f",
"netcoreapp3.1"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Run: Core Debug",
"command": "dotnet",
"args": [
"${workspaceFolder}/ProjectName/bin/Debug/netcoreapp3.1/ProjectName.dll"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/netcoreapp3.1/lib64",
"DYLD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Debug/netcoreapp3.1/osx"
}
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build: Core Release",
"command": "dotnet",
"args": [
"build",
"./ProjectName.sln",
"--configuration",
"Release",
"-f",
"netcoreapp3.1"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Run: Core Release",
"command": "dotnet",
"args": [
"${workspaceFolder}/ProjectName/bin/Release/netcoreapp3.1/ProjectName.dll"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Release/netcoreapp3.1/lib64",
"DYLD_LIBRARY_PATH": "${workspaceFolder}/ProjectName/bin/Release/netcoreapp3.1/osx"
}
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Core Release",
"dependsOrder": "sequence",
"dependsOn": [
"Build: Core Release",
"Run: Core Release"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}

1
FNA Submodule

@ -0,0 +1 @@
Subproject commit 3828068cfeae66e050769ba53ec5b254da78ce7e

34
ProjectName.Framework.sln Normal file
View File

@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNATemplate.Framework", "ProjectName\ProjectName.Framework.csproj", "{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x64.ActiveCfg = Debug|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x64.Build.0 = Debug|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x86.ActiveCfg = Debug|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x86.Build.0 = Debug|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|Any CPU.Build.0 = Release|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x64.ActiveCfg = Release|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x64.Build.0 = Release|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x86.ActiveCfg = Release|Any CPU
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

259
ProjectName/DllMap.cs Normal file
View File

@ -0,0 +1,259 @@
// only works in .NET Core. disable in .NET framework
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Xml.Linq;
public static class DllMap
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDefaultDllDirectories(int directoryFlags);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern void AddDllDirectory(string lpPathName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDllDirectory(string lpPathName);
const int LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000;
public static Dictionary<string, string> MapDictionary;
public static string OS;
public static string CPU;
public static bool Optimise;
public static void Initialise(bool optimise = true)
{
Optimise = optimise;
// Our executabe needs to know how to find the native libraries
// For Windows, we can set this to be x86 or x64 directory at runtime (below)
// For Linux we need to move our native libraries to 'netcoredeps' which is set by .net core
// For OSX we need to set an environment variable (DYLD_LIBRARY_PATH) outside of the process by a script
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
try
{
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
AddDllDirectory(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitProcess ? "x64" : "x86"
));
}
catch
{
// Pre-Windows 7, KB2533623
SetDllDirectory(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitProcess ? "x64" : "x86"
));
}
}
// .NET Core also doesn't use DllImport but we can replicate this using NativeLibrary as per below
// Uses FNA.dll.config to dictate what the name of the native library is per platform and architecture
var fnaAssembly = Assembly.GetAssembly(typeof(Microsoft.Xna.Framework.Graphics.ColorWriteChannels));
DllMap.Register(fnaAssembly);
}
// Register a call-back for native library resolution.
public static void Register(Assembly assembly)
{
NativeLibrary.SetDllImportResolver(assembly, MapAndLoad);
// Do setup so that MapLibraryName is faster than reading the XML each time
// 1) Get platform & cpu
OS = GetCurrentPlatform().ToString().ToLowerInvariant();
CPU = GetCurrentRuntimeArchitecture().ToString().ToLowerInvariant();
// 2) Setup MapDictionary
// For Windows use hardcoded values
// Why? This is our development platform and we wanted the fastest start time possible (eliminates XML Load)
if (OS == "windows" && Optimise)
{
MapDictionary = new Dictionary<string, string>();
MapDictionary.Add("SDL2", "SDL2.dll");
MapDictionary.Add("SDL_image", "SDL_image.dll");
MapDictionary.Add("FAudio", "FAudio.dll");
}
else
{
// For every other platform use XML file
// Read in config XML and only store details we're interested in within MapDictionary
string xmlPath = Path.Combine(Path.GetDirectoryName(assembly.Location),
Path.GetFileNameWithoutExtension(assembly.Location) + ".dll.config");
if (!File.Exists(xmlPath))
{
Console.WriteLine($"=== Cannot find XML: " + xmlPath);
return;
}
XElement root = XElement.Load(xmlPath);
MapDictionary = new Dictionary<string, string>();
ParseXml(root, true); // Direct match on OS & CPU first
ParseXml(root, false); // Loose match on CPU second (won't allow duplicates)
}
}
private static void ParseXml(XElement root, bool matchCPU)
{
foreach (var el in root.Elements("dllmap"))
{
// Ignore entries for other OSs
if (el.Attribute("os").ToString().IndexOf(OS) < 0)
continue;
// Ignore entries for other CPUs
if (matchCPU)
{
if (el.Attribute("cpu") == null)
continue;
if (el.Attribute("cpu").ToString().IndexOf(CPU) < 0)
continue;
}
else
{
if (el.Attribute("cpu") != null && el.Attribute("cpu").ToString().IndexOf(CPU) < 0)
continue;
}
string oldLib = el.Attribute("dll").Value;
string newLib = el.Attribute("target").Value;
if (string.IsNullOrWhiteSpace(oldLib) || string.IsNullOrWhiteSpace(newLib))
continue;
// Don't allow duplicates
if (MapDictionary.ContainsKey(oldLib))
continue;
MapDictionary.Add(oldLib, newLib);
}
}
// The callback: which loads the mapped libray in place of the original
private static IntPtr MapAndLoad(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath)
{
string mappedName = null;
mappedName = MapLibraryName(assembly.Location, libraryName, out mappedName) ? mappedName : libraryName;
return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath);
}
// Parse the assembly.xml file, and map the old name to the new name of a library.
private static bool MapLibraryName(string assemblyLocation, string originalLibName, out string mappedLibName)
{
if (MapDictionary.TryGetValue(originalLibName, out mappedLibName))
return true;
else
return false;
}
// Below pinched from Mono.DllMap project: https://github.com/Firwood-Software/AdvancedDLSupport/tree/1b7394211a655b2f77649ce3b610a3161215cbdc/Mono.DllMap
public static DllMapOS GetCurrentPlatform()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return DllMapOS.Linux;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return DllMapOS.Windows;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return DllMapOS.OSX;
}
var operatingDesc = RuntimeInformation.OSDescription.ToUpperInvariant();
foreach (var system in Enum.GetValues(typeof(DllMapOS)).Cast<DllMapOS>()
.Except(new[] { DllMapOS.Linux, DllMapOS.Windows, DllMapOS.OSX }))
{
if (operatingDesc.Contains(system.ToString().ToUpperInvariant()))
{
return system;
}
}
throw new PlatformNotSupportedException($"Couldn't detect platform: {RuntimeInformation.OSDescription}");
}
public static DllMapArchitecture GetCurrentRuntimeArchitecture()
{
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm:
{
return DllMapArchitecture.ARM;
}
case Architecture.X64:
{
return DllMapArchitecture.x86_64;
}
case Architecture.X86:
{
return DllMapArchitecture.x86;
}
}
typeof(object).Module.GetPEKind(out _, out var machine);
switch (machine)
{
case ImageFileMachine.I386:
{
return DllMapArchitecture.x86;
}
case ImageFileMachine.AMD64:
{
return DllMapArchitecture.x86_64;
}
case ImageFileMachine.ARM:
{
return DllMapArchitecture.ARM;
}
case ImageFileMachine.IA64:
{
return DllMapArchitecture.IA64;
}
}
throw new PlatformNotSupportedException("Couldn't detect the current architecture.");
}
public enum DllMapOS
{
Linux = 1 << 0,
OSX = 1 << 1,
Solaris = 1 << 2,
FreeBSD = 1 << 3,
OpenBSD = 1 << 4,
NetBSD = 1 << 5,
Windows = 1 << 6,
AIX = 1 << 7,
HPUX = 1 << 8
}
public enum DllMapArchitecture
{
x86 = 1 << 0,
x86_64 = 1 << 1,
SPARC = 1 << 2,
PPC = 1 << 3,
S390 = 1 << 4,
S390X = 1 << 5,
ARM = 1 << 6,
ARMV8 = 1 << 7,
MIPS = 1 << 8,
Alpha = 1 << 9,
HPPA = 1 << 10,
IA64 = 1 << 11
}
}

47
ProjectName/Program.cs Normal file
View File

@ -0,0 +1,47 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace ProjectName
{
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDllDirectory(string lpPathName);
static void Main(string[] args)
{
#if NETCOREAPP
DllMap.Initialise(false);
#endif
// 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"
));
}
// 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");
using (ProjectNameGame game = new ProjectNameGame())
{
bool isHighDPI = Environment.GetEnvironmentVariable("FNA_GRAPHICS_ENABLE_HIGHDPI") == "1";
if (isHighDPI)
Debug.WriteLine("HiDPI Enabled");
game.Run();
}
}
}
}

View File

@ -0,0 +1,32 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net461</TargetFramework>
<TargetName>ProjectName</TargetName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>8.0</LangVersion>
<StartupObject>ProjectName.Program</StartupObject>
<AssemblyName>ProjectName</AssemblyName>
<RootNamespace>ProjectName</RootNamespace>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<ApplicationIcon/>
</PropertyGroup>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);DllMap.cs</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<Content Include="Content\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FNA\FNA.csproj"/>
</ItemGroup>
<Import Project="..\build\CopyFNALibs.targets"/>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
</Project>

View File

@ -0,0 +1,52 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace ProjectName
{
class ProjectNameGame : Game
{
GraphicsDeviceManager graphics;
public ProjectNameGame()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
graphics.PreferMultiSampling = true;
Content.RootDirectory = "Content";
Window.AllowUserResizing = true;
IsMouseVisible = true;
}
protected override void LoadContent()
{
base.LoadContent();
}
protected override void UnloadContent()
{
base.UnloadContent();
}
protected override void Update(GameTime gameTime)
{
//
// Insert your game update logic here.
//
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
//
// Replace this with your own drawing code.
//
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
}

27
build/CopyFNALibs.targets Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="..\fnalibs\x86\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x64'">
<Link>x86\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\x64\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x86'">
<Link>x64\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\osx\**\*.*" Condition="'$(OS)' != 'Windows_NT'" >
<Link>osx\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\lib\**\*.*" Condition="'$(OS)' != 'Windows_NT'" >
<Link>lib\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\lib64\**\*.*" Condition="'$(OS)' != 'Windows_NT'" >
<Link>lib64\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

4
fnalibs/README.md Normal file
View File

@ -0,0 +1,4 @@
Put your fnalibs here.
If you don't have fnalibs, the link is located on this wiki page:
https://github.com/FNA-XNA/FNA/wiki/1:-Download-and-Update-FNA