namespace Brutal.TextureApi;
///
/// Extension methods library for ITexture
///
public static class DerivedTexturePropertiesExtensions
{
extension(ITexture texture)
{
///
/// Determines whether the specified texture represents a 3-dimensional texture.
///
/// true if the texture has three dimensions; otherwise, false.
public bool Is3d => texture.DimensionCount == 3;
///
/// Determines whether the specified texture represents a two-dimensional texture.
///
/// true if the texture has exactly two dimensions; otherwise, false.
public bool Is2d => texture.DimensionCount == 2;
///
/// Determines whether the specified texture is one-dimensional.
///
/// true if the texture has a single dimension; otherwise, false.
public bool Is1d => texture.DimensionCount == 1;
///
/// The width of this texture (in texels)
///
public int Width => texture.Extent.X;
///
/// The height of this texture (in texels)
///
public int Height => texture.Extent.Y;
///
/// The depth of this texture (in texels)
///
public int Depth => texture.Extent.Z;
///
/// Calculates the dimensions of a texture at the specified mipmap level.
///
/// The mipmap level for which to calculate the extent. Must be greater than or equal to zero.
/// A TexelCount3 containing the width, height, and depth of the texture at the specified mipmap level. Each
/// dimension will be at least 1.
public TexelCount3 Extent(int level) =>
new(
Math.Max(1, texture.Width >> level),
Math.Max(1, texture.Height >> level),
Math.Max(1, texture.Depth >> level)
);
}
}