diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..23b7049 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.ogg filter=lfs diff=lfs merge=lfs -text +*.qoa filter=lfs diff=lfs merge=lfs -text diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d5c3dcf --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/net7.0/MoonWorksTest.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a537d9c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/MoonWorksTest.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/MoonWorksTest.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/MoonWorksTest.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Content/housecleaning_herbal_mix.ogg b/Content/housecleaning_herbal_mix.ogg new file mode 100644 index 0000000..87ca310 --- /dev/null +++ b/Content/housecleaning_herbal_mix.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba9e715fb29a6a6665a5178a6fcc038e9d53a93ec03074ab48599ec1c0ed644f +size 7510836 diff --git a/Content/housecleaning_herbal_mix.qoa b/Content/housecleaning_herbal_mix.qoa new file mode 100644 index 0000000..d8f4f2b --- /dev/null +++ b/Content/housecleaning_herbal_mix.qoa @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2056476a61d9379786c0f9c477692861574d8853e082558214b934000b0a11c +size 17374528 diff --git a/Content/title_screen.ogg b/Content/title_screen.ogg index aadd670..4144f49 100644 Binary files a/Content/title_screen.ogg and b/Content/title_screen.ogg differ diff --git a/MoonWorksTest.csproj b/MoonWorksTest.csproj index 44bbf1b..918f0a5 100644 --- a/MoonWorksTest.csproj +++ b/MoonWorksTest.csproj @@ -1,7 +1,7 @@ - net5.0 + net7.0 Exe MoonWorksTest x64 diff --git a/lib/MoonWorks b/lib/MoonWorks index 111df04..a869a0e 160000 --- a/lib/MoonWorks +++ b/lib/MoonWorks @@ -1 +1 @@ -Subproject commit 111df04c0f7be740108cc3536eda3629572714d8 +Subproject commit a869a0e958fd307a2883d111489ea7c49793baf6 diff --git a/moonlibs/windows/FAudio.dll b/moonlibs/windows/FAudio.dll index b9c6d40..800667c 100644 Binary files a/moonlibs/windows/FAudio.dll and b/moonlibs/windows/FAudio.dll differ diff --git a/moonlibs/windows/Refresh.dll b/moonlibs/windows/Refresh.dll index 09ca122..12503a1 100644 Binary files a/moonlibs/windows/Refresh.dll and b/moonlibs/windows/Refresh.dll differ diff --git a/moonlibs/windows/SDL2.dll b/moonlibs/windows/SDL2.dll index ddba03c..71f5b89 100644 Binary files a/moonlibs/windows/SDL2.dll and b/moonlibs/windows/SDL2.dll differ diff --git a/src/PositionTexture.cs b/src/PositionTexture.cs index b594038..efc1724 100644 --- a/src/PositionTexture.cs +++ b/src/PositionTexture.cs @@ -1,12 +1,15 @@ using System.Runtime.InteropServices; -using MoonWorks.Math; +using MoonWorks.Graphics; +using MoonWorks.Math.Float; namespace MoonWorksTest { [StructLayout(LayoutKind.Sequential)] - struct PositionTexture + struct PositionTexture : MoonWorks.Graphics.IVertexType { public Vector3 Position; public Vector2 Texture; - } + + public static VertexElementFormat[] Formats => new VertexElementFormat[] { VertexElementFormat.Vector3, VertexElementFormat.Vector2 }; + } } diff --git a/src/Program.cs b/src/Program.cs index 856cacb..dbe58d6 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -15,9 +15,14 @@ namespace MoonWorksTest ScreenMode = ScreenMode.Windowed }; - TestGame game = new TestGame( + FrameLimiterSettings limiterSettings = new FrameLimiterSettings + { + Mode = FrameLimiterMode.Uncapped + }; + + TestGame game = new TestGame( windowCreateInfo, - PresentMode.FIFO, + limiterSettings, 60, true ); diff --git a/src/TestGame.cs b/src/TestGame.cs index 2b7d3e8..9364104 100644 --- a/src/TestGame.cs +++ b/src/TestGame.cs @@ -23,23 +23,17 @@ namespace MoonWorksTest GraphicsPipeline mainGraphicsPipeline; - byte[] screenshotPixels; - Buffer screenshotBuffer; - uint screenshotBufferSize; - StaticSound music; StaticSoundInstance musicInstance; StreamingSoundOgg musicStream; - bool screenshotInProgress = false; - - public TestGame(WindowCreateInfo windowCreateInfo, PresentMode presentMode, int targetTimestep = 60, bool debugMode = false) : base(windowCreateInfo, presentMode, targetTimestep, debugMode) + public TestGame(WindowCreateInfo windowCreateInfo, FrameLimiterSettings limiterSettings, int targetTimestep = 60, bool debugMode = false) : base(windowCreateInfo, limiterSettings, targetTimestep, debugMode) { var windowWidth = windowCreateInfo.WindowWidth; var windowHeight = windowCreateInfo.WindowHeight; - passthroughVertexShaderModule = new ShaderModule(GraphicsDevice, Path.Combine("Content", "passthrough_vert.spv")); - raymarchFragmentShaderModule = new ShaderModule(GraphicsDevice, Path.Combine("Content", "hexagon_grid.spv")); + //passthroughVertexShaderModule = new ShaderModule(GraphicsDevice, Path.Combine("Content", "passthrough_vert.spv")); + //raymarchFragmentShaderModule = new ShaderModule(GraphicsDevice, Path.Combine("Content", "hexagon_grid.spv")); raymarchUniforms.time = 0; raymarchUniforms.padding = 0; @@ -48,8 +42,8 @@ namespace MoonWorksTest var uploadCommandBuffer = GraphicsDevice.AcquireCommandBuffer(); - woodTexture = Texture.LoadPNG(GraphicsDevice, uploadCommandBuffer, "Content/woodgrain.png"); - noiseTexture = Texture.LoadPNG(GraphicsDevice, uploadCommandBuffer, "Content/noise.png"); + woodTexture = Texture.FromImageFile(GraphicsDevice, uploadCommandBuffer, "Content/woodgrain.png"); + noiseTexture = Texture.FromImageFile(GraphicsDevice, uploadCommandBuffer, "Content/noise.png"); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap); @@ -81,54 +75,51 @@ namespace MoonWorksTest /* Pipeline */ + /* mainGraphicsPipeline = new GraphicsPipeline( GraphicsDevice, new GraphicsPipelineCreateInfo { AttachmentInfo = new GraphicsPipelineAttachmentInfo( new ColorAttachmentDescription( - GraphicsDevice.GetSwapchainFormat(Window), + MainWindow.SwapchainFormat, ColorAttachmentBlendState.None ) ), DepthStencilState = DepthStencilState.Disable, VertexShaderInfo = GraphicsShaderInfo.Create(passthroughVertexShaderModule, "main", 0), - VertexInputState = new VertexInputState( - VertexBinding.Create(), - VertexAttribute.Create("Position", 0), - VertexAttribute.Create("Texture", 1) - ), + VertexInputState = VertexInputState.CreateSingleBinding(), PrimitiveType = PrimitiveType.TriangleList, FragmentShaderInfo = GraphicsShaderInfo.Create(raymarchFragmentShaderModule, "main", 2), RasterizerState = RasterizerState.CW_CullBack, - ViewportState = new ViewportState((int)Window.Width, (int)Window.Height), MultisampleState = MultisampleState.None } ); + */ - screenshotBufferSize = windowWidth * windowHeight * 4; - screenshotPixels = new byte[screenshotBufferSize]; - screenshotBuffer = new Buffer(GraphicsDevice, 0, screenshotBufferSize); - - music = StaticSound.LoadOgg(AudioDevice, Path.Combine("Content", "title_screen.ogg")); - musicInstance = music.CreateInstance(); + // music = StaticSound.LoadOgg(AudioDevice, Path.Combine("Content", "title_screen.ogg")); + // musicInstance = music.CreateInstance(); // musicInstance.Play(); - musicStream = StreamingSoundOgg.Load(AudioDevice, Path.Combine("Content", "title_screen.ogg"), false, true); - musicStream.Play(); - } + musicStream = StreamingSoundOgg.Load(AudioDevice, Path.Combine("Content", "housecleaning_herbal_mix.ogg")); + musicStream.QueueSyncPlay(); + + var musicQoaStream = StreamingSoundQoa.Load(AudioDevice, Path.Combine("Content", "housecleaning_herbal_mix.qoa")); + musicQoaStream.QueueSyncPlay(); + + AudioDevice.SyncPlay(); + } protected override void Update(System.TimeSpan dt) { raymarchUniforms.time += (float)dt.TotalSeconds; } - protected override void Draw(System.TimeSpan dt, double alpha) + protected override void Draw(double alpha) { var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); - var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window); - var takeScreenshot = Inputs.Keyboard.IsPressed(Keycode.S) && !screenshotInProgress && (swapchainTexture != null); + var swapchainTexture = commandBuffer.AcquireSwapchainTexture(MainWindow); if (swapchainTexture != null) { @@ -136,6 +127,7 @@ namespace MoonWorksTest new ColorAttachmentInfo(swapchainTexture, clearColor) ); + /* commandBuffer.BindGraphicsPipeline(mainGraphicsPipeline); commandBuffer.BindVertexBuffers(vertexBuffer); @@ -146,46 +138,16 @@ namespace MoonWorksTest var fragmentParamOffset = commandBuffer.PushFragmentShaderUniforms(raymarchUniforms); commandBuffer.DrawPrimitives(0, 1, 0, fragmentParamOffset); + */ + commandBuffer.EndRenderPass(); - if (takeScreenshot) - { - commandBuffer.CopyTextureToBuffer(new TextureSlice(swapchainTexture), screenshotBuffer); - } } GraphicsDevice.Submit(commandBuffer); - - if (takeScreenshot) - { - Task.Run(() => SaveScreenshot()); - } } - private void SaveScreenshot() - { - screenshotInProgress = true; - - var name = "MoonWorksTest-" + System.DateTime.Now.ToString("MM-dd-yyyy-hh-mm-ss") + ".png"; - System.Console.WriteLine("Saving screenshot " + name + " ..."); - - GraphicsDevice.Wait(); - screenshotBuffer.GetData(screenshotPixels, screenshotBufferSize); - - Texture.SavePNG( - name, - 1280, - 720, - GraphicsDevice.GetSwapchainFormat(Window), - screenshotPixels - ); - - System.Console.WriteLine("Screenshot saved!"); - - screenshotInProgress = false; - } - - protected override void OnDestroy() + protected override void Destroy() { }