diff --git a/TestGame/TestGame.cs b/TestGame/TestGame.cs
index 51163cc..ca90f18 100644
--- a/TestGame/TestGame.cs
+++ b/TestGame/TestGame.cs
@@ -98,8 +98,8 @@ public class TestGame : Game
// _scene.BeginDraw();
// _scene.EndDraw();
_renderer.BeginFrame();
- _renderer.ClearBackground(Color.Red);
- _renderer.ClearBackground(Color.Blue);
+ // _renderer.ClearBackground(Color.Aqua);
+ // // _renderer.DrawRectangle(new Vector2(128, 128), Color.Black);
_renderer.EndFrame();
}
}
diff --git a/Voile/Source/Rendering/Material.cs b/Voile/Source/Rendering/Material.cs
new file mode 100644
index 0000000..829c8f0
--- /dev/null
+++ b/Voile/Source/Rendering/Material.cs
@@ -0,0 +1,9 @@
+namespace Voile.Rendering;
+
+///
+/// An abstract class representing a render pipeline for the renderer, with entry points to fragment and vertex programs.
+///
+public abstract class Material
+{
+ public static UnlitMaterial Unlit => new UnlitMaterial();
+}
\ No newline at end of file
diff --git a/Voile/Source/Rendering/StandardRenderer.cs b/Voile/Source/Rendering/StandardRenderer.cs
index 875e1b8..3787ce1 100644
--- a/Voile/Source/Rendering/StandardRenderer.cs
+++ b/Voile/Source/Rendering/StandardRenderer.cs
@@ -123,7 +123,11 @@ namespace Voile.Rendering
}
///
- public override void EndFrame() => WgpuEndFrame();
+ public override void EndFrame()
+ {
+ WgpuEndFrame();
+ }
+
///
public override void Shutdown()
@@ -292,31 +296,31 @@ namespace Voile.Rendering
_wgpu.SurfaceGetCurrentTexture(_surface, ref _surfaceTexture);
_surfaceTextureView = _wgpu.TextureCreateView(_surfaceTexture.Texture, null);
- RenderPassColorAttachment* colorAttachments = stackalloc RenderPassColorAttachment[1];
- colorAttachments[0].View = _surfaceTextureView;
- colorAttachments[0].LoadOp = LoadOp.Clear;
- colorAttachments[0].ClearValue = VoileColorToWebGPUColor(_clearColor);
- colorAttachments[0].StoreOp = StoreOp.Store;
+ RenderPassColorAttachment colorAttachments = CreateClearColorAttachment(_surfaceTextureView, _clearColor);
- _renderPassDescriptor.ColorAttachments = colorAttachments;
- _renderPassDescriptor.ColorAttachmentCount = 1;
+ RenderPassDescriptor renderPassDescriptor = new()
+ {
+ ColorAttachments = &colorAttachments,
+ ColorAttachmentCount = 1
+ };
- _renderPassEncoder = _wgpu.CommandEncoderBeginRenderPass(_commandEncoder, _renderPassDescriptor);
+ _renderPassEncoder = _wgpu.CommandEncoderBeginRenderPass(_commandEncoder, renderPassDescriptor);
}
private unsafe void WgpuEndFrame()
{
_wgpu.RenderPassEncoderEnd(_renderPassEncoder);
var commandBuffer = _wgpu.CommandEncoderFinish(_commandEncoder, null);
+ _wgpu.CommandEncoderRelease(_commandEncoder);
_wgpu.QueueSubmit(_queue, 1, &commandBuffer);
- _wgpu.SurfacePresent(_surface);
+ _wgpu.CommandBufferRelease(commandBuffer);
+ _wgpu.SurfacePresent(_surface);
_wgpu.TextureViewRelease(_surfaceTextureView);
+
_wgpu.TextureRelease(_surfaceTexture.Texture);
_wgpu.RenderPassEncoderRelease(_renderPassEncoder);
- _wgpu.CommandBufferRelease(commandBuffer);
- _wgpu.CommandEncoderRelease(_commandEncoder);
}
private unsafe void ShutdownUnsafe()
@@ -332,6 +336,23 @@ namespace Voile.Rendering
return new Silk.NET.WebGPU.Color(color.R, color.G, color.B, color.A);
}
+ private unsafe RenderPassColorAttachment CreateClearColorAttachment(TextureView* view, Color clearColor)
+ {
+ var colorAttachment = new RenderPassColorAttachment
+ {
+ View = view,
+ LoadOp = LoadOp.Clear,
+ ClearValue = VoileColorToWebGPUColor(clearColor),
+ StoreOp = StoreOp.Store
+ };
+
+ return colorAttachment;
+ }
+
+ private unsafe RenderPipeline* CreatePipeline(Material fromMaterial)
+ {
+ return null;
+ }
private Vector2 _windowSize;
private IWindow? _window;
@@ -346,7 +367,6 @@ namespace Voile.Rendering
private SurfaceTexture _surfaceTexture;
private unsafe TextureView* _surfaceTextureView;
private unsafe CommandEncoder* _commandEncoder;
- private RenderPassDescriptor _renderPassDescriptor;
private unsafe RenderPassEncoder* _renderPassEncoder;
private Logger _logger = new(nameof(StandardRenderer));
diff --git a/Voile/Source/Rendering/UnlitMaterial.cs b/Voile/Source/Rendering/UnlitMaterial.cs
new file mode 100644
index 0000000..7cf242d
--- /dev/null
+++ b/Voile/Source/Rendering/UnlitMaterial.cs
@@ -0,0 +1,9 @@
+namespace Voile.Rendering;
+
+///
+/// A default material for unlit objects.
+///
+public class UnlitMaterial : Material
+{
+
+}
\ No newline at end of file
diff --git a/Voile/TODO.md b/Voile/TODO.md
index 5eaa6f5..1a70a1f 100644
--- a/Voile/TODO.md
+++ b/Voile/TODO.md
@@ -3,6 +3,7 @@
## Engine
### Core
+
- Virtual file system
- Hot reloading