2024-06-04 23:04:19 +00:00
|
|
|
using SDL2_gpuCS;
|
2024-03-01 07:53:11 +00:00
|
|
|
|
|
|
|
namespace MoonWorks.Graphics
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A texture region specifies a subregion of a texture.
|
|
|
|
/// These are used by copy commands.
|
|
|
|
/// </summary>
|
|
|
|
public struct TextureRegion
|
|
|
|
{
|
|
|
|
public TextureSlice TextureSlice;
|
|
|
|
public uint X;
|
|
|
|
public uint Y;
|
|
|
|
public uint Z;
|
|
|
|
public uint Width;
|
|
|
|
public uint Height;
|
|
|
|
public uint Depth;
|
|
|
|
|
|
|
|
public uint Size => (Width * Height * Depth * Texture.BytesPerPixel(TextureSlice.Texture.Format) / Texture.BlockSizeSquared(TextureSlice.Texture.Format)) >> (int) TextureSlice.MipLevel;
|
|
|
|
|
|
|
|
public TextureRegion(Texture texture)
|
|
|
|
{
|
|
|
|
TextureSlice = new TextureSlice(texture);
|
|
|
|
X = 0;
|
|
|
|
Y = 0;
|
|
|
|
Z = 0;
|
|
|
|
Width = texture.Width;
|
|
|
|
Height = texture.Height;
|
|
|
|
Depth = texture.Depth;
|
|
|
|
}
|
|
|
|
|
2024-06-04 23:04:19 +00:00
|
|
|
public SDL_Gpu.TextureRegion ToSDL()
|
2024-03-01 07:53:11 +00:00
|
|
|
{
|
2024-06-04 23:04:19 +00:00
|
|
|
return new SDL_Gpu.TextureRegion
|
2024-03-01 07:53:11 +00:00
|
|
|
{
|
2024-06-04 23:04:19 +00:00
|
|
|
TextureSlice = TextureSlice.ToSDL(),
|
|
|
|
X = X,
|
|
|
|
Y = Y,
|
|
|
|
Z = Z,
|
|
|
|
W = Width,
|
|
|
|
H = Height,
|
|
|
|
D = Depth
|
2024-03-01 07:53:11 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|