2021-01-20 03:33:27 +00:00
|
|
|
|
using RefreshCS;
|
|
|
|
|
|
|
|
|
|
namespace MoonWorks.Graphics
|
|
|
|
|
{
|
2022-02-23 05:14:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A texture slice specifies a subregion of a texture.
|
|
|
|
|
/// Many operations can use texture slices in place of textures for the sake of convenience.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public struct TextureSlice
|
|
|
|
|
{
|
|
|
|
|
public Texture Texture { get; }
|
|
|
|
|
public Rect Rectangle { get; }
|
|
|
|
|
public uint Depth { get; }
|
|
|
|
|
public uint Layer { get; }
|
|
|
|
|
public uint Level { get; }
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public TextureSlice(Texture texture)
|
|
|
|
|
{
|
|
|
|
|
Texture = texture;
|
|
|
|
|
Rectangle = new Rect
|
|
|
|
|
{
|
|
|
|
|
X = 0,
|
|
|
|
|
Y = 0,
|
|
|
|
|
W = (int) texture.Width,
|
|
|
|
|
H = (int) texture.Height
|
|
|
|
|
};
|
|
|
|
|
Depth = 0;
|
|
|
|
|
Layer = 0;
|
|
|
|
|
Level = 0;
|
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public TextureSlice(Texture texture, Rect rectangle, uint depth = 0, uint layer = 0, uint level = 0)
|
|
|
|
|
{
|
|
|
|
|
Texture = texture;
|
|
|
|
|
Rectangle = rectangle;
|
|
|
|
|
Depth = depth;
|
|
|
|
|
Layer = layer;
|
|
|
|
|
Level = level;
|
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
public Refresh.TextureSlice ToRefreshTextureSlice()
|
|
|
|
|
{
|
|
|
|
|
Refresh.TextureSlice textureSlice = new Refresh.TextureSlice
|
|
|
|
|
{
|
|
|
|
|
texture = Texture.Handle,
|
|
|
|
|
rectangle = Rectangle.ToRefresh(),
|
|
|
|
|
depth = Depth,
|
|
|
|
|
layer = Layer,
|
|
|
|
|
level = Level
|
|
|
|
|
};
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
return textureSlice;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-20 03:33:27 +00:00
|
|
|
|
}
|