Fixed the osg::Light so that it requires the user to explicitly define which

OpenGL light is being operated on, and also now relies upong the standard
osg::State handling of OpenGL modes to switch on the appropriate lights.

The previous static counter mechansim for the light number was causing a
redundent light to be created when the osg plugin created the first osg::Light
to use a prototype for other osg::Light's to be cloned from in the
.osg plugin execution.

The static count mechanism also prevent the lights modes being controlled
independantly from the setting of the light paramters themselves.  This
meant that a light once created was global, and couldn't be turned off
locally via the OSG's support for OpenGL mode enabling/disabling.  This
has been overcome with the new implementation, the user has complete
flexiblity of when and where to use the different lights at their
disposal.
This commit is contained in:
Robert Osfield
2001-12-24 21:34:40 +00:00
parent a6d329b812
commit 98c8447ae9
5 changed files with 43 additions and 41 deletions

View File

@@ -48,6 +48,7 @@ void SceneView::setDefaults()
_lightingMode=HEADLIGHT;
_light = new osg::Light;
_light->setLightNum(0);
_light->setAmbient(Vec4(0.00f,0.0f,0.00f,1.0f));
_light->setDiffuse(Vec4(0.8f,0.8f,0.8f,1.0f));
_light->setSpecular(Vec4(1.0f,1.0f,1.0f,1.0f));
@@ -75,6 +76,7 @@ void SceneView::setDefaults()
// enable lighting by default.
_globalState->setMode(GL_LIGHTING, osg::StateAttribute::ON);
_light->setStateSetModes(*_globalState,osg::StateAttribute::ON);
// enable depth testing by default.
_globalState->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);