namespace Voile
{
    /// <summary>
    /// A two-dimensional texture stored on the GPU.
    /// </summary>
    public class Texture2d : Resource
    {
        /// <summary>
        /// Internal handle for the texture. If it got successfully loaded into the GPU, the value will be other than -1.
        /// </summary>
        internal int Handle { get; set; } = -1;
        public int Width { get; set; }
        public int Height { get; set; }
        public int Mipmaps { get; set; } = 1;

        public byte[]? Buffer { get; private set; }
        public long BufferSize { get; set; }

        public TextureFormat Format { get; set; } = TextureFormat.UncompressedR8G8B8A8;
        public Texture2d(string path, byte[] buffer) : base(path)
        {
            Buffer = buffer;
        }

        public static Texture2d Empty => new Texture2d(string.Empty, new byte[] { });
    }

    public enum TextureFormat
    {
        UncompressedGrayscale = 1,
        UncompressedGrayAlpha,
        UncompressedR5G6B5,
        UncompressedR8G8B8,
        UncompressedR5G5B5A1,
        UncompressedR4G4B4A4,
        UncompressedR8G8B8A8,
        UncompressedR32,
        UncompressedR32G32B32,
        UncompressedR32G32B32A32,
        CompressedDXT1Rgb,
        CompressedDXT1Rgba,
        CompressedDXT3Rgba,
        CompressedDXT5Rgba,
        CompressedETC1Rgb,
        CompressedETC2Rgb,
        CompressedETC2EACRgba,
        CompressedPVRTRgb,
        CompressedPVRTRgba,
        CompressedASTC4x4Rgba,
        CompressedASTC8x8Rgba
    }
}