diff --git a/lib/RefreshCS b/lib/RefreshCS index a92549a..800069a 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit a92549a91395900f30fe9010dfe86e19fedd4e85 +Subproject commit 800069ad58bf33518280002749365d254f09cd38 diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index cb13996..e989a78 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using MoonWorks.Math; using RefreshCS; namespace MoonWorks.Graphics @@ -20,22 +21,51 @@ namespace MoonWorks.Graphics RenderPass renderPass, Framebuffer framebuffer, in Rect renderArea, - in DepthStencilValue depthStencilClearValue, - params Color[] clearColors + in DepthStencilValue depthStencilClearValue ) { - fixed (Color* clearColorPtr = &clearColors[0]) + Refresh.Refresh_BeginRenderPass( + Device.Handle, + Handle, + renderPass.Handle, + framebuffer.Handle, + renderArea.ToRefresh(), + IntPtr.Zero, + 0, + depthStencilClearValue.ToRefresh() + ); + } + + public unsafe void BeginRenderPass( + RenderPass renderPass, + Framebuffer framebuffer, + in Rect renderArea, + in DepthStencilValue depthStencilClearValue, + params Vector4[] clearColors + ) { + Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length]; + + for (var i = 0; i < clearColors.Length; i++) { - Refresh.Refresh_BeginRenderPass( - Device.Handle, - Handle, - renderPass.Handle, - framebuffer.Handle, - renderArea.ToRefresh(), - (IntPtr) clearColorPtr, - (uint)clearColors.Length, - depthStencilClearValue.ToRefresh() - ); + colors[i] = new Refresh.Vec4 + { + x = clearColors[i].X, + y = clearColors[i].Y, + z = clearColors[i].Z, + w = clearColors[i].W + }; } + + Refresh.Refresh_BeginRenderPass( + Device.Handle, + Handle, + renderPass.Handle, + framebuffer.Handle, + renderArea.ToRefresh(), + (IntPtr) colors, + (uint)clearColors.Length, + depthStencilClearValue.ToRefresh() + ); + } public unsafe void BeginRenderPass( @@ -216,9 +246,20 @@ namespace MoonWorks.Graphics in Rect clearRect, ClearOptionsFlags clearOptions, in DepthStencilValue depthStencilClearValue, - params Color[] clearColors + params Vector4[] clearColors ) { - Refresh.Color* colors = stackalloc Refresh.Color[clearColors.Length]; + Refresh.Vec4* colors = stackalloc Refresh.Vec4[clearColors.Length]; + for (var i = 0; i < clearColors.Length; i++) + { + colors[i] = new Refresh.Vec4 + { + x = clearColors[i].X, + y = clearColors[i].Y, + z = clearColors[i].Z, + w = clearColors[i].W + }; + } + Refresh.Refresh_Clear( Device.Handle, Handle, diff --git a/src/Graphics/RefreshEnums.cs b/src/Graphics/RefreshEnums.cs index d2f79f4..fb26909 100644 --- a/src/Graphics/RefreshEnums.cs +++ b/src/Graphics/RefreshEnums.cs @@ -97,7 +97,7 @@ namespace MoonWorks.Graphics SixtyFour } - public enum CubeMapFace + public enum CubeMapFace : uint { PositiveX, NegativeX,