Fix some KTX IO bugs

This commit is contained in:
Pavel Krajcevski 2014-03-12 13:18:43 -04:00
parent 865239542a
commit a51e63f5c0
2 changed files with 3 additions and 2 deletions

View File

@ -75,7 +75,7 @@ class ByteReader {
{ } { }
bool Advance(uint32 nBytes) { bool Advance(uint32 nBytes) {
if(nBytes < m_BytesLeft) { if(nBytes > m_BytesLeft) {
assert(!"Cannot read any more, unexpected bytes!"); assert(!"Cannot read any more, unexpected bytes!");
return false; return false;
} }
@ -278,6 +278,7 @@ bool ImageLoaderKTX::ReadData() {
switch(glInternalFormat) { switch(glInternalFormat) {
case GL_COMPRESSED_RGBA_BPTC_UNORM: case GL_COMPRESSED_RGBA_BPTC_UNORM:
m_Format = FasTC::eCompressionFormat_BPTC; m_Format = FasTC::eCompressionFormat_BPTC;
break;
default: default:
fprintf(stderr, "KTX loader - texture format (0x%x) unsupported!\n", glInternalFormat); fprintf(stderr, "KTX loader - texture format (0x%x) unsupported!\n", glInternalFormat);
return false; return false;

View File

@ -123,7 +123,7 @@ bool ImageWriterKTX::WriteImage() {
if(ci) { if(ci) {
wtr.Write(0); // glType wtr.Write(0); // glType
wtr.Write(1); // glTypeSize wtr.Write(1); // glTypeSize
wtr.Write(GL_RGBA); // glFormat wtr.Write(0); // glFormat must be zero for compressed images...
switch(ci->GetFormat()) { switch(ci->GetFormat()) {
case FasTC::eCompressionFormat_BPTC: case FasTC::eCompressionFormat_BPTC:
wtr.Write(GL_COMPRESSED_RGBA_BPTC_UNORM); // glInternalFormat wtr.Write(GL_COMPRESSED_RGBA_BPTC_UNORM); // glInternalFormat