Fixed colors in shaders.
This commit is contained in:
@ -21,8 +21,8 @@ int32_t TextureTool::start() {
|
||||
if(!in.open(FILE_MODE_READ)) return 1;
|
||||
|
||||
int w, h, channels;
|
||||
auto dataImage = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha);
|
||||
if(dataImage == NULL) {
|
||||
auto imageRaw = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha);
|
||||
if(imageRaw == NULL) {
|
||||
std::cout << "Failed to load input texture!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@ -30,6 +30,12 @@ int32_t TextureTool::start() {
|
||||
|
||||
// Convert to floating points
|
||||
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;
|
||||
}
|
||||
stbi_image_free(imageRaw);
|
||||
|
||||
// Open and create output
|
||||
File out(flags["output"] + ".texture");
|
||||
@ -55,7 +61,7 @@ int32_t TextureTool::start() {
|
||||
std::cout << "Failed to write texture data for " << out.filename << std::endl;
|
||||
return 1;
|
||||
}
|
||||
stbi_image_free(dataImage);
|
||||
free(dataImage);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user