Converted tooling to C.

This commit is contained in:
2021-11-07 23:34:05 -08:00
parent a2a839cbac
commit a6bae07e38
18 changed files with 637 additions and 394 deletions

View File

@ -14,6 +14,7 @@ target_sources(texture_generation
PRIVATE
texture_generation.c
../utils/file.c
../utils/image.c
)
target_include_directories(${PROJECT_NAME}
PUBLIC

View File

@ -9,15 +9,6 @@
#include "../utils/file.h"
#include "../utils/image.h"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#endif
#ifndef STB_IMAGE_RESIZE_IMPLEMENTATION
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include <stb_image_resize.h>
#endif
#define RESIZE_VARIANT_COUNT 4
int RESIZE_SCALES[RESIZE_VARIANT_COUNT] = { 1, 2, 3, 4 };
@ -27,7 +18,6 @@ int main(int argc, char *argv[]) {
char xml[2048];
char *in;
char *out;
char pathSep;
int w, h, channels, rw, rh, i, scale;
stbi_uc *dataOriginal;
stbi_uc *dataResized;
@ -38,13 +28,20 @@ int main(int argc, char *argv[]) {
}
// Set up strings
pathSep = FILE_PATH_SEP;
in = argv[1];
out = argv[2];
// Normalize slashes
fileNormalizeSlashes(in);
fileNormalizeSlashes(out);
// Check the output doesn't already exist
sprintf(path, "%s.xml", out);
file = fopen(path, "rb");
if(file != NULL) {
fclose(file);
return 0;
}
// Read in original texture
file = fopen(in, "rb");
@ -77,7 +74,6 @@ int main(int argc, char *argv[]) {
stbir_resize_uint8(dataOriginal, w, h, 0, dataResized, rw, rh, 0, channels);
// Determine output path
path[0] = '\0';
sprintf(path, "%s_%i.texture", out, scale);
// Open output file
@ -111,7 +107,6 @@ int main(int argc, char *argv[]) {
sprintf(xml, "%s\n</texture>", xml);
// Determine XML path
path[0] = '\0';
sprintf(path, "%s.xml", out);
// Write XML