mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Don't crash when failing to convert a texture to KTX format
This commit is contained in:
parent
3bef5ad528
commit
1ccf715e3b
1 changed files with 13 additions and 9 deletions
|
@ -526,16 +526,20 @@ void ImageReader::read() {
|
|||
|
||||
// Save the image into a KTXFile
|
||||
auto ktx = gpu::Texture::serialize(*texture);
|
||||
const char* data = reinterpret_cast<const char*>(ktx->_storage->data());
|
||||
size_t length = ktx->_storage->size();
|
||||
KTXFilePointer file;
|
||||
auto& ktxCache = DependencyManager::get<TextureCache>()->_ktxCache;
|
||||
if (!ktx || !(file = ktxCache.writeFile(data, KTXCache::Metadata(_hash, length)))) {
|
||||
qCWarning(modelnetworking) << _url << "file cache failed";
|
||||
if (ktx) {
|
||||
const char* data = reinterpret_cast<const char*>(ktx->_storage->data());
|
||||
size_t length = ktx->_storage->size();
|
||||
KTXFilePointer file;
|
||||
auto& ktxCache = DependencyManager::get<TextureCache>()->_ktxCache;
|
||||
if (!ktx || !(file = ktxCache.writeFile(data, KTXCache::Metadata(_hash, length)))) {
|
||||
qCWarning(modelnetworking) << _url << "file cache failed";
|
||||
} else {
|
||||
resource.staticCast<NetworkTexture>()->_file = file;
|
||||
auto ktx = file->getKTX();
|
||||
texture->setKtxBacking(ktx);
|
||||
}
|
||||
} else {
|
||||
resource.staticCast<NetworkTexture>()->_file = file;
|
||||
auto ktx = file->getKTX();
|
||||
texture->setKtxBacking(ktx);
|
||||
qCWarning(modelnetworking) << "Unable to serialize texture to KTX " << _url;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue