]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/StateAttributeFactory.cxx
Fix cloud layer - point lights visibility issue
[simgear.git] / simgear / scene / util / StateAttributeFactory.cxx
1 #include <OpenThreads/ScopedLock>
2
3 #include "StateAttributeFactory.hxx"
4
5 using namespace osg;
6
7 namespace simgear
8 {
9 StateAttributeFactory::StateAttributeFactory()
10 {
11     _standardAlphaFunc = new AlphaFunc;
12     _standardAlphaFunc->setFunction(osg::AlphaFunc::GREATER);
13     _standardAlphaFunc->setReferenceValue(0.01);
14     _standardAlphaFunc->setDataVariance(Object::STATIC);
15     _smooth = new ShadeModel;
16     _smooth->setMode(ShadeModel::SMOOTH);
17     _smooth->setDataVariance(Object::STATIC);
18     _flat = new ShadeModel(ShadeModel::FLAT);
19     _flat->setDataVariance(Object::STATIC);
20     _standardBlendFunc = new BlendFunc;
21     _standardBlendFunc->setSource(BlendFunc::SRC_ALPHA);
22     _standardBlendFunc->setDestination(BlendFunc::ONE_MINUS_SRC_ALPHA);
23     _standardBlendFunc->setDataVariance(Object::STATIC);
24     _standardTexEnv = new TexEnv;
25     _standardTexEnv->setMode(TexEnv::MODULATE);
26     _standardTexEnv->setDataVariance(Object::STATIC);
27 }
28
29 osg::ref_ptr<StateAttributeFactory> StateAttributeFactory::_theInstance;
30 OpenThreads::Mutex StateAttributeFactory::_instanceMutex;
31
32 StateAttributeFactory* StateAttributeFactory::instance()
33 {
34     OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_instanceMutex);
35     if (!_theInstance.valid()) {
36         _theInstance = new StateAttributeFactory;
37     }
38     return _theInstance.get();
39 }
40 }