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

Revision 10588, 10.5 kB (checked in by robert, 5 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
RevLine 
[5328]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
[1529]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*/
[235]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
[1613]24// forward declare
25class ArgumentParser;
26class ApplicationUsage;
27
[235]28/** DisplaySettings class for encapsulating what visuals are required and
29  * have been set up, and the status of stereo viewing.*/
[4021]30class OSG_EXPORT DisplaySettings : public osg::Referenced
[235]31{
32
33    public:
34
[3347]35        /** Maintain a DisplaySettings singleton for objects to query at runtime.*/
[434]36        static DisplaySettings* instance();
37
38
[7256]39        DisplaySettings():
40            Referenced(true)
[235]41        {
42            setDefaults();
43            readEnvironmentalVariables();
44        }
45       
[7256]46        DisplaySettings(ArgumentParser& arguments):
47            Referenced(true)
[235]48        {
49            setDefaults();
50            readEnvironmentalVariables();
[1696]51            readCommandLine(arguments);
[235]52        }
53
54        DisplaySettings(const DisplaySettings& vs);
55       
56
57        DisplaySettings& operator = (const DisplaySettings& vs);
[434]58 
[2948]59        void setDisplaySettings(const DisplaySettings& vs);
[235]60       
61        void merge(const DisplaySettings& vs);
62
63        void setDefaults();
64       
[2948]65        /** read the environmental variables.*/
[235]66        void readEnvironmentalVariables();
67
[1610]68        /** read the commandline arguments.*/
[1696]69        void readCommandLine(ArgumentParser& arguments);
[235]70       
[2336]71       
72        enum DisplayType
73        {
74            MONITOR,
75            POWERWALL,
76            REALITY_CENTER,
77            HEAD_MOUNTED_DISPLAY
78        };
[235]79
[2336]80        void setDisplayType(DisplayType type) { _displayType = type; }
81       
82        DisplayType getDisplayType() const { return _displayType; }
83
84
[1133]85        void setStereo(bool on) { _stereo = on; }
86        bool getStereo() const { return _stereo; }
[235]87
88        enum StereoMode
89        {
90            QUAD_BUFFER,
91            ANAGLYPHIC,
92            HORIZONTAL_SPLIT,
[1307]93            VERTICAL_SPLIT,
94            LEFT_EYE,
[4613]95            RIGHT_EYE,
96            HORIZONTAL_INTERLACE,
[7277]97            VERTICAL_INTERLACE,
98            CHECKERBOARD
[235]99        };
100       
[1133]101        void setStereoMode(StereoMode mode) { _stereoMode = mode; }
102        StereoMode getStereoMode() const { return _stereoMode; }
[235]103
[1133]104        void setEyeSeparation(float eyeSeparation) { _eyeSeparation = eyeSeparation; }
105        float getEyeSeparation() const { return _eyeSeparation; }
[235]106
[558]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; }
[235]115
[1133]116        void setSplitStereoHorizontalSeparation(int s) { _splitStereoHorizontalSeparation = s; }
117        int getSplitStereoHorizontalSeparation() const { return _splitStereoHorizontalSeparation; }
[558]118
119        enum SplitStereoVerticalEyeMapping
120        {
121            LEFT_EYE_TOP_VIEWPORT,
[709]122            LEFT_EYE_BOTTOM_VIEWPORT
[558]123        };
124
125        void setSplitStereoVerticalEyeMapping(SplitStereoVerticalEyeMapping m) { _splitStereoVerticalEyeMapping = m; }
126        SplitStereoVerticalEyeMapping getSplitStereoVerticalEyeMapping() const { return _splitStereoVerticalEyeMapping; }
127
[1133]128        void setSplitStereoVerticalSeparation(int s) { _splitStereoVerticalSeparation = s; }
129        int getSplitStereoVerticalSeparation() const { return _splitStereoVerticalSeparation; }
[558]130
[7101]131        void setSplitStereoAutoAdjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
132        bool getSplitStereoAutoAdjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
[558]133
[1979]134
[2413]135        void setScreenWidth(float width) { _screenWidth = width; }
136        float getScreenWidth() const { return _screenWidth; }
137
[1133]138        void setScreenHeight(float height) { _screenHeight = height; }
139        float getScreenHeight() const { return _screenHeight; }
[235]140
[2413]141        void setScreenDistance(float distance) { _screenDistance = distance; }
142        float getScreenDistance() const { return _screenDistance; }
[235]143
[2413]144
145
[1133]146        void setDoubleBuffer(bool flag) { _doubleBuffer = flag; }
147        bool getDoubleBuffer() const { return _doubleBuffer; }
[235]148
149
[1133]150        void setRGB(bool flag) { _RGB = flag; }
151        bool getRGB() const { return _RGB; }
[235]152
153
[1133]154        void setDepthBuffer(bool flag) { _depthBuffer = flag; }
155        bool getDepthBuffer() const { return _depthBuffer; }
[235]156
157
[1133]158        void setMinimumNumAlphaBits(unsigned int bits) { _minimumNumberAlphaBits = bits; }
159        unsigned int getMinimumNumAlphaBits() const { return _minimumNumberAlphaBits; }
160        bool getAlphaBuffer() const { return _minimumNumberAlphaBits!=0; }
[235]161
[1133]162        void setMinimumNumStencilBits(unsigned int bits) { _minimumNumberStencilBits = bits; }
163        unsigned int getMinimumNumStencilBits() const { return _minimumNumberStencilBits; }
164        bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; }
[235]165
[4665]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; }
[434]172
[4665]173
[5358]174        void setMaxNumberOfGraphicsContexts(unsigned int num);
175        unsigned int getMaxNumberOfGraphicsContexts() const;
[434]176
[5043]177        void setNumMultiSamples(unsigned int samples) { _numMultiSamples = samples; }
178        unsigned int getNumMultiSamples() const { return _numMultiSamples; }
179        bool getMultiSamples() const { return _numMultiSamples!=0; }
[7215]180       
181        void setCompileContextsHint(bool useCompileContexts) { _compileContextsHint = useCompileContexts; }
182        bool getCompileContextsHint() const { return _compileContextsHint; }
[7274]183       
184        void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
185        bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
[9055]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; }
[434]189
[9055]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.*/
[10350]194        void setNumOfHttpDatabaseThreadsHint(unsigned int numThreads) { _numHttpDatabaseThreadsHint = numThreads; }
[9055]195
196        /** Get the hint for number of threads in the DatbasePager dedicated to reading http requests.*/
197        unsigned int getNumOfHttpDatabaseThreadsHint() const { return _numHttpDatabaseThreadsHint; }
[9191]198       
199        void setApplication(const std::string& application) { _application = application; }
200        const std::string& getApplication() { return _application; }
[9055]201
[10588]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
[235]212    protected:
213   
[1463]214        virtual ~DisplaySettings();
215
[235]216
[2336]217        DisplayType                     _displayType;
[558]218        bool                            _stereo;
219        StereoMode                      _stereoMode;
[1110]220        float                           _eyeSeparation;
[2413]221        float                           _screenWidth;
222        float                           _screenHeight;
[558]223        float                           _screenDistance;
224
225        SplitStereoHorizontalEyeMapping _splitStereoHorizontalEyeMapping;
[1110]226        int                             _splitStereoHorizontalSeparation;
[558]227        SplitStereoVerticalEyeMapping   _splitStereoVerticalEyeMapping;
[1110]228        int                             _splitStereoVerticalSeparation;
[1979]229        bool                            _splitStereoAutoAdjustAspectRatio;
[235]230   
[558]231        bool                            _doubleBuffer;
232        bool                            _RGB;
233        bool                            _depthBuffer;
234        unsigned int                    _minimumNumberAlphaBits;
235        unsigned int                    _minimumNumberStencilBits;
[4665]236        unsigned int                    _minimumNumberAccumRedBits;
237        unsigned int                    _minimumNumberAccumGreenBits;
238        unsigned int                    _minimumNumberAccumBlueBits;
239        unsigned int                    _minimumNumberAccumAlphaBits;
[235]240
[1141]241        unsigned int                    _maxNumOfGraphicsContexts;
[5043]242       
243        unsigned int                    _numMultiSamples;
[7215]244       
245        bool                            _compileContextsHint;
[7274]246        bool                            _serializeDrawDispatch;
[235]247
[9055]248        unsigned int                    _numDatabaseThreadsHint;
249        unsigned int                    _numHttpDatabaseThreadsHint;
[9191]250       
251        std::string                     _application;
[9055]252
[10588]253        unsigned int                    _maxTexturePoolSize;
254        unsigned int                    _maxVBOPoolSize;
255        unsigned int                    _maxFBOPoolSize;
[235]256};
257
258}
259
260# endif
Note: See TracBrowser for help on using the browser.