OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DisplaySettings.h
Go to the documentation of this file.
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 #include <osg/Matrixd>
19 #include <osg/ref_ptr>
20 
21 #include <string>
22 #include <vector>
23 
24 namespace osg {
25 
26 // forward declare
27 class ArgumentParser;
28 class ApplicationUsage;
29 
33 {
34 
35  public:
36 
38  static ref_ptr<DisplaySettings>& instance();
39 
41  Referenced(true)
42  {
43  setDefaults();
44  readEnvironmentalVariables();
45  }
46 
48  Referenced(true)
49  {
50  setDefaults();
51  readEnvironmentalVariables();
52  readCommandLine(arguments);
53  }
54 
56 
57 
58  DisplaySettings& operator = (const DisplaySettings& vs);
59 
60  void setDisplaySettings(const DisplaySettings& vs);
61 
62  void merge(const DisplaySettings& vs);
63 
64  void setDefaults();
65 
67  void readEnvironmentalVariables();
68 
70  void readCommandLine(ArgumentParser& arguments);
71 
72 
74  {
78  HEAD_MOUNTED_DISPLAY
79  };
80 
81  void setDisplayType(DisplayType type) { _displayType = type; }
82 
83  DisplayType getDisplayType() const { return _displayType; }
84 
85 
86  void setStereo(bool on) { _stereo = on; }
87  bool getStereo() const { return _stereo; }
88 
90  {
99  CHECKERBOARD
100  };
101 
102  void setStereoMode(StereoMode mode) { _stereoMode = mode; }
103  StereoMode getStereoMode() const { return _stereoMode; }
104 
105  void setEyeSeparation(float eyeSeparation) { _eyeSeparation = eyeSeparation; }
106  float getEyeSeparation() const { return _eyeSeparation; }
107 
109  {
111  LEFT_EYE_RIGHT_VIEWPORT
112  };
113 
114  void setSplitStereoHorizontalEyeMapping(SplitStereoHorizontalEyeMapping m) { _splitStereoHorizontalEyeMapping = m; }
115  SplitStereoHorizontalEyeMapping getSplitStereoHorizontalEyeMapping() const { return _splitStereoHorizontalEyeMapping; }
116 
117  void setSplitStereoHorizontalSeparation(int s) { _splitStereoHorizontalSeparation = s; }
118  int getSplitStereoHorizontalSeparation() const { return _splitStereoHorizontalSeparation; }
119 
121  {
123  LEFT_EYE_BOTTOM_VIEWPORT
124  };
125 
126  void setSplitStereoVerticalEyeMapping(SplitStereoVerticalEyeMapping m) { _splitStereoVerticalEyeMapping = m; }
127  SplitStereoVerticalEyeMapping getSplitStereoVerticalEyeMapping() const { return _splitStereoVerticalEyeMapping; }
128 
129  void setSplitStereoVerticalSeparation(int s) { _splitStereoVerticalSeparation = s; }
130  int getSplitStereoVerticalSeparation() const { return _splitStereoVerticalSeparation; }
131 
132  void setSplitStereoAutoAdjustAspectRatio(bool flag) { _splitStereoAutoAdjustAspectRatio=flag; }
133  bool getSplitStereoAutoAdjustAspectRatio() const { return _splitStereoAutoAdjustAspectRatio; }
134 
135 
136  void setScreenWidth(float width) { _screenWidth = width; }
137  float getScreenWidth() const { return _screenWidth; }
138 
139  void setScreenHeight(float height) { _screenHeight = height; }
140  float getScreenHeight() const { return _screenHeight; }
141 
142  void setScreenDistance(float distance) { _screenDistance = distance; }
143  float getScreenDistance() const { return _screenDistance; }
144 
145 
146 
147  void setDoubleBuffer(bool flag) { _doubleBuffer = flag; }
148  bool getDoubleBuffer() const { return _doubleBuffer; }
149 
150 
151  void setRGB(bool flag) { _RGB = flag; }
152  bool getRGB() const { return _RGB; }
153 
154 
155  void setDepthBuffer(bool flag) { _depthBuffer = flag; }
156  bool getDepthBuffer() const { return _depthBuffer; }
157 
158 
159  void setMinimumNumAlphaBits(unsigned int bits) { _minimumNumberAlphaBits = bits; }
160  unsigned int getMinimumNumAlphaBits() const { return _minimumNumberAlphaBits; }
161  bool getAlphaBuffer() const { return _minimumNumberAlphaBits!=0; }
162 
163  void setMinimumNumStencilBits(unsigned int bits) { _minimumNumberStencilBits = bits; }
164  unsigned int getMinimumNumStencilBits() const { return _minimumNumberStencilBits; }
165  bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; }
166 
167  void setMinimumNumAccumBits(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha);
168  unsigned int getMinimumNumAccumRedBits() const { return _minimumNumberAccumRedBits; }
169  unsigned int getMinimumNumAccumGreenBits() const { return _minimumNumberAccumGreenBits; }
170  unsigned int getMinimumNumAccumBlueBits() const { return _minimumNumberAccumBlueBits; }
171  unsigned int getMinimumNumAccumAlphaBits() const { return _minimumNumberAccumAlphaBits; }
172  bool getAccumBuffer() const { return (_minimumNumberAccumRedBits+_minimumNumberAccumGreenBits+_minimumNumberAccumBlueBits+_minimumNumberAccumAlphaBits)!=0; }
173 
174 
175  void setMaxNumberOfGraphicsContexts(unsigned int num);
176  unsigned int getMaxNumberOfGraphicsContexts() const;
177 
178  void setNumMultiSamples(unsigned int samples) { _numMultiSamples = samples; }
179  unsigned int getNumMultiSamples() const { return _numMultiSamples; }
180  bool getMultiSamples() const { return _numMultiSamples!=0; }
181 
182  void setCompileContextsHint(bool useCompileContexts) { _compileContextsHint = useCompileContexts; }
183  bool getCompileContextsHint() const { return _compileContextsHint; }
184 
185  void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
186  bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
187 
188 
189  void setUseSceneViewForStereoHint(bool hint) { _useSceneViewForStereoHint = hint; }
190  bool getUseSceneViewForStereoHint() const { return _useSceneViewForStereoHint; }
191 
192 
194  void setNumOfDatabaseThreadsHint(unsigned int numThreads) { _numDatabaseThreadsHint = numThreads; }
195 
197  unsigned int getNumOfDatabaseThreadsHint() const { return _numDatabaseThreadsHint; }
198 
200  void setNumOfHttpDatabaseThreadsHint(unsigned int numThreads) { _numHttpDatabaseThreadsHint = numThreads; }
201 
203  unsigned int getNumOfHttpDatabaseThreadsHint() const { return _numHttpDatabaseThreadsHint; }
204 
205  void setApplication(const std::string& application) { _application = application; }
206  const std::string& getApplication() { return _application; }
207 
208 
209  void setMaxTexturePoolSize(unsigned int size) { _maxTexturePoolSize = size; }
210  unsigned int getMaxTexturePoolSize() const { return _maxTexturePoolSize; }
211 
212  void setMaxBufferObjectPoolSize(unsigned int size) { _maxBufferObjectPoolSize = size; }
213  unsigned int getMaxBufferObjectPoolSize() const { return _maxBufferObjectPoolSize; }
214 
224  {
225  IMPLICIT_DEPTH_BUFFER_ATTACHMENT = (1 << 0),
226  IMPLICIT_STENCIL_BUFFER_ATTACHMENT = (1 << 1),
227  IMPLICIT_COLOR_BUFFER_ATTACHMENT = (1 << 2),
228  DEFAULT_IMPLICIT_BUFFER_ATTACHMENT = IMPLICIT_COLOR_BUFFER_ATTACHMENT | IMPLICIT_DEPTH_BUFFER_ATTACHMENT
229  };
230 
232 
233  void setImplicitBufferAttachmentMask(ImplicitBufferAttachmentMask renderMask = DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT, ImplicitBufferAttachmentMask resolveMask = DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT )
234  {
235  _implicitBufferAttachmentRenderMask = renderMask;
236  _implicitBufferAttachmentResolveMask = resolveMask;
237  }
238 
239  void setImplicitBufferAttachmentRenderMask(ImplicitBufferAttachmentMask implicitBufferAttachmentRenderMask)
240  {
241  _implicitBufferAttachmentRenderMask = implicitBufferAttachmentRenderMask;
242  }
243 
244  void setImplicitBufferAttachmentResolveMask(ImplicitBufferAttachmentMask implicitBufferAttachmentResolveMask)
245  {
246  _implicitBufferAttachmentResolveMask = implicitBufferAttachmentResolveMask;
247  }
248 
250  ImplicitBufferAttachmentMask getImplicitBufferAttachmentRenderMask() const { return _implicitBufferAttachmentRenderMask; }
251 
253  ImplicitBufferAttachmentMask getImplicitBufferAttachmentResolveMask() const { return _implicitBufferAttachmentResolveMask;}
254 
256  {
257  SWAP_DEFAULT, // Leave swap method at default returned by choose Pixel Format.
258  SWAP_EXCHANGE, // Flip front / back buffer.
259  SWAP_COPY, // Copy back to front buffer.
260  SWAP_UNDEFINED // Move back to front buffer leaving contents of back buffer undefined.
261  };
262 
264  void setSwapMethod( SwapMethod swapMethod ) { _swapMethod = swapMethod; }
265 
267  SwapMethod getSwapMethod( void ) { return _swapMethod; }
268 
269 
271  void setSyncSwapBuffers(unsigned int numFrames=0) { _syncSwapBuffers = numFrames; }
272 
274  unsigned int getSyncSwapBuffers() const { return _syncSwapBuffers; }
275 
276 
277 
279  void setGLContextVersion(const std::string& version) { _glContextVersion = version; }
280 
282  const std::string getGLContextVersion() const { return _glContextVersion; }
283 
285  void setGLContextFlags(unsigned int flags) { _glContextFlags = flags; }
286 
288  unsigned int getGLContextFlags() const { return _glContextFlags; }
289 
291  void setGLContextProfileMask(unsigned int mask) { _glContextProfileMask = mask; }
292 
294  unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
295 
297  void setNvOptimusEnablement(int value);
299  int getNvOptimusEnablement() const;
300 
301 
302  void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
303  bool getKeystoneHint() const { return _keystoneHint; }
304 
305  typedef std::vector<std::string> FileNames;
306  void setKeystoneFileNames(const FileNames& filenames) { _keystoneFileNames = filenames; }
307  FileNames& getKeystoneFileNames() { return _keystoneFileNames; }
308  const FileNames& getKeystoneFileNames() const { return _keystoneFileNames; }
309 
310  typedef std::vector< osg::ref_ptr<osg::Object> > Objects;
311  void setKeystones(const Objects& objects) { _keystones = objects; }
312  Objects& getKeystones() { return _keystones; }
313  const Objects& getKeystones() const { return _keystones; }
314 
318  MENUBAR_FORCE_SHOW
319  };
320 
321  OSXMenubarBehavior getOSXMenubarBehavior() const { return _OSXMenubarBehavior; }
322  void setOSXMenubarBehavior(OSXMenubarBehavior hint) { _OSXMenubarBehavior = hint; }
323 
325  virtual osg::Matrixd computeLeftEyeProjectionImplementation(const osg::Matrixd& projection) const;
326 
328  virtual osg::Matrixd computeLeftEyeViewImplementation(const osg::Matrixd& view, double eyeSeperationScale=1.0) const;
329 
331  virtual osg::Matrixd computeRightEyeProjectionImplementation(const osg::Matrixd& projection) const;
332 
334  virtual osg::Matrixd computeRightEyeViewImplementation(const osg::Matrixd& view, double eyeSeperationScale=1.0) const;
335 
336  protected:
337 
338  virtual ~DisplaySettings();
339 
340 
342  bool _stereo;
348 
354 
356  bool _RGB;
364 
366 
367  unsigned int _numMultiSamples;
368 
372 
375 
376  std::string _application;
377 
378  unsigned int _maxTexturePoolSize;
380 
381  ImplicitBufferAttachmentMask _implicitBufferAttachmentRenderMask;
382  ImplicitBufferAttachmentMask _implicitBufferAttachmentResolveMask;
383 
384  std::string _glContextVersion;
385  unsigned int _glContextFlags;
386  unsigned int _glContextProfileMask;
387 
389  unsigned int _syncSwapBuffers;
390 
393  Objects _keystones;
394 
396 
397 };
398 
399 }
400 
401 # endif
unsigned int _minimumNumberAccumRedBits
int getSplitStereoVerticalSeparation() const
void setGLContextVersion(const std::string &version)
#define OSG_EXPORT
Definition: Export.h:43
unsigned int getMinimumNumAccumBlueBits() const
void setImplicitBufferAttachmentRenderMask(ImplicitBufferAttachmentMask implicitBufferAttachmentRenderMask)
unsigned int getMinimumNumAccumAlphaBits() const
unsigned int _maxBufferObjectPoolSize
ImplicitBufferAttachmentMask _implicitBufferAttachmentResolveMask
unsigned int _numHttpDatabaseThreadsHint
float getScreenHeight() const
OSXMenubarBehavior getOSXMenubarBehavior() const
void setDisplayType(DisplayType type)
void setCompileContextsHint(bool useCompileContexts)
bool getStereo() const
void setMinimumNumAlphaBits(unsigned int bits)
unsigned int _numDatabaseThreadsHint
float getScreenWidth() const
void setSplitStereoVerticalEyeMapping(SplitStereoVerticalEyeMapping m)
unsigned int getGLContextProfileMask() const
std::vector< std::string > FileNames
unsigned int _syncSwapBuffers
StereoMode getStereoMode() const
const FileNames & getKeystoneFileNames() const
bool getUseSceneViewForStereoHint() const
void setDoubleBuffer(bool flag)
unsigned int _minimumNumberAlphaBits
void setMaxTexturePoolSize(unsigned int size)
unsigned int _minimumNumberStencilBits
ImplicitBufferAttachmentMask getImplicitBufferAttachmentRenderMask() const
bool getAccumBuffer() const
void readCommandLine(osg::ArgumentParser &parser)
Definition: Registry.h:645
void setRGB(bool flag)
FileNames & getKeystoneFileNames()
void setSplitStereoVerticalSeparation(int s)
const std::string & getApplication()
void setNumMultiSamples(unsigned int samples)
void setApplication(const std::string &application)
void setGLContextProfileMask(unsigned int mask)
SplitStereoHorizontalEyeMapping _splitStereoHorizontalEyeMapping
void setDepthBuffer(bool flag)
void setNumOfDatabaseThreadsHint(unsigned int numThreads)
bool getAlphaBuffer() const
unsigned int getMinimumNumStencilBits() const
void setMinimumNumStencilBits(unsigned int bits)
void setMaxBufferObjectPoolSize(unsigned int size)
unsigned int _minimumNumberAccumGreenBits
unsigned int getNumOfHttpDatabaseThreadsHint() const
void setScreenHeight(float height)
std::string _glContextVersion
void setImplicitBufferAttachmentResolveMask(ImplicitBufferAttachmentMask implicitBufferAttachmentResolveMask)
bool getMultiSamples() const
void setKeystoneHint(bool enabled)
void setSwapMethod(SwapMethod swapMethod)
SwapMethod getSwapMethod(void)
void setStereoMode(StereoMode mode)
GLint GLenum GLsizei width
Definition: GLU.h:71
unsigned int _glContextFlags
void setScreenDistance(float distance)
ImplicitBufferAttachmentMask _implicitBufferAttachmentRenderMask
const std::string getGLContextVersion() const
void setSyncSwapBuffers(unsigned int numFrames=0)
unsigned int getMinimumNumAlphaBits() const
ImplicitBufferAttachmentMask getImplicitBufferAttachmentResolveMask() const
DisplayType getDisplayType() const
unsigned int _minimumNumberAccumBlueBits
DisplaySettings(ArgumentParser &arguments)
SplitStereoVerticalEyeMapping getSplitStereoVerticalEyeMapping() const
unsigned int getNumOfDatabaseThreadsHint() const
bool getDepthBuffer() const
OSXMenubarBehavior _OSXMenubarBehavior
bool getDoubleBuffer() const
unsigned int getGLContextFlags() const
unsigned int _numMultiSamples
bool getStencilBuffer() const
void setSplitStereoHorizontalEyeMapping(SplitStereoHorizontalEyeMapping m)
std::vector< osg::ref_ptr< osg::Object > > Objects
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: GLU.h:71
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
void setNumOfHttpDatabaseThreadsHint(unsigned int numThreads)
bool getCompileContextsHint() const
unsigned int _maxTexturePoolSize
int getSplitStereoHorizontalSeparation() const
void setKeystones(const Objects &objects)
void setStereo(bool on)
unsigned int getMaxBufferObjectPoolSize() const
SplitStereoHorizontalEyeMapping getSplitStereoHorizontalEyeMapping() const
unsigned int getMinimumNumAccumGreenBits() const
unsigned int getNumMultiSamples() const
bool getSplitStereoAutoAdjustAspectRatio() const
unsigned int _minimumNumberAccumAlphaBits
float getScreenDistance() const
bool getKeystoneHint() const
unsigned int _maxNumOfGraphicsContexts
Definition: AlphaFunc.h:19
void setSplitStereoAutoAdjustAspectRatio(bool flag)
void setSerializeDrawDispatch(bool serializeDrawDispatch)
unsigned int getMinimumNumAccumRedBits() const
float getEyeSeparation() const
unsigned int getMaxTexturePoolSize() const
const Objects & getKeystones() const
void setSplitStereoHorizontalSeparation(int s)
void setUseSceneViewForStereoHint(bool hint)
void setScreenWidth(float width)
SplitStereoVerticalEyeMapping _splitStereoVerticalEyeMapping
unsigned int getSyncSwapBuffers() const
bool getSerializeDrawDispatch() const
void setKeystoneFileNames(const FileNames &filenames)
void setEyeSeparation(float eyeSeparation)
void setOSXMenubarBehavior(OSXMenubarBehavior hint)
unsigned int _glContextProfileMask
void setGLContextFlags(unsigned int flags)
void setImplicitBufferAttachmentMask(ImplicitBufferAttachmentMask renderMask=DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT, ImplicitBufferAttachmentMask resolveMask=DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT)