mirror of
https://github.com/prime31/FNA-VSCode-Template.git
synced 2025-10-31 21:50:44 +07:00
Building projects and effects
This commit is contained in:
commit
af4391b54c
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.DS_Store
|
||||
FNA/
|
||||
fnalibs/
|
||||
project_name/bin/
|
||||
project_name/obj/
|
||||
33
getFNA.sh
Executable file
33
getFNA.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# getFNA
|
||||
# Clones/pulls the latest FNA from Github for use as a project reference.
|
||||
# Usage: ./getFNA
|
||||
|
||||
git --version > /dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "ERROR: Git is required to pull FNA from the command line."
|
||||
echo "Either install git or download and unzip FNA manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Downloading
|
||||
if [ ! -d "FNA" ]; then
|
||||
echo "Cloning FNA..."
|
||||
git clone https://github.com/FNA-XNA/FNA.git --recursive
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Finished cloning!"
|
||||
else
|
||||
echo "ERROR: Unable to clone successfully. Maybe try again later?"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Pulling the latest git version of FNA..."
|
||||
cd FNA
|
||||
git pull --recurse-submodules
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Finished updating!"
|
||||
else
|
||||
echo "ERROR: Unable to update."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
32
getLibs.sh
Executable file
32
getLibs.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# getLibs
|
||||
# Downloads the latest archive of pre-compiled native libraries for FNA,
|
||||
# and installs them in /usr/local/lib so Mono can easily reference them.
|
||||
# Usage: ./getLibs
|
||||
|
||||
# Downloading
|
||||
echo "Downloading latest fnalibs..."
|
||||
curl http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 > fnalibs.tar.bz2
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Finished downloading!"
|
||||
else
|
||||
echo "ERROR: Unable to download successfully. Maybe try again later?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Unzipping
|
||||
echo "Decompressing fnalibs..."
|
||||
mkdir fnalibs
|
||||
tar xjC fnalibs -f fnalibs.tar.bz2
|
||||
rm fnalibs.tar.bz2
|
||||
echo "Finished decompressing!"
|
||||
|
||||
# Copying
|
||||
echo "Copying fnalibs to /usr/local/libs..."
|
||||
cp ./fnalibs/osx/* /usr/local/lib
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully installed!"
|
||||
else
|
||||
echo "ERROR: Unable to copy fnalibs successfully."
|
||||
exit 1
|
||||
fi
|
||||
19
project_name/.vscode/buildEffects.sh
vendored
Executable file
19
project_name/.vscode/buildEffects.sh
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# Compiles all .fx files found in the project's Content directory.
|
||||
# Intended for usage with VS Code Build Tasks tooling.
|
||||
# You may need to change the path to fxc.exe depending on your installation.
|
||||
|
||||
printf "Starting build process...\n"
|
||||
|
||||
for file in `find ./Content/** -name "*.fx"` ;
|
||||
do
|
||||
# Hush, wine...
|
||||
export WINEDEBUG=fixme-all,err-all
|
||||
|
||||
# Build the effect
|
||||
wine ~/.wine/drive_c/Program\ Files/Microsoft\ DirectX\ SDK\ \(June\ 2010\)/Utilities/bin/x86/fxc.exe\
|
||||
/T fx_2_0 $file /Fo "`dirname $file`/`basename $file .fx`.fxb"
|
||||
|
||||
echo ""
|
||||
|
||||
done
|
||||
23
project_name/.vscode/launch.json
vendored
Normal file
23
project_name/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
// Change "mono" to "clr" for 64-bit .NET Framework debugging on Windows.
|
||||
// (See: https://github.com/OmniSharp/omnisharp-vscode/wiki/Desktop-.NET-Framework)
|
||||
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch",
|
||||
"type": "mono",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/bin/Debug/project_name.exe",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "Build (Debug)"
|
||||
},
|
||||
{
|
||||
"name": "Attach",
|
||||
"type": "mono",
|
||||
"request": "attach",
|
||||
"address": "localhost",
|
||||
"port": 55555
|
||||
}
|
||||
]
|
||||
}
|
||||
9
project_name/.vscode/settings.json
vendored
Normal file
9
project_name/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
// This prevents Omnisharp from prematurely creating obj and bin directories.
|
||||
// Change this to true after changing the name of the csproj file and running Restore Project.
|
||||
"omnisharp.autoStart": false,
|
||||
|
||||
// This just circumvents annoying default behavior with the C# extension...
|
||||
// If you really like Code Lens, feel free to change this.
|
||||
"csharp.referencesCodeLens.enabled": false,
|
||||
}
|
||||
104
project_name/.vscode/tasks.json
vendored
Normal file
104
project_name/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Restore Project",
|
||||
"type": "shell",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
"/t:restore"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Clean Project",
|
||||
"type": "shell",
|
||||
"command": "msbuild /t:clean /p:configuration=Debug; msbuild /t:clean /p:configuration=Release",
|
||||
"group": "build",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Build (Debug)",
|
||||
"type": "shell",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
"/p:configuration=Debug",
|
||||
"/t:build"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": "$msCompile",
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Build (Release)",
|
||||
"type": "shell",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
"/p:configuration=Release",
|
||||
"/t:build"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": "$msCompile",
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Build and Run (Debug)",
|
||||
"identifier": "Build and Run (Debug)",
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"osx":{
|
||||
"command": "mono",
|
||||
"args": [
|
||||
"${workspaceFolder}/bin/Debug/project_name.exe"
|
||||
],
|
||||
},
|
||||
"windows":{
|
||||
"command": "cmd",
|
||||
"args": [
|
||||
"/k",
|
||||
"${workspaceFolder}/bin/Debug/project_name.exe"
|
||||
]
|
||||
},
|
||||
"dependsOn": "Build (Debug)",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Build and Run (Release)",
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"osx":{
|
||||
"command": "mono",
|
||||
"args": [
|
||||
"${workspaceFolder}/bin/Release/project_name.exe"
|
||||
]
|
||||
},
|
||||
"windows":{
|
||||
"command": "cmd",
|
||||
"args": [
|
||||
"/k",
|
||||
"${workspaceFolder}/bin/Release/project_name.exe"
|
||||
]
|
||||
},
|
||||
"dependsOn": "Build (Release)",
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Build Effects",
|
||||
"type": "shell",
|
||||
"group": "build",
|
||||
"osx":{
|
||||
"command": "${workspaceFolder}/.vscode/buildEffects.sh"
|
||||
},
|
||||
"windows":{
|
||||
"command": "cmd",
|
||||
// TODO!
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
38
project_name/Game1.cs
Normal file
38
project_name/Game1.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace project_name
|
||||
{
|
||||
class Game1 : Game
|
||||
{
|
||||
GraphicsDeviceManager graphics;
|
||||
|
||||
public Game1()
|
||||
{
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
Content.RootDirectory = "Content";
|
||||
}
|
||||
|
||||
override protected void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
override protected void LoadContent()
|
||||
{
|
||||
base.LoadContent();
|
||||
}
|
||||
|
||||
override protected void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
override protected void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
project_name/Program.cs
Normal file
51
project_name/Program.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace project_name
|
||||
{
|
||||
class Program
|
||||
{
|
||||
[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 void Main(string[] args)
|
||||
{
|
||||
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"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
using (Game1 game = new Game1())
|
||||
{
|
||||
game.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
project_name/project_name.csproj
Normal file
36
project_name/project_name.csproj
Normal file
@ -0,0 +1,36 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net46</TargetFramework>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<AssemblyName>project_name</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Reference FNA project -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../FNA/FNA.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Include the Content directory (except for .fx files, since we use .fxb at runtime) -->
|
||||
<ItemGroup>
|
||||
<Content Include="Content/**/*.*" Exclude="**/*.fx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Copy the correct fnalibs folder on Windows -->
|
||||
<!-- Modified from Andrew Russell's template (https://github.com/AndrewRussellNet/FNA-Template/blob/master/build/CopyFNALibs.targets) -->
|
||||
<ItemGroup>
|
||||
<Content Include="..\fnalibs\x86\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' == 'x86'">
|
||||
<Link>x86\%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\fnalibs\x64\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' == 'x64'">
|
||||
<Link>x64\%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue
Block a user