SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d

View file

@ -0,0 +1,36 @@
using System.Collections.Frozen;
using Brutal.Pointers.Extensions;
namespace Brutal.TextureApi.Gli;
public static partial class Loader
{
public static GliTexture LoadFromFile(string filePath)
{
var nativeTexture = new GliApi.Gli.Texture(filePath);
if (nativeTexture.IsNull())
{
nativeTexture.Dispose();
throw new GliTextureException($"Failed to load texture from filePath \"{filePath}\"");
}
return new GliTexture(nativeTexture);
}
public static unsafe GliTexture LoadFromMemory(ReadOnlySpan<byte> data)
{
var nativeTexture = new GliApi.Gli.Texture(data);
if (nativeTexture.IsNull())
{
nativeTexture.Dispose();
throw new GliTextureException($"Failed to load texture from data at 0x{(nint)data.AsPointer()}");
}
return new GliTexture(nativeTexture);
}
public static FrozenSet<string> SupportedExtensions { get; } =
FrozenSet.Create(StringComparer.OrdinalIgnoreCase, [".dds", ".ktx", ".kmg"]);
}