Added constructor and SetData to Texture2D

obviously this has to be done for the other texture types as well at some point
This commit is contained in:
Simon Lübeß
2021-06-23 19:11:37 +02:00
parent 1f1b32e101
commit 819476a3ec
3 changed files with 239 additions and 4 deletions
+62
View File
@@ -0,0 +1,62 @@
using System;
namespace GlitchyEngine.Math
{
public struct ResourceBox
{
/// The x position of the left hand side of the box.
public uint32 Left;
/// The y position of the top of the box.
public uint32 Top;
/// The z position of the front of the box.
public uint32 Front;
/// The x position of the right hand side of the box.
public uint32 Right;
/// The y position of the bottom of the box.
public uint32 Bottom;
/// The z position of the back of the box.
public uint32 Back;
/**
* Returns true if the box is empty.
* A box is empty if the top value is greater than or equal to the bottom value,
* or the left value is greater than or equal to the right value,
* or the front value is greater than or equal to the back value.
*/
public bool IsEmpty => Top >= Bottom || Left >= Right || Front >= Back;
/**
* Instantiates a new instance of an uninitialized Box structure.
*/
public this()
{
this = default;
}
/**
* Instantiates a new instance of a Box structure that is initialized with the dimensions of a box.
*/
public this(uint32 left, uint32 top, uint32 front, uint32 right, uint32 bottom, uint32 back)
{
Left = left;
Top = top;
Front = front;
Right = right;
Bottom = bottom;
Back = back;
}
[Inline]
public static bool operator ==(ResourceBox l, ResourceBox r)
{
return l.Left == r.Left && l.Top == r.Top && l.Front == r.Front &&
l.Right == r.Right && l.Bottom == r.Bottom && l.Back == r.Back;
}
[Inline]
public static bool operator !=(ResourceBox l, ResourceBox r)
{
return !(l == r);
}
}
}