Added support for glLightModel functionality via osg::LightModel.

This commit is contained in:
Robert Osfield
2002-02-25 22:46:38 +00:00
parent aaa0a42205
commit e21af2adce
10 changed files with 256 additions and 6 deletions

View File

@@ -29,6 +29,7 @@
#include <osg/LineSegment>
#include <osg/PolygonMode>
#include <osg/Texture>
#include <osg/LightModel>
#include <osg/ShadeModel>
#include <osg/Notify>
@@ -101,8 +102,6 @@ Viewer::Viewer()
_viewFrustumCullingActive = true;
_smallFeatureCullingActive = true;
_two_sided_lighting=0;
_useDisplayLists = true;
_saveFileName = "saved_model.osg";
@@ -359,8 +358,6 @@ float Viewer::draw(unsigned int viewport)
{
osg::Timer_t beforeDraw = _timer.tick();
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_two_sided_lighting);
// do draw traversal.
getViewportSceneView(viewport)->draw();
@@ -943,7 +940,15 @@ void Viewer::keyboard(unsigned char key, int x, int y)
break;
case 'T' :
_two_sided_lighting = 1 - _two_sided_lighting;
{
osg::LightModel* lightmodel = dynamic_cast<LightModel*>(sceneView->getGlobalStateSet()->getAttribute(osg::StateAttribute::LIGHTMODEL));
if (lightmodel)
{
lightmodel = new osg::LightModel;
sceneView->getGlobalStateSet()->setAttribute(lightmodel);
}
lightmodel->setTwoSided(!lightmodel->getTwoSided());
}
break;
case 'w' :