Prevent null pointer deference when load has failed.

This was triggered by the TU154B; probably related to the console error

* "Image loading failed:Warning: reading "fgdata\AI\Aircraft\tu154b\Model" not supported.
This commit is contained in:
Richard Harrison
2017-01-21 00:54:01 +01:00
parent f9f2b4cbdb
commit c5cdfa1a1d

View File

@@ -450,7 +450,8 @@ SGMaterialAnimation::createAnimationGroup(osg::Group& parent)
stateSet->setTextureAttribute(0, texture2D,
osg::StateAttribute::OVERRIDE);
stateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
if (texture2D->getImage()->isImageTranslucent()) {
osg::ref_ptr<osg::Image> textureImage = texture2D->getImage();
if (textureImage && textureImage->isImageTranslucent()) {
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
}