mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
36
brutal.texture/Brutal.Texture/Gli/GliTextureLoader.cs
Normal file
36
brutal.texture/Brutal.Texture/Gli/GliTextureLoader.cs
Normal 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"]);
|
||||
}
|
||||
Loading…
Reference in a new issue