mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-28 01:14:24 +01:00
Add PVRTC support to KTX writer
This commit is contained in:
parent
4601cf00c7
commit
211bc5aece
@ -81,4 +81,21 @@
|
||||
|
||||
#endif // GL_VERTSION_4_2
|
||||
|
||||
|
||||
#ifndef COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||
#define COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
|
||||
#endif // COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||
|
||||
#ifndef COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
#define COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
|
||||
#endif // COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
|
||||
#ifndef COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||
#define COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
|
||||
#endif // COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||
|
||||
#ifndef COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||
#define COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
||||
#endif // COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||
|
||||
#endif // _IO_SRC_GL_DEFINES_H_
|
||||
|
@ -118,12 +118,25 @@ bool ImageWriterKTX::WriteImage() {
|
||||
tkvSz = (tkvSz + 3) & ~0x3; // 4-byte aligned
|
||||
|
||||
CompressedImage *ci = dynamic_cast<CompressedImage *>(&m_Image);
|
||||
if(ci && ci->GetFormat() == FasTC::eCompressionFormat_BPTC) {
|
||||
if(ci) {
|
||||
wtr.Write(0); // glType
|
||||
wtr.Write(1); // glTypeSize
|
||||
wtr.Write(GL_RGBA); // glFormat
|
||||
wtr.Write(GL_COMPRESSED_RGBA_BPTC_UNORM); // glInternalFormat
|
||||
wtr.Write(GL_RGBA); // glBaseFormat
|
||||
switch(ci->GetFormat()) {
|
||||
case FasTC::eCompressionFormat_BPTC:
|
||||
wtr.Write(GL_COMPRESSED_RGBA_BPTC_UNORM); // glInternalFormat
|
||||
wtr.Write(GL_RGBA); // glBaseFormat
|
||||
break;
|
||||
|
||||
case FasTC::eCompressionFormat_PVRTC:
|
||||
wtr.Write(COMPRESSED_RGBA_PVRTC_4BPPV1_IMG); // glInternalFormat
|
||||
wtr.Write(GL_RGBA); // glBaseFormat
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unsupported KTX compressed format: %d\n", ci->GetFormat());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
wtr.Write(GL_BYTE); // glType
|
||||
wtr.Write(1); // glTypeSize
|
||||
@ -148,6 +161,10 @@ bool ImageWriterKTX::WriteImage() {
|
||||
static const uint32 kImageSize = m_Width * m_Height;
|
||||
wtr.Write(kImageSize); // imageSize
|
||||
wtr.Write(ci->GetCompressedData(), kImageSize); // imagedata...
|
||||
} else if(ci && ci->GetFormat() == FasTC::eCompressionFormat_PVRTC) {
|
||||
static const uint32 kImageSize = m_Width * m_Height >> 1;
|
||||
wtr.Write(kImageSize); // imageSize
|
||||
wtr.Write(ci->GetCompressedData(), kImageSize); // imagedata...
|
||||
} else {
|
||||
static const uint32 kImageSize = m_Width * m_Height * 4;
|
||||
wtr.Write(kImageSize); // imageSize
|
||||
|
Loading…
Reference in New Issue
Block a user