Rename ddx_ktx to dds_ktx and add get_ASTC_internal_format

This commit is contained in:
Alberto Torres 2024-09-03 14:20:56 +02:00
parent e759f25519
commit e31d416f94
3 changed files with 37 additions and 0 deletions

View file

@ -248,3 +248,40 @@ proc ParseDdsKtx*(p: pointer, len: int): seq[KtxPart] =
else:
let err_msg = $cast[cstring](err.msg.addr)
raise ValueError.newException err_msg
func get_ASTC_internal_format*(blk_size: (int,int), is_sRGB: bool): int32 =
result = if is_sRGB:
case blk_size[0]*100 or blk_size[1]:
of 04_04: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
of 05_04: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
of 05_05: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
of 06_05: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
of 06_06: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
of 08_05: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
of 08_06: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
of 10_05: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
of 10_06: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
of 08_08: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
of 10_08: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
of 10_10: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
of 12_10: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
of 12_12: GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
else: 0'i32
else:
case blk_size[0]*100 or blk_size[1]:
of 04_04: GL_COMPRESSED_RGBA_ASTC_4x4_KHR
of 05_04: GL_COMPRESSED_RGBA_ASTC_5x4_KHR
of 05_05: GL_COMPRESSED_RGBA_ASTC_5x5_KHR
of 06_05: GL_COMPRESSED_RGBA_ASTC_6x5_KHR
of 06_06: GL_COMPRESSED_RGBA_ASTC_6x6_KHR
of 08_05: GL_COMPRESSED_RGBA_ASTC_8x5_KHR
of 08_06: GL_COMPRESSED_RGBA_ASTC_8x6_KHR
of 10_05: GL_COMPRESSED_RGBA_ASTC_10x5_KHR
of 10_06: GL_COMPRESSED_RGBA_ASTC_10x6_KHR
of 08_08: GL_COMPRESSED_RGBA_ASTC_8x8_KHR
of 10_08: GL_COMPRESSED_RGBA_ASTC_10x8_KHR
of 10_10: GL_COMPRESSED_RGBA_ASTC_10x10_KHR
of 12_10: GL_COMPRESSED_RGBA_ASTC_12x10_KHR
of 12_12: GL_COMPRESSED_RGBA_ASTC_12x12_KHR
else: 0'i32
assert result != 0, "Invalid ASTC block size " & $blk_size