update to latest MoonWorks

main
cosmonaut 2022-03-03 11:05:23 -08:00
parent 75e525c71a
commit ce4b03aca4
10 changed files with 29 additions and 173 deletions

8
.vscode/launch.json vendored
View File

@ -2,13 +2,13 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Attach to .NET 5 Debugger", "name": "Attach to .NET 6 Debugger",
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "Build: .NET 5 Debug", "preLaunchTask": "Build: .NET 6 Debug",
"program": "${workspaceFolder}/bin/x64/Debug/net5.0/ProjectName.dll", "program": "${workspaceFolder}/bin/x64/Debug/net6.0/ProjectName.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/bin/x64/Debug/net5.0", "cwd": "${workspaceFolder}/bin/x64/Debug/net6.0",
"console": "integratedTerminal", "console": "integratedTerminal",
"internalConsoleOptions": "neverOpen" "internalConsoleOptions": "neverOpen"
} }

30
.vscode/tasks.json vendored
View File

@ -21,12 +21,12 @@
}, },
"tasks": [ "tasks": [
{ {
"label": "Build & Run: .NET 5 Debug", "label": "Build & Run: .NET 6 Debug",
"type": "shell", "type": "shell",
"dependsOrder": "sequence", "dependsOrder": "sequence",
"dependsOn": [ "dependsOn": [
"Build: .NET 5 Debug", "Build: .NET 6 Debug",
"Run: .NET 5 Debug" "Run: .NET 6 Debug"
], ],
"group": { "group": {
"kind": "build", "kind": "build",
@ -35,7 +35,7 @@
"problemMatcher": [] "problemMatcher": []
}, },
{ {
"label": "Build: .NET 5 Debug", "label": "Build: .NET 6 Debug",
"command": "dotnet", "command": "dotnet",
"args": [ "args": [
"build", "build",
@ -51,17 +51,13 @@
"problemMatcher": [] "problemMatcher": []
}, },
{ {
"label": "Run: .NET 5 Debug", "label": "Run: .NET 6 Debug",
"command": "dotnet", "command": "dotnet",
"args": [ "args": [
"./ProjectName.dll" "./ProjectName.dll"
], ],
"options": { "options": {
"env": { "cwd": "${workspaceFolder}/bin/x64/Debug/net6.0"
"LD_LIBRARY_PATH": "./lib64",
"DYLD_LIBRARY_PATH": "./osx"
},
"cwd": "${workspaceFolder}/bin/x64/Debug/net5.0"
}, },
"type": "process", "type": "process",
"group": { "group": {
@ -71,7 +67,7 @@
"problemMatcher": [] "problemMatcher": []
}, },
{ {
"label": "Build: .NET 5 Release", "label": "Build: .NET 6 Release",
"command": "dotnet", "command": "dotnet",
"args": [ "args": [
"build", "build",
@ -95,11 +91,7 @@
"./ProjectName.dll" "./ProjectName.dll"
], ],
"options": { "options": {
"env": { "cwd": "${workspaceFolder}/bin/x64/Release/net6.0"
"LD_LIBRARY_PATH": "./lib64",
"DYLD_LIBRARY_PATH": "./osx"
},
"cwd": "${workspaceFolder}/bin/x64/Release/net5.0"
}, },
"type": "process", "type": "process",
"group": { "group": {
@ -109,11 +101,11 @@
"problemMatcher": [] "problemMatcher": []
}, },
{ {
"label": "Build & Run: .NET 5 Release", "label": "Build & Run: .NET 6 Release",
"dependsOrder": "sequence", "dependsOrder": "sequence",
"dependsOn": [ "dependsOn": [
"Build: .NET 5 Release", "Build: .NET 6 Release",
"Run: .NET 5 Release" "Run: .NET 6 Release"
], ],
"type": "shell", "type": "shell",
"group": { "group": {

View File

@ -1,13 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetName>ProjectName</TargetName> <TargetName>ProjectName</TargetName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
@ -16,6 +10,7 @@
<AssemblyName>ProjectName</AssemblyName> <AssemblyName>ProjectName</AssemblyName>
<RootNamespace>ProjectName</RootNamespace> <RootNamespace>ProjectName</RootNamespace>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon /> <ApplicationIcon />
</PropertyGroup> </PropertyGroup>

View File

@ -1,6 +1,6 @@
# MoonWorksTemplate # MoonWorksTemplate
Template and build tasks for developing a cross-platform multi-target .NET Framework, Mono, and .NET 5 MoonWorks project in VSCode. Template and build tasks for developing a cross-platform multi-target .NET 6 MoonWorks project in VSCode.
The generated solution file will also work in regular Visual Studio. The generated solution file will also work in regular Visual Studio.
@ -8,15 +8,14 @@ NOTE: OSX is broken right now because I need to set up MoltenVK.
## Features ## Features
- Includes project boilerplate code - Project boilerplate code
- Build tasks for both .NET Framework, Mono, and .NET 5 side by side - VSCode build tasks
- VSCode debugger integration - VSCode debugger integration
## Requirements ## Requirements
- [Git](https://git-scm.com/) or [Git for Windows](https://gitforwindows.org/) on Windows - [Git](https://git-scm.com/) or [Git for Windows](https://gitforwindows.org/) on Windows
- [.NET 5 SDK](https://dotnet.microsoft.com/download/dotnet/5.0) - [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
- [.NET Framework 4.7.2 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/net472) on Windows
- [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) on Windows - [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) on Windows
- [Mono](https://www.mono-project.com/) on OSX or Linux - [Mono](https://www.mono-project.com/) on OSX or Linux
- [Visual Studio Code](https://code.visualstudio.com/) - [Visual Studio Code](https://code.visualstudio.com/)
@ -35,9 +34,7 @@ NOTE: OSX is broken right now because I need to set up MoltenVK.
- Open the project directory in VSCode - Open the project directory in VSCode
- Press Ctrl-Shift-B to open the build tasks menu - Press Ctrl-Shift-B to open the build tasks menu
- `Framework` tasks use .NET Framework to build and run (Windows only) - Tasks use .NET 6.0 to build and run
- `Mono` tasks use Mono to build and run
- `.NET 5` tasks use .NET 5 to build and run
- Press F5 to build and debug - Press F5 to build and debug
## Acknowledgments ## Acknowledgments

View File

@ -1,26 +0,0 @@
using MoonWorks.Graphics;
namespace ProjectName.Graphics
{
public class Framebuffers
{
public Framebuffer ExampleFramebuffer { get; }
public Framebuffers(
GraphicsDevice graphicsDevice,
RenderPasses renderPasses,
RenderTargets renderTargets,
uint renderDimensionsX,
uint renderDimensionsY
) {
ExampleFramebuffer = new Framebuffer(
graphicsDevice,
renderDimensionsX,
renderDimensionsY,
renderPasses.ExampleRenderPass,
null,
renderTargets.ExampleRenderTarget
);
}
}
}

View File

@ -1,24 +0,0 @@
using MoonWorks.Graphics;
namespace ProjectName.Graphics
{
public class RenderPasses
{
public RenderPass ExampleRenderPass { get; }
public RenderPasses(GraphicsDevice graphicsDevice)
{
var clearPassDescription = new ColorTargetDescription
{
Format = TextureFormat.R8G8B8A8,
LoadOp = LoadOp.Clear,
StoreOp = StoreOp.Store,
MultisampleCount = SampleCount.One
};
ExampleRenderPass = new RenderPass(
graphicsDevice,
clearPassDescription
);
}
}
}

View File

@ -1,23 +0,0 @@
using MoonWorks.Graphics;
namespace ProjectName.Graphics
{
public class RenderTargets
{
public RenderTarget ExampleRenderTarget { get; }
public RenderTargets(
GraphicsDevice graphicsDevice,
uint renderDimensionsX,
uint renderDimensionsY
) {
ExampleRenderTarget = RenderTarget.CreateBackedRenderTarget(
graphicsDevice,
renderDimensionsX,
renderDimensionsY,
TextureFormat.R8G8B8A8,
false
);
}
}
}

View File

@ -1,31 +0,0 @@
using MoonWorks.Graphics;
namespace ProjectName.Graphics
{
public class GraphicsObjects
{
public RenderTargets RenderTargets { get; }
public Framebuffers Framebuffers { get; }
public RenderPasses RenderPasses { get; }
public GraphicsObjects(
GraphicsDevice graphicsDevice,
uint renderDimensionsX,
uint renderDimensionsY
) {
RenderPasses = new RenderPasses(graphicsDevice);
RenderTargets = new RenderTargets(
graphicsDevice,
renderDimensionsX,
renderDimensionsY
);
Framebuffers = new Framebuffers(
graphicsDevice,
RenderPasses,
RenderTargets,
renderDimensionsX,
renderDimensionsY
);
}
}
}

View File

@ -2,7 +2,6 @@ using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using MoonWorks; using MoonWorks;
using MoonWorks.Window;
namespace ProjectName namespace ProjectName
{ {

View File

@ -1,17 +1,10 @@
using MoonWorks.Graphics; using MoonWorks.Graphics;
using MoonWorks.Window;
using MoonWorks; using MoonWorks;
using ProjectName.Graphics;
namespace ProjectName namespace ProjectName
{ {
class ProjectNameGame : Game class ProjectNameGame : Game
{ {
private GraphicsObjects GraphicsObjects { get; }
private int RenderWidth { get; }
private int RenderHeight { get; }
public ProjectNameGame( public ProjectNameGame(
WindowCreateInfo windowCreateInfo, WindowCreateInfo windowCreateInfo,
PresentMode presentMode, PresentMode presentMode,
@ -19,13 +12,6 @@ namespace ProjectName
) : base(windowCreateInfo, presentMode, 60, debugMode) ) : base(windowCreateInfo, presentMode, 60, debugMode)
{ {
// Insert your game initialization logic here. // Insert your game initialization logic here.
GraphicsObjects = new GraphicsObjects(
GraphicsDevice,
windowCreateInfo.WindowWidth,
windowCreateInfo.WindowHeight
);
RenderWidth = (int)windowCreateInfo.WindowWidth;
RenderHeight = (int)windowCreateInfo.WindowHeight;
} }
protected override void Update(System.TimeSpan dt) protected override void Update(System.TimeSpan dt)
@ -38,29 +24,20 @@ namespace ProjectName
// Replace this with your own drawing code. // Replace this with your own drawing code.
var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window);
commandBuffer.BeginRenderPass( commandBuffer.BeginRenderPass(
GraphicsObjects.RenderPasses.ExampleRenderPass, new ColorAttachmentInfo(swapchainTexture, Color.CornflowerBlue)
GraphicsObjects.Framebuffers.ExampleFramebuffer,
new Rect
{
X = 0,
Y = 0,
W = RenderWidth,
H = RenderHeight
},
Color.CornflowerBlue.ToVector4()
); );
commandBuffer.EndRenderPass(); commandBuffer.EndRenderPass();
commandBuffer.QueuePresent(
GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice,
Filter.Nearest,
Window
);
GraphicsDevice.Submit(commandBuffer); GraphicsDevice.Submit(commandBuffer);
} }
protected override void OnDestroy()
{
}
} }
} }