Use StateAttributeFactory for CullFace and ShadeModel attributes

This commit is contained in:
timoore 2008-12-10 22:39:23 +00:00
parent c5e8c6603c
commit 1625192c81

View File

@ -29,7 +29,6 @@
#include <string.h>
#include <map>
using std::map;
#include <plib/ul.h>
@ -45,9 +44,13 @@ using std::map;
#include <simgear/misc/sgstream.hxx>
#include <simgear/scene/model/model.hxx>
#include <simgear/scene/util/StateAttributeFactory.hxx>
#include "mat.hxx"
using std::map;
using namespace simgear;
////////////////////////////////////////////////////////////////////////
// Constructors and destructor.
@ -249,20 +252,15 @@ SGMaterial::get_state (int n)
void
SGMaterial::build_state( bool defer_tex_load )
{
StateAttributeFactory *attrFact = StateAttributeFactory::instance();
for (unsigned int i = 0; i < _status.size(); i++)
{
osg::StateSet *stateSet = new osg::StateSet;
stateSet->setUserData(new SGMaterialUserData(this));
// Set up the textured state
osg::ShadeModel* shadeModel = new osg::ShadeModel;
shadeModel->setMode(osg::ShadeModel::SMOOTH);
stateSet->setAttribute(shadeModel);
osg::CullFace* cullFace = new osg::CullFace;
cullFace->setMode(osg::CullFace::BACK);
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
stateSet->setAttribute(cullFace);
stateSet->setAttribute(attrFact->getSmoothShadeModel());
stateSet->setAttributeAndModes(attrFact->getCullFaceBack());
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);