Shipwright/OTRExporter/OTRExporter/TextureExporter.cpp
M4xw 442a88f03b git subrepo clone https://github.com/HarbourMasters/OTRExporter.git
subrepo:
  subdir:   "OTRExporter"
  merged:   "1503d3eef"
upstream:
  origin:   "https://github.com/HarbourMasters/OTRExporter.git"
  branch:   "master"
  commit:   "1503d3eef"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"
2022-03-22 02:53:02 +01:00

31 lines
951 B
C++

#include "TextureExporter.h"
#include "../ZAPD/ZFile.h"
void OTRExporter_Texture::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer)
{
ZTexture* tex = (ZTexture*)res;
WriteHeader(tex, outPath, writer, Ship::ResourceType::Texture);
auto start = std::chrono::steady_clock::now();
//printf("Exporting Texture %s\n", tex->GetName().c_str());
writer->Write((uint32_t)tex->GetTextureType());
writer->Write((uint32_t)tex->GetWidth());
writer->Write((uint32_t)tex->GetHeight());
writer->Write((uint32_t)tex->GetRawDataSize());
auto data = tex->parent->GetRawData();
writer->Write((char*)data.data() + tex->GetRawDataIndex(), tex->GetRawDataSize());
auto end = std::chrono::steady_clock::now();
size_t diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
//printf("Exported Texture %s in %zums\n", tex->GetName().c_str(), diff);
//if (diff > 2)
//printf("Export took %lms\n", diff);
}