root/OpenSceneGraph/trunk/include/osg/DisplaySettings @ 10588

Revision 10588, 10.5 kB (checked in by robert, 4 years ago)

Preliminary work on support for a texture object pool that is designed to help manage resources down the GPU more tightly.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_DisplaySettings
15#define OSG_DisplaySettings 1
16
17#include <osg/Referenced>
18
19#include <string>
20#include <vector>
21
22namespace osg {
23
24// forward declare
25class ArgumentParser;
26class ApplicationUsage;
27
28/** DisplaySettings class for encapsulating what visuals are required and
29  * have been set up, and the status of stereo viewing.*/
30class OSG_EXPORT DisplaySettings : public osg::Referenced
31{
32
33    public:
34
35        /** Maintain a DisplaySettings singleton for objects to query at runtime.*/
36        static DisplaySettings* instance();
37
38
39        DisplaySettings():
40            Referenced(true)
41        {
42            setDefaults();
43            readEnvironmentalVariables();
44        }
45       
46        DisplaySettings(ArgumentParser& arguments):
47            Referenced(true)
48        {
49            setDefaults();
50            readEnvironmentalVariables();
51            readCommandLine(arguments);
52        }
53
54        DisplaySettings(const DisplaySettings& vs);
55       
56
57        DisplaySettings& operator = (const DisplaySettings& vs);
58 
59        void setDisplaySettings(const DisplaySettings& vs);
60       
61        void merge(const DisplaySettings& vs);
62
63        void setDefaults();
64       
65        /** read the environmental variables.*/
66        void readEnvironmentalVariables();
67
68        /** read the commandline arguments.*/
69        void readCommandLine(ArgumentParser& arguments);
70       
71       
72        enum DisplayType
73        {
74            MONITOR,
75            POWERWALL,
76            REALITY_CENTER,
77            HEAD_MOUNTED_DISPLAY
78        };
79
80        void setDisplayType(DisplayType type) { _displayType = type; }
81       
82        DisplayType getDisplayType() const { return _displayType; }
83
84
85        void setStereo(bool on) { _stereo = on; }
86        bool getStereo() const { return _stereo; }
87
88        enum StereoMode
89        {
90            QUAD_BUFFER,
91            ANAGLYPHIC,
92            HORIZONTAL_SPLIT,
93            VERTICAL_SPLIT,
94            LEFT_EYE,
95            RIGHT_EYE,
96            HORIZONTAL_INTERLACE,
97            VERTICAL_INTERLACE,
98            CHECKERBOARD
99        };
100       
101        void setStereoMode(StereoMode mode) { _stereoMode = mode; }
102        StereoMode getStereoMode() const { return _stereoMode; }
103
104        void setEyeSeparation(float eyeSeparation) { _eyeSeparation = eyeSeparation; }
105        float getEyeSeparation() const { return _eyeSeparation; }
106
107        enum SplitStereoHorizontalEyeMapping
108        {
109            LEFT_EYE_LEFT_VIEWPORT,
110            LEFT_EYE_RIGHT_VIEWPORT
111        };
112       
113        void setSplitStereoHorizontalEyeMapping(SplitStereoHorizontalEyeMapping m) { _splitStereoHorizontalEyeMapping = m; }
114        SplitStereoHorizontalEyeMapping getSplitStereoHorizontalEyeMapping() const { return _splitStereoHorizontalEyeMapping; }
115
116        void setSplitStereoHorizontalSeparation(int s) { _splitStereoHorizontalSeparation = s; }
117        int getSplitStereoHorizontalSeparation() const { return _splitStereoHorizontalSeparation; }
118
119        enum SplitStereoVerticalEyeMapping
120        {
121            LEFT_EYE_TOP_VIEWPORT,
122            LEFT_EYE_BOTTOM_VIEWPORT
123        };
124
125        void setSplitStereoVerticalEyeMapping(SplitStereoVerticalEyeMapping m) { _splitStereoVerticalEyeMapping = m; }
126        SplitStereoVerticalEyeMapping getSplitStereoVerticalEyeMapping() const { return _splitStereoVerticalEyeMapping; }
127
128        void setSplitStereoVerticalSeparation(int s) { _splitStereoVerticalSeparation = s; }
129        int getSplitStereoVerticalSeparation() const { return _splitStereoVerticalSeparation; }
130
131        void setSplitStereoAutoAdjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
132        bool getSplitStereoAutoAdjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
133
134
135        void setScreenWidth(float width) { _screenWidth = width; }
136        float getScreenWidth() const { return _screenWidth; }
137
138        void setScreenHeight(float height) { _screenHeight = height; }
139        float getScreenHeight() const { return _screenHeight; }
140
141        void setScreenDistance(float distance) { _screenDistance = distance; }
142        float getScreenDistance() const { return _screenDistance; }
143
144
145
146        void setDoubleBuffer(bool flag) { _doubleBuffer = flag; }
147        bool getDoubleBuffer() const { return _doubleBuffer; }
148
149
150        void setRGB(bool flag) { _RGB = flag; }
151        bool getRGB() const { return _RGB; }
152
153
154        void setDepthBuffer(bool flag) { _depthBuffer = flag; }
155        bool getDepthBuffer() const { return _depthBuffer; }
156
157
158        void setMinimumNumAlphaBits(unsigned int bits) { _minimumNumberAlphaBits = bits; }
159        unsigned int getMinimumNumAlphaBits() const { return _minimumNumberAlphaBits; }
160        bool getAlphaBuffer() const { return _minimumNumberAlphaBits!=0; }
161
162        void setMinimumNumStencilBits(unsigned int bits) { _minimumNumberStencilBits = bits; }
163        unsigned int getMinimumNumStencilBits() const { return _minimumNumberStencilBits; }
164        bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; }
165
166        void setMinimumNumAccumBits(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha);
167        unsigned int getMinimumNumAccumRedBits() const { return _minimumNumberAccumRedBits; }
168        unsigned int getMinimumNumAccumGreenBits() const { return _minimumNumberAccumGreenBits; }
169        unsigned int getMinimumNumAccumBlueBits() const { return _minimumNumberAccumBlueBits; }
170        unsigned int getMinimumNumAccumAlphaBits() const { return _minimumNumberAccumAlphaBits; }
171        bool getAccumBuffer() const { return (_minimumNumberAccumRedBits+_minimumNumberAccumGreenBits+_minimumNumberAccumBlueBits+_minimumNumberAccumAlphaBits)!=0; }
172
173
174        void setMaxNumberOfGraphicsContexts(unsigned int num);
175        unsigned int getMaxNumberOfGraphicsContexts() const;
176
177        void setNumMultiSamples(unsigned int samples) { _numMultiSamples = samples; }
178        unsigned int getNumMultiSamples() const { return _numMultiSamples; }
179        bool getMultiSamples() const { return _numMultiSamples!=0; }
180       
181        void setCompileContextsHint(bool useCompileContexts) { _compileContextsHint = useCompileContexts; }
182        bool getCompileContextsHint() const { return _compileContextsHint; }
183       
184        void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
185        bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
186       
187        /** Set the hint for the total number of threads in the DatbasePager set up, inclusive of the number of http dedicated threads.*/
188        void setNumOfDatabaseThreadsHint(unsigned int numThreads) { _numDatabaseThreadsHint = numThreads; }
189
190        /** Get the hint for total number of threads in the DatbasePager set up, inclusive of the number of http dedicated threads.*/
191        unsigned int getNumOfDatabaseThreadsHint() const { return _numDatabaseThreadsHint; }
192
193        /** Set the hint for number of threads in the DatbasePager to dedicate to reading http requests.*/
194        void setNumOfHttpDatabaseThreadsHint(unsigned int numThreads) { _numHttpDatabaseThreadsHint = numThreads; }
195
196        /** Get the hint for number of threads in the DatbasePager dedicated to reading http requests.*/
197        unsigned int getNumOfHttpDatabaseThreadsHint() const { return _numHttpDatabaseThreadsHint; }
198       
199        void setApplication(const std::string& application) { _application = application; }
200        const std::string& getApplication() { return _application; }
201
202
203        void setMaxTexturePoolSize(unsigned int size) { _maxTexturePoolSize = size; }
204        unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
205
206        void setMaxVBOPoolSize(unsigned int size) { _maxVBOPoolSize = size; }
207        unsigned int getMaxVBOPoolSize() const { return _maxVBOPoolSize; }
208
209        void setMaxFBOPoolSize(unsigned int size) { _maxFBOPoolSize = size; }
210        unsigned int getMaxFBOPoolSize() const { return _maxFBOPoolSize; }
211
212    protected:
213   
214        virtual ~DisplaySettings();
215
216
217        DisplayType                     _displayType;
218        bool                            _stereo;
219        StereoMode                      _stereoMode;
220        float                           _eyeSeparation;
221        float                           _screenWidth;
222        float                           _screenHeight;
223        float                           _screenDistance;
224
225        SplitStereoHorizontalEyeMapping _splitStereoHorizontalEyeMapping;
226        int                             _splitStereoHorizontalSeparation;
227        SplitStereoVerticalEyeMapping   _splitStereoVerticalEyeMapping;
228        int                             _splitStereoVerticalSeparation;
229        bool                            _splitStereoAutoAdjustAspectRatio;
230   
231        bool                            _doubleBuffer;
232        bool                            _RGB;
233        bool                            _depthBuffer;
234        unsigned int                    _minimumNumberAlphaBits;
235        unsigned int                    _minimumNumberStencilBits;
236        unsigned int                    _minimumNumberAccumRedBits;
237        unsigned int                    _minimumNumberAccumGreenBits;
238        unsigned int                    _minimumNumberAccumBlueBits;
239        unsigned int                    _minimumNumberAccumAlphaBits;
240
241        unsigned int                    _maxNumOfGraphicsContexts;
242       
243        unsigned int                    _numMultiSamples;
244       
245        bool                            _compileContextsHint;
246        bool                            _serializeDrawDispatch;
247
248        unsigned int                    _numDatabaseThreadsHint;
249        unsigned int                    _numHttpDatabaseThreadsHint;
250       
251        std::string                     _application;
252
253        unsigned int                    _maxTexturePoolSize;
254        unsigned int                    _maxVBOPoolSize;
255        unsigned int                    _maxFBOPoolSize;
256};
257
258}
259
260# endif
Note: See TracBrowser for help on using the browser.