]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/SGSceneFeatures.hxx
Use osg's builtin mechanisms to traverse only in range nodes with the
[simgear.git] / simgear / scene / util / SGSceneFeatures.hxx
1 /* -*-c++-*-
2  *
3  * Copyright (C) 2006-2007 Mathias Froehlich 
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  * MA 02110-1301, USA.
19  *
20  */
21
22 #ifndef SG_SCENE_FEATURES_HXX
23 #define SG_SCENE_FEATURES_HXX
24
25 #include <OpenThreads/Mutex>
26
27 #include <simgear/structure/SGReferenced.hxx>
28
29 namespace osg { class Texture; }
30
31 class SGSceneFeatures : public SGReferenced {
32 public:
33   static SGSceneFeatures* instance();
34
35   enum TextureCompression {
36     DoNotUseCompression,
37     UseARBCompression,
38     UseDXT1Compression,
39     UseDXT3Compression,
40     UseDXT5Compression
41   };
42
43   void setTextureCompression(TextureCompression textureCompression)
44   { _textureCompression = textureCompression; }
45   TextureCompression getTextureCompression() const
46   { return _textureCompression; }
47   void setTextureCompression(osg::Texture* texture) const;
48
49   void setEnablePointSpriteLights(bool enable)
50   { _pointSpriteLights = enable; }
51   bool getEnablePointSpriteLights(unsigned contextId) const
52   {
53     if (!_pointSpriteLights)
54       return false;
55     return getHavePointSprites(contextId);
56   }
57
58   void setEnableDistanceAttenuationLights(bool enable)
59   { _distanceAttenuationLights = enable; }
60   bool getEnableDistanceAttenuationLights(unsigned contextId) const
61   {
62     if (!_distanceAttenuationLights)
63       return false;
64     return getHavePointParameters(contextId);
65   }
66
67   void setEnableShaderLights(bool enable)
68   { _shaderLights = enable; }
69   bool getEnableShaderLights(unsigned contextId) const
70   {
71     if (!_shaderLights)
72       return false;
73     return getHaveShaderPrograms(contextId);
74   }
75   
76   void setTextureFilter( int max) 
77   { _textureFilter = max; }
78   int getTextureFilter() const {
79           return _textureFilter;
80   }
81
82 protected:  
83   bool getHavePointSprites(unsigned contextId) const;
84   bool getHaveFragmentPrograms(unsigned contextId) const;
85   bool getHaveVertexPrograms(unsigned contextId) const;
86   bool getHaveShaderPrograms(unsigned contextId) const;
87   bool getHavePointParameters(unsigned contextId) const;
88
89 private:
90   SGSceneFeatures();
91   SGSceneFeatures(const SGSceneFeatures&);
92   SGSceneFeatures& operator=(const SGSceneFeatures&);
93
94   TextureCompression _textureCompression;
95   bool _shaderLights;
96   bool _pointSpriteLights;
97   bool _distanceAttenuationLights;
98   int  _textureFilter;
99
100   static OpenThreads::Mutex _instanceMutex;
101 };
102
103 #endif