]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/StateAttributeFactory.hxx
Fix cloud layer - point lights visibility issue
[simgear.git] / simgear / scene / util / StateAttributeFactory.hxx
1 #ifndef SIMGEAR_STATEATTRIBUTEFACTORY_HXX
2 #define SIMGEAR_STATEATTRIBUTEFACTORY_HXX 1
3
4 #include <OpenThreads/Mutex>
5 #include <osg/ref_ptr>
6 #include <osg/AlphaFunc>
7 #include <osg/BlendFunc>
8 #include <osg/ShadeModel>
9 #include <osg/TexEnv>
10
11 // Return read-only instances of common OSG state attributes.
12 namespace simgear
13 {
14 class StateAttributeFactory : public osg::Referenced {
15 public:
16     // Alpha test > .01
17     osg::AlphaFunc* getStandardAlphaFunc() { return _standardAlphaFunc.get(); }
18     // alpha source, 1 - alpha destination
19     osg::BlendFunc* getStandardBlendFunc() { return _standardBlendFunc.get(); }
20     // modulate
21     osg::TexEnv* getStandardTexEnv() { return _standardTexEnv.get(); }
22     osg::ShadeModel* getSmoothShadeModel() { return _smooth.get(); }
23     osg::ShadeModel* getFlatShadeModel() { return _flat.get(); }
24     static StateAttributeFactory* instance();
25 protected:
26     StateAttributeFactory();
27     osg::ref_ptr<osg::AlphaFunc> _standardAlphaFunc;
28     osg::ref_ptr<osg::ShadeModel> _smooth;
29     osg::ref_ptr<osg::ShadeModel> _flat;
30     osg::ref_ptr<osg::BlendFunc> _standardBlendFunc;
31     osg::ref_ptr<osg::TexEnv> _standardTexEnv;
32     static osg::ref_ptr<StateAttributeFactory> _theInstance;
33     static OpenThreads::Mutex _instanceMutex;
34 };
35 }
36 #endif