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