Clean up some compressed texture loading code.

This commit is contained in:
Alex Szpakowski
2022-04-22 22:55:48 -03:00
parent 4e051c6faa
commit a9cca65a14
16 changed files with 37 additions and 68 deletions
+3 -4
View File
@@ -114,7 +114,7 @@ bool PKMHandler::canParseCompressed(Data *data)
return true;
}
StrongRef<CompressedMemory> PKMHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
StrongRef<ByteData> PKMHandler::parseCompressed(Data *filedata, std::vector<StrongRef<CompressedSlice>> &images, PixelFormat &format, bool &sRGB)
{
if (!canParseCompressed(filedata))
throw love::Exception("Could not decode compressed data (not a PKM file?)");
@@ -135,11 +135,10 @@ StrongRef<CompressedMemory> PKMHandler::parseCompressed(Data *filedata, std::vec
// The rest of the file after the header is all texture data.
size_t totalsize = filedata->getSize() - sizeof(PKMHeader);
StrongRef<CompressedMemory> memory;
memory.set(new CompressedMemory(totalsize), Acquire::NORETAIN);
StrongRef<ByteData> memory(new ByteData(totalsize, false), Acquire::NORETAIN);
// PKM files only store a single mipmap level.
memcpy(memory->data, (uint8 *) filedata->getData() + sizeof(PKMHeader), totalsize);
memcpy(memory->getData(), (uint8 *) filedata->getData() + sizeof(PKMHeader), totalsize);
// TODO: verify whether glCompressedTexImage works properly with the unpadded
// width and height values (extended == padded.)