commit d431c5bd6d89bfcb87d31cf984f3cd26c0247fef Author: cosmonaut Date: Tue Feb 8 17:38:20 2022 -0800 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae88792 --- /dev/null +++ b/.gitignore @@ -0,0 +1,353 @@ +## 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 + +moonlibs/ + +# 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/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d51e2a4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/MoonWorks"] + path = lib/MoonWorks + url = https://gitea.moonside.games/MoonsideGames/MoonWorks.git diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..abf1b1a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to .NET 5 Debugger", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "Build: .NET 5 Debug", + "program": "${workspaceFolder}/bin/x64/Debug/net5.0/MoonWorksMultiWindow.dll", + "args": [], + "cwd": "${workspaceFolder}/bin/x64/Debug/net5.0", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d99f8a7 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,126 @@ +{ + "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 & Run: .NET 5 Debug", + "type": "shell", + "dependsOrder": "sequence", + "dependsOn": [ + "Build: .NET 5 Debug", + "Run: .NET 5 Debug" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build: .NET 5 Debug", + "command": "dotnet", + "args": [ + "build", + "./MoonWorksMultiWindow.csproj", + "-p:SolutionDir=${workspaceFolder}/", + "-p:Platform=x64" + ], + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Run: .NET 5 Debug", + "command": "dotnet", + "args": [ + "./MoonWorksMultiWindow.dll" + ], + "options": { + "env": { + "LD_LIBRARY_PATH": "./lib64", + "DYLD_LIBRARY_PATH": "./osx" + }, + "cwd": "${workspaceFolder}/bin/x64/Debug/net5.0" + }, + "type": "process", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build: .NET 5 Release", + "command": "dotnet", + "args": [ + "build", + "./MoonWorksMultiWindow.csproj", + "--configuration", + "Release", + "-p:SolutionDir=${workspaceFolder}/", + "-p:Platform=x64" + ], + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Run: .NET 5 Release", + "command": "dotnet", + "args": [ + "./MoonWorksMultiWindow.dll" + ], + "options": { + "env": { + "LD_LIBRARY_PATH": "./lib64", + "DYLD_LIBRARY_PATH": "./osx" + }, + "cwd": "${workspaceFolder}/bin/x64/Release/net5.0" + }, + "type": "process", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build & Run: .NET 5 Release", + "dependsOrder": "sequence", + "dependsOn": [ + "Build: .NET 5 Release", + "Run: .NET 5 Release" + ], + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + } + ] +} diff --git a/Content/README.md b/Content/README.md new file mode 100644 index 0000000..d05e474 --- /dev/null +++ b/Content/README.md @@ -0,0 +1 @@ +Insert your content files here (sprites, sound, etc) diff --git a/CopyMoonlibs.targets b/CopyMoonlibs.targets new file mode 100644 index 0000000..50cd87a --- /dev/null +++ b/CopyMoonlibs.targets @@ -0,0 +1,43 @@ + + + + + + + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + diff --git a/MoonWorksMultiWindow.csproj b/MoonWorksMultiWindow.csproj new file mode 100644 index 0000000..77b9b70 --- /dev/null +++ b/MoonWorksMultiWindow.csproj @@ -0,0 +1,37 @@ + + + Exe + net5.0 + true + + + + Exe + net5.0 + MoonWorksMultiWindow + false + false + 8.0 + MoonWorksMultiWindow.Program + MoonWorksMultiWindow + MoonWorksMultiWindow + true + + + + + + Always + + + + + $(DefaultItemExcludes);lib\**\* + + + + + + + + diff --git a/MoonWorksMultiWindow.sln b/MoonWorksMultiWindow.sln new file mode 100644 index 0000000..8c4157e --- /dev/null +++ b/MoonWorksMultiWindow.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonWorksMultiWindow.Core", "MoonWorksMultiWindow\MoonWorksMultiWindow.Core.csproj", "{4589302C-174A-4173-9654-CAA6CA1B5220}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonWorksMultiWindow", "MoonWorksMultiWindow.csproj", "{697974A4-B594-40B1-BCA4-284381B019C2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{C5EB0F50-EFF6-4D54-BD12-DF19CEEBFC4E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonWorks", "lib\MoonWorks\MoonWorks.csproj", "{8E9F8ACA-6706-4035-993D-D05136980328}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.ActiveCfg = Debug|x64 + {4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.Build.0 = Debug|x64 + {4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.ActiveCfg = Release|x64 + {4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.Build.0 = Release|x64 + {697974A4-B594-40B1-BCA4-284381B019C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {697974A4-B594-40B1-BCA4-284381B019C2}.Debug|x64.Build.0 = Debug|Any CPU + {697974A4-B594-40B1-BCA4-284381B019C2}.Release|x64.ActiveCfg = Release|Any CPU + {697974A4-B594-40B1-BCA4-284381B019C2}.Release|x64.Build.0 = Release|Any CPU + {8E9F8ACA-6706-4035-993D-D05136980328}.Debug|x64.ActiveCfg = Debug|x64 + {8E9F8ACA-6706-4035-993D-D05136980328}.Debug|x64.Build.0 = Debug|x64 + {8E9F8ACA-6706-4035-993D-D05136980328}.Release|x64.ActiveCfg = Release|x64 + {8E9F8ACA-6706-4035-993D-D05136980328}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {70247DA8-9C19-4FC5-B4BC-68E1262B9F4B} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {8E9F8ACA-6706-4035-993D-D05136980328} = {C5EB0F50-EFF6-4D54-BD12-DF19CEEBFC4E} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c3613c --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# MoonWorksTemplate + +Template and build tasks for developing a cross-platform multi-target .NET Framework, Mono, and .NET 5 MoonWorks project in VSCode. + +The generated solution file will also work in regular Visual Studio. + +NOTE: OSX is broken right now because I need to set up MoltenVK. + +## Features + +- Includes project boilerplate code +- Build tasks for both .NET Framework, Mono, and .NET 5 side by side +- VSCode debugger integration + +## Requirements + +- [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 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 +- [Mono](https://www.mono-project.com/) on OSX or Linux +- [Visual Studio Code](https://code.visualstudio.com/) +- [VSCode C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) +- [VSCode Mono Debug Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) if debugging using Mono + +## Installation + +- Make sure you have Git Bash from Git for Windows if you are on Windows +- Download this repository +- Run `install.sh` +- Move the newly created project directory wherever you want +- On Windows, add `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin` to your system environment PATH variable after installing Build Tools for VS 2019 + +## Usage + +- Open the project directory in VSCode +- Press Ctrl-Shift-B to open the build tasks menu +- `Framework` tasks use .NET Framework to build and run (Windows only) +- `Mono` tasks use Mono to build and run +- `.NET 5` tasks use .NET 5 to build and run +- Press F5 to build and debug + +## Acknowledgments + +Thanks to Andrew Russell and Caleb Cornett's FNA templates for a starting point for this template. diff --git a/lib/MoonWorks b/lib/MoonWorks new file mode 160000 index 0000000..4acc258 --- /dev/null +++ b/lib/MoonWorks @@ -0,0 +1 @@ +Subproject commit 4acc2588e17f2ad1f594e95e9e06d4d2ae7009ac diff --git a/src/Graphics/Containers/Framebuffers.cs b/src/Graphics/Containers/Framebuffers.cs new file mode 100644 index 0000000..ad1009f --- /dev/null +++ b/src/Graphics/Containers/Framebuffers.cs @@ -0,0 +1,36 @@ +using MoonWorks.Graphics; + +namespace MoonWorksMultiWindow.Graphics +{ + public class Framebuffers + { + public Framebuffer ExampleFramebuffer { get; } + public Framebuffer ExtraWindowFramebuffer { get; } + + public Framebuffers( + GraphicsDevice graphicsDevice, + RenderPasses renderPasses, + RenderTargets renderTargets, + uint renderDimensionsX, + uint renderDimensionsY + ) { + ExampleFramebuffer = new Framebuffer( + graphicsDevice, + renderDimensionsX, + renderDimensionsY, + renderPasses.ExampleRenderPass, + null, + renderTargets.ExampleRenderTarget + ); + + ExtraWindowFramebuffer = new Framebuffer( + graphicsDevice, + renderDimensionsX, + renderDimensionsY, + renderPasses.ExtraWindowRenderPass, + null, + renderTargets.ExtraWindowRenderTarget + ); + } + } +} \ No newline at end of file diff --git a/src/Graphics/Containers/RenderPasses.cs b/src/Graphics/Containers/RenderPasses.cs new file mode 100644 index 0000000..fe5917b --- /dev/null +++ b/src/Graphics/Containers/RenderPasses.cs @@ -0,0 +1,31 @@ +using MoonWorks.Graphics; + +namespace MoonWorksMultiWindow.Graphics +{ + public class RenderPasses + { + public RenderPass ExampleRenderPass { get; } + public RenderPass ExtraWindowRenderPass { 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 + ); + + ExtraWindowRenderPass = new RenderPass( + graphicsDevice, + clearPassDescription + ); + } + } +} \ No newline at end of file diff --git a/src/Graphics/Containers/RenderTargets.cs b/src/Graphics/Containers/RenderTargets.cs new file mode 100644 index 0000000..bb32ce0 --- /dev/null +++ b/src/Graphics/Containers/RenderTargets.cs @@ -0,0 +1,32 @@ +using MoonWorks.Graphics; + +namespace MoonWorksMultiWindow.Graphics +{ + public class RenderTargets + { + public RenderTarget ExampleRenderTarget { get; } + public RenderTarget ExtraWindowRenderTarget { get; } + + public RenderTargets( + GraphicsDevice graphicsDevice, + uint renderDimensionsX, + uint renderDimensionsY + ) { + ExampleRenderTarget = RenderTarget.CreateBackedRenderTarget( + graphicsDevice, + renderDimensionsX, + renderDimensionsY, + TextureFormat.R8G8B8A8, + false + ); + + ExtraWindowRenderTarget = RenderTarget.CreateBackedRenderTarget( + graphicsDevice, + renderDimensionsX, + renderDimensionsY, + TextureFormat.R8G8B8A8, + false + ); + } + } +} diff --git a/src/Graphics/GraphicsObjects.cs b/src/Graphics/GraphicsObjects.cs new file mode 100644 index 0000000..39909f0 --- /dev/null +++ b/src/Graphics/GraphicsObjects.cs @@ -0,0 +1,31 @@ +using MoonWorks.Graphics; + +namespace MoonWorksMultiWindow.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 + ); + } + } +} diff --git a/src/MoonWorksMultiWindowGame.cs b/src/MoonWorksMultiWindowGame.cs new file mode 100644 index 0000000..80ca2f5 --- /dev/null +++ b/src/MoonWorksMultiWindowGame.cs @@ -0,0 +1,111 @@ +using MoonWorks.Graphics; +using MoonWorks.Window; +using MoonWorks; +using MoonWorksMultiWindow.Graphics; +using System.Threading.Tasks; + +namespace MoonWorksMultiWindow +{ + class MoonWorksMultiWindowGame : Game + { + private GraphicsObjects GraphicsObjects { get; } + + private int RenderWidth { get; } + private int RenderHeight { get; } + + private OSWindow ExtraWindow { get; } + + public MoonWorksMultiWindowGame( + WindowCreateInfo windowCreateInfo, + PresentMode presentMode, + bool debugMode + ) : base(windowCreateInfo, presentMode, 60, debugMode) + { + // Insert your game initialization logic here. + GraphicsObjects = new GraphicsObjects( + GraphicsDevice, + windowCreateInfo.WindowWidth, + windowCreateInfo.WindowHeight + ); + RenderWidth = (int)windowCreateInfo.WindowWidth; + RenderHeight = (int)windowCreateInfo.WindowHeight; + + var extraWindowCreateInfo = new WindowCreateInfo + { + WindowTitle = "Extra Window", + WindowWidth = 1280, + WindowHeight = 720, + ScreenMode = ScreenMode.Windowed + }; + + ExtraWindow = new OSWindow(extraWindowCreateInfo); + } + + protected override void Update(System.TimeSpan dt) + { + // Insert your game update logic here. + } + + protected override void Draw(System.TimeSpan dt, double alpha) + { + Task mainDraw = Task.Run(MainDraw); + Task extraDraw = Task.Run(ExtraWindowDraw); + } + + private void MainDraw() + { + var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); + + commandBuffer.BeginRenderPass( + GraphicsObjects.RenderPasses.ExampleRenderPass, + GraphicsObjects.Framebuffers.ExampleFramebuffer, + new Rect + { + X = 0, + Y = 0, + W = RenderWidth, + H = RenderHeight + }, + Color.CornflowerBlue.ToVector4() + ); + + commandBuffer.EndRenderPass(); + + commandBuffer.QueuePresent( + GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice, + Filter.Nearest, + Window + ); + + GraphicsDevice.Submit(commandBuffer); + } + + private void ExtraWindowDraw() + { + var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); + + commandBuffer.BeginRenderPass( + GraphicsObjects.RenderPasses.ExtraWindowRenderPass, + GraphicsObjects.Framebuffers.ExtraWindowFramebuffer, + new Rect + { + X = 0, + Y = 0, + W = RenderWidth, + H = RenderHeight + }, + Color.OrangeRed.ToVector4() + ); + + commandBuffer.EndRenderPass(); + + commandBuffer.QueuePresent( + GraphicsObjects.RenderTargets.ExtraWindowRenderTarget.TextureSlice, + Filter.Nearest, + ExtraWindow + ); + + GraphicsDevice.Submit(commandBuffer); + } + } +} diff --git a/src/Program.cs b/src/Program.cs new file mode 100644 index 0000000..4c52ff3 --- /dev/null +++ b/src/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; +using MoonWorks; +using MoonWorks.Window; + +namespace MoonWorksMultiWindow +{ + 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 + { + WindowWidth = 1280, + WindowHeight = 720, + WindowTitle = "MoonWorksMultiWindow", + ScreenMode = ScreenMode.Windowed + }; + + MoonWorksMultiWindowGame game = new MoonWorksMultiWindowGame( + windowCreateInfo, + MoonWorks.Graphics.PresentMode.FIFORelaxed, + true + ); + + game.Run(); + } + } +}