1 #ifndef SIMGEAR_STATEATTRIBUTEFACTORY_HXX
2 #define SIMGEAR_STATEATTRIBUTEFACTORY_HXX 1
4 #include <OpenThreads/Mutex>
6 #include <osg/AlphaFunc>
7 #include <osg/BlendFunc>
8 #include <osg/ShadeModel>
11 // Return read-only instances of common OSG state attributes.
14 class StateAttributeFactory : public osg::Referenced {
17 osg::AlphaFunc* getStandardAlphaFunc() { return _standardAlphaFunc.get(); }
18 // alpha source, 1 - alpha destination
19 osg::BlendFunc* getStandardBlendFunc() { return _standardBlendFunc.get(); }
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();
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;