MoonWorks/src/Graphics/TextureSlice.cs

32 lines
663 B
C#
Raw Normal View History

2024-06-04 17:20:07 +00:00
using SDL2_gpuCS;
namespace MoonWorks.Graphics;
2024-06-04 17:20:07 +00:00
/// <summary>
/// A texture slice specifies a subresource of a texture.
/// </summary>
public struct TextureSlice
{
2024-06-04 17:20:07 +00:00
public Texture Texture;
public uint MipLevel;
public uint Layer;
2024-06-04 17:20:07 +00:00
public uint Size => (Texture.Width * Texture.Height * Texture.Depth * Texture.BytesPerPixel(Texture.Format) / Texture.BlockSizeSquared(Texture.Format)) >> (int) MipLevel;
2024-06-04 17:20:07 +00:00
public TextureSlice(Texture texture)
{
Texture = texture;
MipLevel = 0;
Layer = 0;
}
2024-06-04 17:20:07 +00:00
public SDL_Gpu.TextureSlice ToSDL()
{
return new SDL_Gpu.TextureSlice
2022-02-23 05:14:32 +00:00
{
2024-06-04 17:20:07 +00:00
Texture = Texture.Handle,
MipLevel = MipLevel,
Layer = Layer
};
2022-02-23 05:14:32 +00:00
}
}