From ad39d7b19091bf8ae2f10896bedb4c4c4cc419c7 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 8 Jun 2023 11:07:20 -0700 Subject: [PATCH] update template for .NET 7 --- .vscode/launch.json | 8 ++++---- .vscode/tasks.json | 40 ++++++++++++++++++++-------------------- ProjectName.csproj | 3 +-- src/Program.cs | 15 +++++---------- src/ProjectNameGame.cs | 7 +++---- 5 files changed, 33 insertions(+), 40 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 933c3d4..358a5a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,13 +2,13 @@ "version": "0.2.0", "configurations": [ { - "name": "Attach to .NET 6 Debugger", + "name": "Attach to .NET 7 Debugger", "type": "coreclr", "request": "launch", - "preLaunchTask": "Build: .NET 6 Debug", - "program": "${workspaceFolder}/bin/x64/Debug/net6.0/ProjectName.dll", + "preLaunchTask": "Build: .NET 7 Debug", + "program": "${workspaceFolder}/bin/x64/Debug/net7.0/ProjectName.dll", "args": [], - "cwd": "${workspaceFolder}/bin/x64/Debug/net6.0", + "cwd": "${workspaceFolder}/bin/x64/Debug/net7.0", "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 662e623..66a3c98 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -21,12 +21,12 @@ }, "tasks": [ { - "label": "Build & Run: .NET 6 Debug", + "label": "Build & Run: .NET 7 Debug", "type": "shell", "dependsOrder": "sequence", "dependsOn": [ - "Build: .NET 6 Debug", - "Run: .NET 6 Debug" + "Build: .NET 7 Debug", + "Run: .NET 7 Debug" ], "group": { "kind": "build", @@ -35,7 +35,7 @@ "problemMatcher": [] }, { - "label": "Build: .NET 6 Debug", + "label": "Build: .NET 7 Debug", "command": "dotnet", "args": [ "build", @@ -51,13 +51,13 @@ "problemMatcher": [] }, { - "label": "Run: .NET 6 Debug", - "command": "dotnet", - "args": [ - "./ProjectName.dll" - ], + "label": "Run: .NET 7 Debug", + "command": "ProjectName", + "windows": { + "command": "ProjectName.exe" + }, "options": { - "cwd": "${workspaceFolder}/bin/x64/Debug/net6.0" + "cwd": "${workspaceFolder}/bin/x64/Debug/net7.0" }, "type": "process", "group": { @@ -67,7 +67,7 @@ "problemMatcher": [] }, { - "label": "Build: .NET 6 Release", + "label": "Build: .NET 7 Release", "command": "dotnet", "args": [ "build", @@ -85,13 +85,13 @@ "problemMatcher": [] }, { - "label": "Run: .NET 5 Release", - "command": "dotnet", - "args": [ - "./ProjectName.dll" - ], + "label": "Run: .NET 7 Release", + "command": "ProjectName", + "windows": { + "command": "ProjectName.exe" + }, "options": { - "cwd": "${workspaceFolder}/bin/x64/Release/net6.0" + "cwd": "${workspaceFolder}/bin/x64/Debug/net7.0" }, "type": "process", "group": { @@ -101,11 +101,11 @@ "problemMatcher": [] }, { - "label": "Build & Run: .NET 6 Release", + "label": "Build & Run: .NET 7 Release", "dependsOrder": "sequence", "dependsOn": [ - "Build: .NET 6 Release", - "Run: .NET 6 Release" + "Build: .NET 7 Release", + "Run: .NET 7 Release" ], "type": "shell", "group": { diff --git a/ProjectName.csproj b/ProjectName.csproj index 66626fe..ad9fde8 100644 --- a/ProjectName.csproj +++ b/ProjectName.csproj @@ -1,11 +1,10 @@ Exe - net6.0 + net7.0 ProjectName false false - 7.3 ProjectName.Program ProjectName ProjectName diff --git a/src/Program.cs b/src/Program.cs index 0c1b12e..c68361c 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -7,11 +7,6 @@ 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) { WindowCreateInfo windowCreateInfo = new WindowCreateInfo @@ -19,19 +14,19 @@ namespace ProjectName WindowWidth = 1280, WindowHeight = 720, WindowTitle = "ProjectName", - ScreenMode = ScreenMode.Windowed + ScreenMode = ScreenMode.Windowed, + PresentMode = PresentMode.FIFORelaxed }; - FramerateSettings framerateSettings = new FramerateSettings + FrameLimiterSettings frameLimiterSettings = new FrameLimiterSettings { - Mode = FramerateMode.Uncapped, + Mode = FrameLimiterMode.Capped, Cap = 60 }; ProjectNameGame game = new ProjectNameGame( windowCreateInfo, - MoonWorks.Graphics.PresentMode.FIFORelaxed, - framerateSettings, + frameLimiterSettings, true ); diff --git a/src/ProjectNameGame.cs b/src/ProjectNameGame.cs index 461fb3d..c947671 100644 --- a/src/ProjectNameGame.cs +++ b/src/ProjectNameGame.cs @@ -7,10 +7,9 @@ namespace ProjectName { public ProjectNameGame( WindowCreateInfo windowCreateInfo, - PresentMode presentMode, - FramerateSettings framerateSettings, + FrameLimiterSettings frameLimiterSettings, bool debugMode - ) : base(windowCreateInfo, presentMode, framerateSettings, 60, debugMode) + ) : base(windowCreateInfo, frameLimiterSettings, 60, debugMode) { // Insert your game initialization logic here. } @@ -25,7 +24,7 @@ namespace ProjectName // Replace this with your own drawing code. var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); - var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window); + var swapchainTexture = commandBuffer.AcquireSwapchainTexture(MainWindow); commandBuffer.BeginRenderPass( new ColorAttachmentInfo(swapchainTexture, Color.CornflowerBlue)