Fixed the handling of setLightingMode and inheritCullSettings so that it properly manages the GL_LIGHTING mode

This commit is contained in:
Robert Osfield
2009-01-28 09:23:26 +00:00
parent a51e95222d
commit d2d89498ad
2 changed files with 30 additions and 4 deletions

View File

@@ -165,7 +165,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
typedef Options LightingMode;
void setLightingMode(LightingMode mode) { _lightingMode=mode; }
void setLightingMode(LightingMode mode);
LightingMode getLightingMode() const { return _lightingMode; }
void setLight(osg::Light* light) { _light = light; }

View File

@@ -643,17 +643,43 @@ void SceneView::computeRightEyeViewport(const osg::Viewport *viewport)
}
}
void SceneView::setLightingMode(LightingMode mode)
{
if (mode==_lightingMode) return;
if (_lightingMode!=NO_SCENEVIEW_LIGHT)
{
// remove GL_LIGHTING mode
_globalStateSet->removeMode(GL_LIGHTING);
}
_lightingMode = mode;
if (_lightingMode!=NO_SCENEVIEW_LIGHT)
{
// add GL_LIGHTING mode
_globalStateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
}
}
void SceneView::inheritCullSettings(const osg::CullSettings& settings, unsigned int inheritanceMask)
{
if (_camera.valid() && _camera->getView())
{
if (inheritanceMask & osg::CullSettings::LIGHTING_MODE)
{
LightingMode newLightingMode = _lightingMode;
switch(_camera->getView()->getLightingMode())
{
case(osg::View::NO_LIGHT): setLightingMode(NO_SCENEVIEW_LIGHT); break;
case(osg::View::HEADLIGHT): setLightingMode(HEADLIGHT); break;
case(osg::View::SKY_LIGHT): setLightingMode(SKY_LIGHT); break;
case(osg::View::NO_LIGHT): newLightingMode = NO_SCENEVIEW_LIGHT; break;
case(osg::View::HEADLIGHT): newLightingMode = HEADLIGHT; break;
case(osg::View::SKY_LIGHT): newLightingMode = SKY_LIGHT; break;
}
if (newLightingMode != _lightingMode)
{
setLightingMode(newLightingMode);
}
}