Fix for crash if screenspace image load fails

This commit is contained in:
GPayne
2020-10-18 14:13:27 -06:00
parent 8e05054602
commit 37ac1466b4
3 changed files with 42 additions and 30 deletions

View File

@@ -129,25 +129,31 @@ void ScreenSpaceImageOnline::update() {
return;
}
std::unique_ptr<ghoul::opengl::Texture> texture =
ghoul::io::TextureReader::ref().loadTexture(
reinterpret_cast<void*>(imageFile.buffer),
imageFile.size,
imageFile.format
);
try {
std::unique_ptr<ghoul::opengl::Texture> texture =
ghoul::io::TextureReader::ref().loadTexture(
reinterpret_cast<void*>(imageFile.buffer),
imageFile.size,
imageFile.format
);
if (texture) {
// Images don't need to start on 4-byte boundaries, for example if the
// image is only RGB
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (texture) {
// Images don't need to start on 4-byte boundaries, for example if the
// image is only RGB
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
texture->purgeFromRAM();
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
texture->purgeFromRAM();
_texture = std::move(texture);
_objectSize = _texture->dimensions();
_texture = std::move(texture);
_objectSize = _texture->dimensions();
_textureIsDirty = false;
}
}
catch (const ghoul::io::TextureReader::InvalidLoadException& e) {
_textureIsDirty = false;
LERRORC(e.component, e.message);
}
}
}