diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-02-21 20:51:00 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2024-02-21 20:51:00 -0600 |
| commit | b8bcb110c2fba991cad049743073ffc7ece1143e (patch) | |
| tree | c5457a7f31cd6c665aee03eb45747ab613f651f5 | |
| parent | 12532b1a7657f7194f9f325f3b9428e173754550 (diff) | |
Fixed byte size on rgba16/rgba32 textures
| -rw-r--r-- | src/factories/TextureFactory.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/factories/TextureFactory.cpp b/src/factories/TextureFactory.cpp index 4f21c74..6aa4f82 100644 --- a/src/factories/TextureFactory.cpp +++ b/src/factories/TextureFactory.cpp @@ -93,7 +93,8 @@ void TextureHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedD } void TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) { - auto data = std::static_pointer_cast<TextureData>(raw)->mBuffer; + auto texture = std::static_pointer_cast<TextureData>(raw); + auto data = texture->mBuffer; auto symbol = GetSafeNode(node, "symbol", entryName); auto format = GetSafeNode<std::string>(node, "format"); @@ -107,12 +108,22 @@ void TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedDat std::ofstream file(dpath + ".inc.c", std::ios::binary); - for (int i = 0; i < data.size(); i++) { + size_t byteSize = std::max(1, (int) (texture->mFormat.depth / 8)); + + SPDLOG_INFO("Byte Size: {}", byteSize); + + for (int i = 0; i < data.size(); i+=byteSize) { if (i % 16 == 0 && i != 0) { file << std::endl; } - file << "0x" << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(data[i]) << ", "; + file << "0x"; + + for (int j = 0; j < byteSize; j++) { + file << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(data[i + j]); + } + + file << ", "; } file << std::endl; |
