From 2bd88e1dc14fdfd1b9f36d5bec0c5292792e1c93 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 13 May 2022 16:26:26 -0700 Subject: [PATCH] add a few useful functions --- src/Graphics/RefreshStructs.cs | 18 ++++++++++++++++++ src/Graphics/State/VertexInputState.cs | 6 ++++++ src/Math/MathHelper.cs | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs index 518db0a0..6bd0c845 100644 --- a/src/Graphics/RefreshStructs.cs +++ b/src/Graphics/RefreshStructs.cs @@ -281,6 +281,24 @@ namespace MoonWorks.Graphics StencilStoreOp = StoreOp.DontCare; } + public DepthStencilAttachmentInfo( + Texture texture, + LoadOp loadOp = LoadOp.DontCare, + StoreOp storeOp = StoreOp.Store, + LoadOp stencilLoadOp = LoadOp.DontCare, + StoreOp stencilStoreOp = StoreOp.Store + ) { + Texture = texture; + Depth = 0; + Layer = 0; + Level = 0; + DepthStencilClearValue = new DepthStencilValue(); + LoadOp = loadOp; + StoreOp = storeOp; + StencilLoadOp = stencilLoadOp; + StencilStoreOp = stencilStoreOp; + } + public Refresh.DepthStencilAttachmentInfo ToRefresh() { return new Refresh.DepthStencilAttachmentInfo diff --git a/src/Graphics/State/VertexInputState.cs b/src/Graphics/State/VertexInputState.cs index a984219f..7ca93efe 100644 --- a/src/Graphics/State/VertexInputState.cs +++ b/src/Graphics/State/VertexInputState.cs @@ -8,6 +8,12 @@ public VertexBinding[] VertexBindings; public VertexAttribute[] VertexAttributes; + public VertexInputState() + { + VertexBindings = new VertexBinding[0]; + VertexAttributes = new VertexAttribute[0]; + } + public VertexInputState( VertexBinding vertexBinding, params VertexAttribute[] vertexAttributes diff --git a/src/Math/MathHelper.cs b/src/Math/MathHelper.cs index 15518ac7..5d582f25 100644 --- a/src/Math/MathHelper.cs +++ b/src/Math/MathHelper.cs @@ -280,6 +280,11 @@ namespace MoonWorks.Math return result; } + public static float Quantize(float value, float step) + { + return (float) System.Math.Floor(value / step) * step; + } + /// /// Converts radians to degrees. ///