Fixed a few small things.
This commit is contained in:
@ -45,6 +45,7 @@ function(tool_texture target)
|
||||
set(FILTER_MAG "")
|
||||
set(WRAP_X "")
|
||||
set(WRAP_Y "")
|
||||
set(SCALE "")
|
||||
|
||||
# Parse Args
|
||||
foreach(_PAIR IN LISTS ARGN)
|
||||
@ -73,6 +74,7 @@ function(tool_texture target)
|
||||
--wrapY="${WRAP_Y}"
|
||||
--filterMin="${FILTER_MIN}"
|
||||
--filterMag="${FILTER_MIN}"
|
||||
--scale="${SCALE}"
|
||||
COMMENT "Generating texture ${target} from ${FILE}"
|
||||
DEPENDS ${DEPS}
|
||||
)
|
||||
|
@ -16,7 +16,8 @@ std::map<std::string, std::string> TextureTool::getOptionalFlags() {
|
||||
{ "wrapX", "clamp" },
|
||||
{ "wrapY", "clamp" },
|
||||
{ "filterMin", "linear" },
|
||||
{ "filterMax", "linear" }
|
||||
{ "filterMax", "linear" },
|
||||
{ "scale", "" }
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,13 +41,19 @@ int32_t TextureTool::start() {
|
||||
}
|
||||
in.close();
|
||||
|
||||
// Convert to floating points
|
||||
// Buffer to output
|
||||
size_t len = STBI_rgb_alpha * w * h;
|
||||
uint8_t *dataImage = (uint8_t*)malloc(sizeof(uint8_t) * len);
|
||||
for(size_t i = 0; i < len; i++) {
|
||||
auto dataIn = imageRaw[i];
|
||||
dataImage[i] = dataIn;
|
||||
|
||||
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);
|
||||
w = w * scale;
|
||||
h = h * scale;
|
||||
} else {
|
||||
memcpy(dataImage, imageRaw, len);
|
||||
}
|
||||
|
||||
stbi_image_free(imageRaw);
|
||||
|
||||
std::function<int32_t(std::string)> wrapFromString = [&](std::string wr) {
|
||||
|
Reference in New Issue
Block a user