summaryrefslogtreecommitdiff
path: root/src/factories/CompressedTextureFactory.cpp
diff options
context:
space:
mode:
authorinspectredc <inspectredc@gmail.com>2025-03-04 12:22:26 +0000
committerLywx <kiritodev01@gmail.com>2025-03-09 17:26:40 -0600
commit445b7dad7d7604e09f7a9a4d39009dc471c99ba5 (patch)
treea5a63b5ea71f54f0654492260d6791da7582e41d /src/factories/CompressedTextureFactory.cpp
parent359ad0d884c91aab97a9113be9bb78be9e0f6844 (diff)
Add to config
Diffstat (limited to 'src/factories/CompressedTextureFactory.cpp')
-rw-r--r--src/factories/CompressedTextureFactory.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/factories/CompressedTextureFactory.cpp b/src/factories/CompressedTextureFactory.cpp
index 3fab3ef..1c8a974 100644
--- a/src/factories/CompressedTextureFactory.cpp
+++ b/src/factories/CompressedTextureFactory.cpp
@@ -68,29 +68,33 @@ ExportResult CompressedTextureHeaderExporter::Export(std::ostream &write, std::s
} else {
if(isOTR){
write << "static const ALIGN_ASSET(2) char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
- write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
- write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ if (Companion::Instance->AddTextureDefines()) {
+ write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
+ write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
+ }
} else {
write << "extern " << "u8 " << symbol << "[];\n";
- // Allocate worse case size
- uint8_t* compressedData;
- size_t compressedSize;
- size_t worstSize;
-
- switch (texture->mCompressionType) {
- case CompressionType::MIO0:
- worstSize = MIO0_HEADER_LENGTH + ((data.size()+7)/8) + data.size();
- compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t)));
- compressedSize = mio0_encode(data.data(), data.size(), compressedData);
- break;
- default:
- // UNIMPLEMENTED
- throw std::runtime_error("Unsupported Compressed Texture Type");
- break;
+ if (Companion::Instance->AddTextureDefines()) {
+ // Allocate worse case size
+ uint8_t* compressedData;
+ size_t compressedSize;
+ size_t worstSize;
+
+ switch (texture->mCompressionType) {
+ case CompressionType::MIO0:
+ worstSize = MIO0_HEADER_LENGTH + ((data.size()+7)/8) + data.size();
+ compressedData = static_cast<uint8_t*>(std::calloc(worstSize, sizeof(uint8_t)));
+ compressedSize = mio0_encode(data.data(), data.size(), compressedData);
+ break;
+ default:
+ // UNIMPLEMENTED
+ throw std::runtime_error("Unsupported Compressed Texture Type");
+ break;
+ }
+ write << "#define _" << symbol << "_COMPRESSED_SIZE 0x" << std::hex << compressedSize << std::dec << "\n";
+ write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
+ write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
}
- write << "#define _" << symbol << "_COMPRESSED_SIZE 0x" << std::hex << compressedSize << std::dec << "\n";
- write << "#define _" << symbol << "_WIDTH 0x" << std::hex << texture->mWidth << std::dec << "\n";
- write << "#define _" << symbol << "_HEIGHT 0x" << std::hex << texture->mHeight << std::dec << "\n";
}
}