commit af4391b54cf5b60b3fc989793b04d1e78d07a123 Author: Caleb Cornett Date: Sat Oct 6 20:42:24 2018 -0400 Building projects and effects diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba3f579 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +FNA/ +fnalibs/ +project_name/bin/ +project_name/obj/ diff --git a/getFNA.sh b/getFNA.sh new file mode 100755 index 0000000..715dce8 --- /dev/null +++ b/getFNA.sh @@ -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 \ No newline at end of file diff --git a/getLibs.sh b/getLibs.sh new file mode 100755 index 0000000..75d9d21 --- /dev/null +++ b/getLibs.sh @@ -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 diff --git a/project_name/.vscode/buildEffects.sh b/project_name/.vscode/buildEffects.sh new file mode 100755 index 0000000..22fc7ad --- /dev/null +++ b/project_name/.vscode/buildEffects.sh @@ -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 \ No newline at end of file diff --git a/project_name/.vscode/launch.json b/project_name/.vscode/launch.json new file mode 100644 index 0000000..bedb9b1 --- /dev/null +++ b/project_name/.vscode/launch.json @@ -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 + } + ] +} \ No newline at end of file diff --git a/project_name/.vscode/settings.json b/project_name/.vscode/settings.json new file mode 100644 index 0000000..b4537c8 --- /dev/null +++ b/project_name/.vscode/settings.json @@ -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, +} \ No newline at end of file diff --git a/project_name/.vscode/tasks.json b/project_name/.vscode/tasks.json new file mode 100644 index 0000000..ff925db --- /dev/null +++ b/project_name/.vscode/tasks.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/project_name/Game1.cs b/project_name/Game1.cs new file mode 100644 index 0000000..a75ef2e --- /dev/null +++ b/project_name/Game1.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/project_name/Program.cs b/project_name/Program.cs new file mode 100644 index 0000000..436f461 --- /dev/null +++ b/project_name/Program.cs @@ -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(); + } + } + } +} \ No newline at end of file diff --git a/project_name/project_name.csproj b/project_name/project_name.csproj new file mode 100644 index 0000000..734f3fa --- /dev/null +++ b/project_name/project_name.csproj @@ -0,0 +1,36 @@ + + + + Exe + net46 + false + AnyCPU + project_name + + + + + + + + + + + PreserveNewest + + + + + + + + x86\%(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + x64\%(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + \ No newline at end of file