diff --git a/modules/asset_loader/include/vkcv/asset/asset_loader.hpp b/modules/asset_loader/include/vkcv/asset/asset_loader.hpp index 0ae31debb5725ee102bca0b3c17f931244e88220..8d80062bacce4a4d9f825a6884043cf69d439c98 100644 --- a/modules/asset_loader/include/vkcv/asset/asset_loader.hpp +++ b/modules/asset_loader/include/vkcv/asset/asset_loader.hpp @@ -308,6 +308,9 @@ int loadScene(const std::filesystem::path &path, Scene &scene); * loading a font atlas) and not meant to be used for regular assets. * The sampler is set to -1, signalling that this Texture was loaded * outside the context of a glTF-file. + * If there was an error loading or decoding the image, the returned struct + * will be cleared to all 0 with path and data being empty; make sure to always + * check that !data.empty() before using the struct. * * @param path must be the path to an image file. * @return Texture struct describing the loaded image. diff --git a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp index 5ce21ec8d884aaaa728fb87f66377083be1494fc..8042f1b2e98d535aaa5f2c8d19a38c658db6cdd4 100644 --- a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp +++ b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp @@ -760,7 +760,11 @@ namespace vkcv::asset { Texture texture; texture.path = path; texture.sampler = -1; - loadTextureData(texture); + if (loadTextureData(texture) != ASSET_SUCCESS) { + texture.path.clear(); + texture.w = texture.h = texture.channels = 0; + texture.data.clear(); + } return texture; }