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

View file

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