F16 tex
This commit is contained in:
parent
fc85c5318b
commit
95ad5625a9
2 changed files with 60 additions and 15 deletions
|
|
@ -24,13 +24,31 @@ using namespace Crafter;
|
|||
namespace fs = std::filesystem;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc != 3) {
|
||||
std::cout << "Usage: crafter-asset <input_file> <output_file>\n";
|
||||
if (argc != 3 && argc != 2) { // Allow the possibility of just one argument (input file)
|
||||
std::cout << "Usage: crafter-asset <input_file> [output_file]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
fs::path inputPath = argv[1];
|
||||
fs::path outputPath = argv[2];
|
||||
fs::path outputPath;
|
||||
|
||||
// Check if output path is provided; if not, use input path with a modified extension
|
||||
if (argc == 3) {
|
||||
outputPath = argv[2];
|
||||
} else {
|
||||
// Determine extension type for output
|
||||
std::string extension = inputPath.extension().string();
|
||||
if (extension == ".obj") {
|
||||
outputPath = inputPath;
|
||||
outputPath.replace_extension(".mesh");
|
||||
} else if (extension == ".png") {
|
||||
outputPath = inputPath;
|
||||
outputPath.replace_extension(".tex");
|
||||
} else {
|
||||
std::cerr << "Unsupported file type: " << extension << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs::exists(inputPath)) {
|
||||
std::cerr << "Error: Input file does not exist.\n";
|
||||
|
|
@ -47,7 +65,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
else if (extension == ".png") {
|
||||
// Load PNG as TextureAsset
|
||||
auto texture = TextureAsset<Vector<std::uint8_t, 4, 0>>::LoadPNG(inputPath);
|
||||
auto texture = TextureAsset<Vector<_Float16, 4, 0>>::LoadPNG(inputPath);
|
||||
texture.Save(outputPath);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue