mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 21:18:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
52
brutal.texture/Brutal.Texture/Stb/StbTextureF.cs
Normal file
52
brutal.texture/Brutal.Texture/Stb/StbTextureF.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using Brutal.Numerics;
|
||||
using Brutal.StbApi;
|
||||
using Brutal.TextureApi;
|
||||
|
||||
namespace Brutal.TextureApi.Stb;
|
||||
|
||||
public class StbTextureF : StbTexture
|
||||
{
|
||||
internal StbTextureF(StbImageF image)
|
||||
: base(
|
||||
new CreateInfo
|
||||
{
|
||||
Extent = new int2(image.Width, image.Height),
|
||||
Channels = image.Channels,
|
||||
BytesPerChannel = 4,
|
||||
}
|
||||
)
|
||||
{
|
||||
_image = image;
|
||||
}
|
||||
|
||||
public override TextureFormat Format
|
||||
{
|
||||
get
|
||||
{
|
||||
return _image.Channels switch
|
||||
{
|
||||
1 => TextureFormat.R32_SFloat,
|
||||
2 => TextureFormat.R32G32_SFloat,
|
||||
3 => TextureFormat.R32G32B32_SFloat,
|
||||
4 => TextureFormat.R32G32B32A32_SFloat,
|
||||
_ => throw new ArgumentOutOfRangeException(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected override unsafe byte* GetDataPointer()
|
||||
{
|
||||
return (byte*)_image.Data;
|
||||
}
|
||||
|
||||
protected override void FreeNativeResources()
|
||||
{
|
||||
if (_image.IsNotNull())
|
||||
{
|
||||
_image.Dispose();
|
||||
_image = default;
|
||||
}
|
||||
}
|
||||
|
||||
private StbImageF _image;
|
||||
}
|
||||
Loading…
Reference in a new issue