Ensure uniform are there before trying to use them

This commit is contained in:
Frederic Bouvier 2012-04-14 18:00:42 +02:00
parent 4758447370
commit 77b8b278ea

View File

@ -72,11 +72,14 @@ public:
BOOST_FOREACH(osg::ref_ptr<simgear::Pass>& pass, technique->passes) BOOST_FOREACH(osg::ref_ptr<simgear::Pass>& pass, technique->passes)
{ {
osg::Uniform* amb = pass->getUniform("Ambient"); osg::Uniform* amb = pass->getUniform("Ambient");
amb->set(toOsg(_ambient) * dim); if (amb)
amb->set(toOsg(_ambient) * dim);
osg::Uniform* dif = pass->getUniform("Diffuse"); osg::Uniform* dif = pass->getUniform("Diffuse");
dif->set(toOsg(_diffuse) * dim); if (dif)
dif->set(toOsg(_diffuse) * dim);
osg::Uniform* spe = pass->getUniform("Specular"); osg::Uniform* spe = pass->getUniform("Specular");
spe->set(toOsg(_specular) * dim); if (spe)
spe->set(toOsg(_specular) * dim);
} }
} }
} }