Compare commits

..

No commits in common. "qoa_test" and "main" have entirely different histories.

14 changed files with 70 additions and 114 deletions

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
*.ogg filter=lfs diff=lfs merge=lfs -text
*.qoa filter=lfs diff=lfs merge=lfs -text

24
.vscode/launch.json vendored
View File

@ -1,24 +0,0 @@
{
// 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"
}
]
}

42
.vscode/tasks.json vendored
View File

@ -1,42 +0,0 @@
{
"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"
}
]
}

BIN
Content/housecleaning_herbal_mix.ogg (Stored with Git LFS)

Binary file not shown.

BIN
Content/housecleaning_herbal_mix.qoa (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>MoonWorksTest</RootNamespace>
<Platforms>x64</Platforms>

@ -1 +1 @@
Subproject commit a869a0e958fd307a2883d111489ea7c49793baf6
Subproject commit 111df04c0f7be740108cc3536eda3629572714d8

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,15 +1,12 @@
using System.Runtime.InteropServices;
using MoonWorks.Graphics;
using MoonWorks.Math.Float;
using MoonWorks.Math;
namespace MoonWorksTest
{
[StructLayout(LayoutKind.Sequential)]
struct PositionTexture : MoonWorks.Graphics.IVertexType
struct PositionTexture
{
public Vector3 Position;
public Vector2 Texture;
public static VertexElementFormat[] Formats => new VertexElementFormat[] { VertexElementFormat.Vector3, VertexElementFormat.Vector2 };
}
}

View File

@ -15,14 +15,9 @@ namespace MoonWorksTest
ScreenMode = ScreenMode.Windowed
};
FrameLimiterSettings limiterSettings = new FrameLimiterSettings
{
Mode = FrameLimiterMode.Uncapped
};
TestGame game = new TestGame(
windowCreateInfo,
limiterSettings,
PresentMode.FIFO,
60,
true
);

View File

@ -23,17 +23,23 @@ namespace MoonWorksTest
GraphicsPipeline mainGraphicsPipeline;
byte[] screenshotPixels;
Buffer screenshotBuffer;
uint screenshotBufferSize;
StaticSound music;
StaticSoundInstance musicInstance;
StreamingSoundOgg musicStream;
public TestGame(WindowCreateInfo windowCreateInfo, FrameLimiterSettings limiterSettings, int targetTimestep = 60, bool debugMode = false) : base(windowCreateInfo, limiterSettings, targetTimestep, debugMode)
bool screenshotInProgress = false;
public TestGame(WindowCreateInfo windowCreateInfo, PresentMode presentMode, int targetTimestep = 60, bool debugMode = false) : base(windowCreateInfo, presentMode, 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;
@ -42,8 +48,8 @@ namespace MoonWorksTest
var uploadCommandBuffer = GraphicsDevice.AcquireCommandBuffer();
woodTexture = Texture.FromImageFile(GraphicsDevice, uploadCommandBuffer, "Content/woodgrain.png");
noiseTexture = Texture.FromImageFile(GraphicsDevice, uploadCommandBuffer, "Content/noise.png");
woodTexture = Texture.LoadPNG(GraphicsDevice, uploadCommandBuffer, "Content/woodgrain.png");
noiseTexture = Texture.LoadPNG(GraphicsDevice, uploadCommandBuffer, "Content/noise.png");
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
@ -75,39 +81,41 @@ namespace MoonWorksTest
/* Pipeline */
/*
mainGraphicsPipeline = new GraphicsPipeline(
GraphicsDevice,
new GraphicsPipelineCreateInfo
{
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
new ColorAttachmentDescription(
MainWindow.SwapchainFormat,
GraphicsDevice.GetSwapchainFormat(Window),
ColorAttachmentBlendState.None
)
),
DepthStencilState = DepthStencilState.Disable,
VertexShaderInfo = GraphicsShaderInfo.Create(passthroughVertexShaderModule, "main", 0),
VertexInputState = VertexInputState.CreateSingleBinding<PositionTexture>(),
VertexInputState = new VertexInputState(
VertexBinding.Create<PositionTexture>(),
VertexAttribute.Create<PositionTexture>("Position", 0),
VertexAttribute.Create<PositionTexture>("Texture", 1)
),
PrimitiveType = PrimitiveType.TriangleList,
FragmentShaderInfo = GraphicsShaderInfo.Create<RaymarchUniforms>(raymarchFragmentShaderModule, "main", 2),
RasterizerState = RasterizerState.CW_CullBack,
ViewportState = new ViewportState((int)Window.Width, (int)Window.Height),
MultisampleState = MultisampleState.None
}
);
*/
// music = StaticSound.LoadOgg(AudioDevice, Path.Combine("Content", "title_screen.ogg"));
// musicInstance = music.CreateInstance();
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();
// musicInstance.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();
musicStream = StreamingSoundOgg.Load(AudioDevice, Path.Combine("Content", "title_screen.ogg"), false, true);
musicStream.Play();
}
protected override void Update(System.TimeSpan dt)
@ -115,11 +123,12 @@ namespace MoonWorksTest
raymarchUniforms.time += (float)dt.TotalSeconds;
}
protected override void Draw(double alpha)
protected override void Draw(System.TimeSpan dt, double alpha)
{
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(MainWindow);
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window);
var takeScreenshot = Inputs.Keyboard.IsPressed(Keycode.S) && !screenshotInProgress && (swapchainTexture != null);
if (swapchainTexture != null)
{
@ -127,7 +136,6 @@ namespace MoonWorksTest
new ColorAttachmentInfo(swapchainTexture, clearColor)
);
/*
commandBuffer.BindGraphicsPipeline(mainGraphicsPipeline);
commandBuffer.BindVertexBuffers(vertexBuffer);
@ -138,16 +146,46 @@ 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());
}
}
protected override void Destroy()
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()
{
}