From 77d8357186cbf2efa894f33c818868516fdba9c9 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 15 Jan 2024 17:15:59 -0800 Subject: [PATCH] StoreLoad Test --- MoonWorksGraphicsTests.sln | 6 +++++ StoreLoad/StoreLoad.csproj | 17 +++++++++++++ StoreLoad/StoreLoadGame.cs | 50 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 StoreLoad/StoreLoad.csproj create mode 100644 StoreLoad/StoreLoadGame.cs diff --git a/MoonWorksGraphicsTests.sln b/MoonWorksGraphicsTests.sln index 74c9073..2773e38 100644 --- a/MoonWorksGraphicsTests.sln +++ b/MoonWorksGraphicsTests.sln @@ -59,6 +59,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepthMSAA", "DepthMSAA\Dept EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowResizing", "WindowResizing\WindowResizing.csproj", "{AF5F2804-663D-4C46-BD02-AB178002180B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreLoad", "StoreLoad\StoreLoad.csproj", "{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -177,6 +179,10 @@ Global {AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|x64.Build.0 = Debug|x64 {AF5F2804-663D-4C46-BD02-AB178002180B}.Release|x64.ActiveCfg = Release|Any CPU {AF5F2804-663D-4C46-BD02-AB178002180B}.Release|x64.Build.0 = Release|Any CPU + {CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|x64.ActiveCfg = Debug|x64 + {CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|x64.Build.0 = Debug|x64 + {CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|x64.ActiveCfg = Release|x64 + {CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/StoreLoad/StoreLoad.csproj b/StoreLoad/StoreLoad.csproj new file mode 100644 index 0000000..fb73c0c --- /dev/null +++ b/StoreLoad/StoreLoad.csproj @@ -0,0 +1,17 @@ + + + + + + + + + Exe + net8.0 + enable + x64 + + + + + diff --git a/StoreLoad/StoreLoadGame.cs b/StoreLoad/StoreLoadGame.cs new file mode 100644 index 0000000..5b11658 --- /dev/null +++ b/StoreLoad/StoreLoadGame.cs @@ -0,0 +1,50 @@ +using System; +using MoonWorks.Graphics; + +namespace MoonWorks.Test +{ + class StoreLoadGame : Game + { + private GraphicsPipeline fillPipeline; + + public StoreLoadGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true) + { + ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("RawTriangle.vert")); + ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag")); + + GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo( + MainWindow.SwapchainFormat, + vertShaderModule, + fragShaderModule + ); + fillPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); + } + + protected override void Update(TimeSpan delta) + { + + } + + protected override void Draw(double alpha) + { + CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); + Texture? swapchain = cmdbuf.AcquireSwapchainTexture(MainWindow); + if (swapchain != null) + { + cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, Color.Blue)); + cmdbuf.BindGraphicsPipeline(fillPipeline); + cmdbuf.DrawPrimitives(0, 1, 0, 0); + cmdbuf.EndRenderPass(); + cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, LoadOp.Load, StoreOp.Store)); + cmdbuf.EndRenderPass(); + } + GraphicsDevice.Submit(cmdbuf); + } + + public static void Main(string[] args) + { + StoreLoadGame game = new StoreLoadGame(); + game.Run(); + } + } +}