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
34
brutal.texture/Brutal.Texture/Ktx/KtxTextureWriter.cs
Normal file
34
brutal.texture/Brutal.Texture/Ktx/KtxTextureWriter.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using Brutal.KtxApi;
|
||||
|
||||
namespace Brutal.TextureApi.Ktx;
|
||||
|
||||
public static partial class Writer
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes an ITexture
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="filePath"></param>
|
||||
/// <exception cref="KtxTextureException"></exception>
|
||||
public static void SaveToFile(ITexture texture, string filePath)
|
||||
{
|
||||
var ktxTexture = texture as KtxTexture ?? Converter.ToV2KtxTexture(texture);
|
||||
try
|
||||
{
|
||||
var saveResult = ktxTexture.SaveToFile(filePath);
|
||||
if (saveResult != KtxErrorCode.Success)
|
||||
throw new KtxTextureException($"Failed to save texture KtxErrorCode:{saveResult}", saveResult);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (texture is not KtxTexture)
|
||||
ktxTexture.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveToFile(TextureDescriptor descriptor, string filePath)
|
||||
{
|
||||
var texture2Handle = Converter.ToKtxTexture2Handle(descriptor);
|
||||
SaveToFile(new KtxTexture(texture2Handle), filePath);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue