From 1625192c8162b56d170e19e7491e5fddafa7aa9a Mon Sep 17 00:00:00 2001 From: timoore Date: Wed, 10 Dec 2008 22:39:23 +0000 Subject: [PATCH] Use StateAttributeFactory for CullFace and ShadeModel attributes --- simgear/scene/material/mat.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index cd0bcee0..33162abe 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -29,7 +29,6 @@ #include #include -using std::map; #include @@ -45,9 +44,13 @@ using std::map; #include #include +#include #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);