]> git.mxchange.org Git - simgear.git/commitdiff
Use StateAttributeFactory for CullFace and ShadeModel attributes
authortimoore <timoore>
Wed, 10 Dec 2008 22:39:23 +0000 (22:39 +0000)
committertimoore <timoore>
Wed, 10 Dec 2008 22:39:23 +0000 (22:39 +0000)
simgear/scene/material/mat.cxx

index cd0bcee01f840410159b458ce089c0cb5e4a0cf7..33162abe510d3cf03228bedd1ff339832cd67dd6 100644 (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;
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // 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);