]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/SGSceneFeatures.hxx
Work around apparent OSG 3.2.0 normal binding bug.
[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 <simgear/structure/SGReferenced.hxx>
26
27 namespace osg { class Texture; }
28
29 class SGSceneFeatures : public SGReferenced {
30 public:
31   static SGSceneFeatures* instance();
32
33   enum TextureCompression {
34     DoNotUseCompression,
35     UseARBCompression,
36     UseDXT1Compression,
37     UseDXT3Compression,
38     UseDXT5Compression
39   };
40
41   void setTextureCompression(TextureCompression textureCompression)
42   { _textureCompression = textureCompression; }
43   TextureCompression getTextureCompression() const
44   { return _textureCompression; }
45   void setTextureCompression(osg::Texture* texture) const;
46
47   void setEnablePointSpriteLights(bool enable)
48   { _pointSpriteLights = enable; }
49   bool getEnablePointSpriteLights() const
50   {
51       return _pointSpriteLights;
52   }
53   bool getEnablePointSpriteLights(unsigned contextId) const
54   {
55     if (!_pointSpriteLights)
56       return false;
57     return getHavePointSprites(contextId);
58   }
59
60   void setEnableDistanceAttenuationLights(bool enable)
61   { _distanceAttenuationLights = enable; }
62   bool getEnableDistanceAttenuationLights(unsigned contextId) const
63   {
64     if (!_distanceAttenuationLights)
65       return false;
66     return getHavePointParameters(contextId);
67   }
68
69   void setEnableShaderLights(bool enable)
70   { _shaderLights = enable; }
71   bool getEnableShaderLights(unsigned contextId) const
72   {
73     if (!_shaderLights)
74       return false;
75     return getHaveShaderPrograms(contextId);
76   }
77   
78   void setTextureFilter(int max) 
79   { _textureFilter = max; }
80   int getTextureFilter() const
81   { return _textureFilter; }
82
83 protected:
84   bool getHavePointSprites(unsigned contextId) const;
85   bool getHaveFragmentPrograms(unsigned contextId) const;
86   bool getHaveVertexPrograms(unsigned contextId) const;
87   bool getHaveShaderPrograms(unsigned contextId) const;
88   bool getHavePointParameters(unsigned contextId) const;
89
90 private:
91   SGSceneFeatures();
92   SGSceneFeatures(const SGSceneFeatures&);
93   SGSceneFeatures& operator=(const SGSceneFeatures&);
94
95   TextureCompression _textureCompression;
96   bool _shaderLights;
97   bool _pointSpriteLights;
98   bool _distanceAttenuationLights;
99   int  _textureFilter;
100 };
101
102 #endif