in src/raw/RawModel.cpp [102:136]
int RawModel::AddTexture(
const std::string& name,
const std::string& fileName,
const std::string& fileLocation,
RawTextureUsage usage) {
if (name.empty()) {
return -1;
}
for (size_t i = 0; i < textures.size(); i++) {
// we allocate the struct even if the implementing image file is missing
if (textures[i].usage == usage &&
StringUtils::CompareNoCase(textures[i].fileLocation, fileLocation) == 0 &&
StringUtils::CompareNoCase(textures[i].name, name) == 0) {
return (int)i;
}
}
const ImageUtils::ImageProperties properties = ImageUtils::GetImageProperties(
!fileLocation.empty() ? fileLocation.c_str() : fileName.c_str());
RawTexture texture;
texture.name = name;
texture.width = properties.width;
texture.height = properties.height;
texture.mipLevels =
(int)ceilf(log2f(std::max((float)properties.width, (float)properties.height)));
texture.usage = usage;
texture.occlusion = (properties.occlusion == ImageUtils::IMAGE_TRANSPARENT)
? RAW_TEXTURE_OCCLUSION_TRANSPARENT
: RAW_TEXTURE_OCCLUSION_OPAQUE;
texture.fileName = fileName;
texture.fileLocation = fileLocation;
textures.emplace_back(texture);
return (int)textures.size() - 1;
}