add some constructors to reduce boilerplate

pull/17/head
cosmonaut 2022-02-25 18:01:22 -08:00
parent 32b269526f
commit 7328cbc13d
3 changed files with 64 additions and 0 deletions

View File

@ -31,6 +31,22 @@ namespace MoonWorks.Graphics
public int W;
public int H;
public Rect(int x, int y, int w, int h)
{
X = x;
Y = y;
W = w;
H = h;
}
public Rect(int w, int h)
{
X = 0;
Y = 0;
W = w;
H = h;
}
// FIXME: can we do an unsafe cast somehow?
public Refresh.Rect ToRefresh()
{
@ -53,6 +69,36 @@ namespace MoonWorks.Graphics
public float H;
public float MinDepth;
public float MaxDepth;
public Viewport(float w, float h)
{
X = 0;
Y = 0;
W = w;
H = h;
MinDepth = 0;
MaxDepth = 1;
}
public Viewport(float x, float y, float w, float h)
{
X = x;
Y = y;
W = w;
H = h;
MinDepth = 0;
MaxDepth = 1;
}
public Viewport(float x, float y, float w, float h, float minDepth, float maxDepth)
{
X = x;
Y = y;
W = w;
H = h;
MinDepth = minDepth;
MaxDepth = maxDepth;
}
}
[StructLayout(LayoutKind.Sequential)]

View File

@ -7,5 +7,14 @@
{
public uint VertexSamplerBindingCount;
public uint FragmentSamplerBindingCount;
public GraphicsPipelineLayoutInfo(
uint vertexSamplerBindingCount,
uint fragmentSamplerBindingCount
)
{
VertexSamplerBindingCount = vertexSamplerBindingCount;
FragmentSamplerBindingCount = fragmentSamplerBindingCount;
}
}
}

View File

@ -7,5 +7,14 @@
{
public Viewport[] Viewports;
public Rect[] Scissors;
/// <summary>
/// A default single viewport with no scissor area.
/// </summary>
public ViewportState(int width, int height)
{
Viewports = new Viewport[] { new Viewport(width, height) };
Scissors = new Rect[] { new Rect(width, height) };
}
}
}