62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <argparse/argparse.hpp>
|
|
#include <spdlog/spdlog.h>
|
|
#include <mijin/util/winundef.hpp>
|
|
|
|
#include "./packer.hpp"
|
|
|
|
namespace
|
|
{
|
|
inline constexpr int APP_ERROR = 1;
|
|
inline constexpr int USER_ERROR = 2;
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
std::string outputFile;
|
|
std::vector<std::string> inputFiles;
|
|
argparse::ArgumentParser parser("texture_packer");
|
|
parser.add_argument("output_file")
|
|
.store_into(outputFile);
|
|
parser.add_argument("input_file")
|
|
.store_into(inputFiles)
|
|
.nargs(argparse::nargs_pattern::at_least_one);
|
|
// now parse
|
|
try
|
|
{
|
|
parser.parse_args(argc, argv);
|
|
}
|
|
catch (std::runtime_error& error)
|
|
{
|
|
spdlog::error("{}", error.what());
|
|
return USER_ERROR;
|
|
}
|
|
|
|
try
|
|
{
|
|
sdl_gpu_test::Packer packer;
|
|
for (const std::string& inputFile : inputFiles)
|
|
{
|
|
if (inputFile.ends_with(".txt"))
|
|
{
|
|
packer.addImageList(inputFile);
|
|
}
|
|
else
|
|
{
|
|
packer.addImage(inputFile, inputFile);
|
|
}
|
|
}
|
|
packer.pack(outputFile);
|
|
}
|
|
catch(const std::runtime_error& error)
|
|
{
|
|
spdlog::error("{}", error.what());
|
|
return USER_ERROR;
|
|
}
|
|
|
|
return 0;
|
|
}
|