#include #include #include #include #include #include #include "AssetData.hpp" using json = nlohmann::json; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AssetMaterial, vertexShader, fragmentShader) int main(int argc, char **argv) { try { std::filesystem::path in = argv[1]; std::filesystem::path out = argv[2]; std::ifstream fin(in); std::ofstream fout(out); if (!fin.is_open()) { std::cout << "Error: Could not open input file." << std::endl; return 1; } if (!fout.is_open()) { std::cout << "Error: Could not open output file." << std::endl; return 1; } json data = json::parse(fin); for (const char *link : { "vertexShader", "fragmentShader" }) { std::filesystem::path linkPath = data[link]; auto linkPath8 = linkPath.generic_u8string(); uint32_t assetId = XXH32(linkPath8.data(), linkPath8.size(), 0); data[link] = assetId; } AssetMaterial material = data.get(); fout.write(reinterpret_cast(&material), sizeof(material)); fin.close(); fout.close(); } catch (const std::exception &e) { std::cerr << e.what() << std::endl; } return 0; }