New textures

This commit is contained in:
2023-06-20 23:57:22 -07:00
parent e2e4732938
commit 160aa43973
9 changed files with 76 additions and 75 deletions

View File

@@ -17,7 +17,11 @@ std::map<std::string, std::string> TextureTool::getOptionalFlags() {
{ "wrapY", "clamp" },
{ "filterMin", "linear" },
{ "filterMax", "linear" },
{ "scale", "" }
{ "scale", "" },
{ "scaleWrapX", "clamp" },
{ "scaleWrapY", "clamp" },
{ "scaleFilterX", "nearest" },
{ "scaleFilterY", "nearest" }
};
}
@@ -45,11 +49,22 @@ int32_t TextureTool::start() {
size_t len = STBI_rgb_alpha * w * h;
uint8_t *dataImage = (uint8_t*)malloc(sizeof(uint8_t) * len);
float_t scale = 1;
if(!flags["scale"].empty()) {
float_t scale = std::stof(flags["scale"]);
stbir_resize_uint8(imageRaw, w, h, 0, dataImage, w * scale, h * scale, 0, STBI_rgb_alpha);
scale = std::stof(flags["scale"]);
}
if(scale != 1) {
stbir_resize_uint8_generic(
imageRaw, w, h, 0,
dataImage, w * scale, h * scale, 0,
STBI_rgb_alpha, -1, 0,
STBIR_EDGE_CLAMP, STBIR_FILTER_TRIANGLE, STBIR_COLORSPACE_LINEAR,
NULL
);
w = w * scale;
h = h * scale;
printf("Changing size to %ix%i\n", w, h);
} else {
memcpy(dataImage, imageRaw, len);
}

View File

@@ -55,6 +55,11 @@ void CodeGen::classGen(
}
line(out, "namespace Dawn {", "");
auto itTemplates = info.classTemplates.begin();
while(itTemplates != info.classTemplates.end()) {
line(out, "template<" + itTemplates->second + " " + itTemplates->first + ">", " ");
++itTemplates;
}
line(out, "class " + info.clazz + (info.extend.size() == 0 ? "{" : " : public " + info.extend + " {" ), " ");
if(info.protectedCode.size() > 0) {
line(out, "protected:", " ");

View File

@@ -14,6 +14,8 @@ namespace Dawn {
std::string constructorArgs = "";
std::string extendArgs = "";
std::map<std::string, std::string> classTemplates;
std::vector<std::string> constructorCode;
std::vector<std::string> protectedCode;