2006-07-18 23:21:48 +08:00
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2003-01-22 00:45:36 +08:00
*
* This library is open source and may be redistributed and / or modified under
* the terms of the OpenSceneGraph Public License ( OSGPL ) version 0.0 or
* ( at your option ) any later version . The full license is in LICENSE file
* included with this distribution , and on the openscenegraph . org website .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* OpenSceneGraph Public License for more details .
*/
2001-12-22 06:48:19 +08:00
# include <osg/DisplaySettings>
2003-02-19 05:10:42 +08:00
# include <osg/ArgumentParser>
2003-02-19 00:36:42 +08:00
# include <osg/ApplicationUsage>
2006-07-26 23:29:26 +08:00
# include <osg/Notify>
2003-01-10 17:25:42 +08:00
# include <osg/ref_ptr>
2001-12-19 08:38:23 +08:00
# include <algorithm>
2007-12-10 18:16:13 +08:00
# include <string.h>
2001-12-19 08:38:23 +08:00
using namespace osg ;
2002-02-23 01:12:10 +08:00
using namespace std ;
2002-02-28 08:11:31 +08:00
DisplaySettings * DisplaySettings : : instance ( )
{
2003-01-10 17:25:42 +08:00
static ref_ptr < DisplaySettings > s_displaySettings = new DisplaySettings ;
2002-02-28 08:11:31 +08:00
return s_displaySettings . get ( ) ;
}
2007-08-22 17:42:27 +08:00
DisplaySettings : : DisplaySettings ( const DisplaySettings & vs ) : Referenced ( true )
2001-12-19 08:38:23 +08:00
{
2004-05-05 17:16:12 +08:00
setDisplaySettings ( vs ) ;
2001-12-19 08:38:23 +08:00
}
2001-12-22 06:48:19 +08:00
DisplaySettings : : ~ DisplaySettings ( )
2001-12-19 08:38:23 +08:00
{
}
2002-02-28 08:11:31 +08:00
DisplaySettings & DisplaySettings : : operator = ( const DisplaySettings & vs )
2001-12-19 08:38:23 +08:00
{
if ( this = = & vs ) return * this ;
2004-05-05 17:16:12 +08:00
setDisplaySettings ( vs ) ;
2001-12-19 08:38:23 +08:00
return * this ;
}
2004-05-05 17:16:12 +08:00
void DisplaySettings : : setDisplaySettings ( const DisplaySettings & vs )
2001-12-19 08:38:23 +08:00
{
2003-10-01 23:56:52 +08:00
_displayType = vs . _displayType ;
2005-05-08 23:24:26 +08:00
_stereo = vs . _stereo ;
2001-12-19 08:38:23 +08:00
_stereoMode = vs . _stereoMode ;
2002-08-29 11:22:27 +08:00
_eyeSeparation = vs . _eyeSeparation ;
2003-11-05 00:38:10 +08:00
_screenWidth = vs . _screenWidth ;
2001-12-22 06:48:19 +08:00
_screenHeight = vs . _screenHeight ;
2003-11-05 00:38:10 +08:00
_screenDistance = vs . _screenDistance ;
2001-12-19 08:38:23 +08:00
2002-04-15 06:21:59 +08:00
_splitStereoHorizontalEyeMapping = vs . _splitStereoHorizontalEyeMapping ;
2002-08-29 11:22:27 +08:00
_splitStereoHorizontalSeparation = vs . _splitStereoHorizontalSeparation ;
2002-04-15 06:21:59 +08:00
_splitStereoVerticalEyeMapping = vs . _splitStereoVerticalEyeMapping ;
2002-08-29 11:22:27 +08:00
_splitStereoVerticalSeparation = vs . _splitStereoVerticalSeparation ;
2003-05-27 19:03:49 +08:00
_splitStereoAutoAdjustAspectRatio = vs . _splitStereoAutoAdjustAspectRatio ;
2002-04-15 06:21:59 +08:00
2001-12-19 08:38:23 +08:00
_doubleBuffer = vs . _doubleBuffer ;
_RGB = vs . _RGB ;
_depthBuffer = vs . _depthBuffer ;
_minimumNumberAlphaBits = vs . _minimumNumberAlphaBits ;
_minimumNumberStencilBits = vs . _minimumNumberStencilBits ;
2002-02-28 08:11:31 +08:00
_maxNumOfGraphicsContexts = vs . _maxNumOfGraphicsContexts ;
2006-03-14 05:29:17 +08:00
_numMultiSamples = vs . _numMultiSamples ;
2007-08-11 22:49:14 +08:00
_compileContextsHint = vs . _compileContextsHint ;
2007-08-23 19:00:12 +08:00
_serializeDrawDispatch = vs . _serializeDrawDispatch ;
2008-10-27 06:22:38 +08:00
_numDatabaseThreadsHint = vs . _numDatabaseThreadsHint ;
_numHttpDatabaseThreadsHint = vs . _numHttpDatabaseThreadsHint ;
2008-11-20 20:03:21 +08:00
_application = vs . _application ;
2001-12-19 08:38:23 +08:00
}
2001-12-22 06:48:19 +08:00
void DisplaySettings : : merge ( const DisplaySettings & vs )
2001-12-19 08:38:23 +08:00
{
if ( _stereo | | vs . _stereo ) _stereo = true ;
// need to think what to do about merging the stereo mode.
if ( _doubleBuffer | | vs . _doubleBuffer ) _doubleBuffer = true ;
if ( _RGB | | vs . _RGB ) _RGB = true ;
if ( _depthBuffer | | vs . _depthBuffer ) _depthBuffer = true ;
if ( vs . _minimumNumberAlphaBits > _minimumNumberAlphaBits ) _minimumNumberAlphaBits = vs . _minimumNumberAlphaBits ;
if ( vs . _minimumNumberStencilBits > _minimumNumberStencilBits ) _minimumNumberStencilBits = vs . _minimumNumberStencilBits ;
2006-03-14 05:29:17 +08:00
if ( vs . _numMultiSamples > _numMultiSamples ) _numMultiSamples = vs . _numMultiSamples ;
2007-08-11 22:49:14 +08:00
if ( vs . _compileContextsHint ) _compileContextsHint = vs . _compileContextsHint ;
2007-08-23 19:00:12 +08:00
if ( vs . _serializeDrawDispatch ) _serializeDrawDispatch = vs . _serializeDrawDispatch ;
2008-10-27 06:22:38 +08:00
if ( vs . _numDatabaseThreadsHint > _numDatabaseThreadsHint ) _numDatabaseThreadsHint = vs . _numDatabaseThreadsHint ;
if ( vs . _numHttpDatabaseThreadsHint > _numHttpDatabaseThreadsHint ) _numHttpDatabaseThreadsHint = vs . _numHttpDatabaseThreadsHint ;
2008-11-20 20:03:21 +08:00
if ( _application . empty ( ) ) _application = vs . _application ;
2001-12-19 08:38:23 +08:00
}
2001-12-22 06:48:19 +08:00
void DisplaySettings : : setDefaults ( )
2001-12-19 08:38:23 +08:00
{
2003-10-01 23:56:52 +08:00
_displayType = MONITOR ;
2001-12-19 08:38:23 +08:00
_stereo = false ;
_stereoMode = ANAGLYPHIC ;
2002-08-29 11:22:27 +08:00
_eyeSeparation = 0.05f ;
2003-11-05 00:38:10 +08:00
_screenWidth = 0.325f ;
2001-12-22 06:48:19 +08:00
_screenHeight = 0.26f ;
2003-11-05 00:38:10 +08:00
_screenDistance = 0.5f ;
2001-12-19 08:38:23 +08:00
2002-04-15 06:21:59 +08:00
_splitStereoHorizontalEyeMapping = LEFT_EYE_LEFT_VIEWPORT ;
2003-05-26 23:00:38 +08:00
_splitStereoHorizontalSeparation = 0 ;
2002-04-15 06:21:59 +08:00
_splitStereoVerticalEyeMapping = LEFT_EYE_TOP_VIEWPORT ;
2003-05-26 23:00:38 +08:00
_splitStereoVerticalSeparation = 0 ;
2002-04-15 06:21:59 +08:00
2003-05-27 19:03:49 +08:00
_splitStereoAutoAdjustAspectRatio = true ;
2001-12-19 08:38:23 +08:00
_doubleBuffer = true ;
_RGB = true ;
_depthBuffer = true ;
_minimumNumberAlphaBits = 0 ;
_minimumNumberStencilBits = 0 ;
2005-11-03 03:15:18 +08:00
_minimumNumberAccumRedBits = 0 ;
_minimumNumberAccumGreenBits = 0 ;
_minimumNumberAccumBlueBits = 0 ;
_minimumNumberAccumAlphaBits = 0 ;
2002-02-28 08:11:31 +08:00
2006-07-26 23:29:26 +08:00
_maxNumOfGraphicsContexts = 32 ;
2006-03-14 05:29:17 +08:00
_numMultiSamples = 0 ;
# ifdef __sgi
// switch on anti-aliasing by default, just in case we have an Onyx :-)
_numMultiSamples = 4 ;
# endif
2007-08-11 22:49:14 +08:00
_compileContextsHint = false ;
2007-08-23 19:00:12 +08:00
_serializeDrawDispatch = true ;
2008-10-27 06:22:38 +08:00
_numDatabaseThreadsHint = 2 ;
_numHttpDatabaseThreadsHint = 1 ;
2001-12-19 08:38:23 +08:00
}
2006-07-26 23:29:26 +08:00
void DisplaySettings : : setMaxNumberOfGraphicsContexts ( unsigned int num )
{
_maxNumOfGraphicsContexts = num ;
}
unsigned int DisplaySettings : : getMaxNumberOfGraphicsContexts ( ) const
{
// osg::notify(osg::NOTICE)<<"getMaxNumberOfGraphicsContexts()="<<_maxNumOfGraphicsContexts<<std::endl;
return _maxNumOfGraphicsContexts ;
}
2005-11-03 03:15:18 +08:00
void DisplaySettings : : setMinimumNumAccumBits ( unsigned int red , unsigned int green , unsigned int blue , unsigned int alpha )
{
_minimumNumberAccumRedBits = red ;
_minimumNumberAccumGreenBits = green ;
_minimumNumberAccumBlueBits = blue ;
_minimumNumberAccumAlphaBits = alpha ;
}
2003-10-01 23:56:52 +08:00
static ApplicationUsageProxy DisplaySetting_e0 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_DISPLAY_TYPE <type> " , " MONITOR | POWERWALL | REALITY_CENTER | HEAD_MOUNTED_DISPLAY " ) ;
2005-10-25 23:43:04 +08:00
static ApplicationUsageProxy DisplaySetting_e1 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_STEREO_MODE <mode> " , " QUAD_BUFFER | ANAGLYPHIC | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE | VERTICAL_INTERLACE | HORIZONTAL_INTERLACE " ) ;
2003-10-01 23:56:52 +08:00
static ApplicationUsageProxy DisplaySetting_e2 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_STEREO <mode> " , " OFF | ON " ) ;
static ApplicationUsageProxy DisplaySetting_e3 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_EYE_SEPARATION <float> " , " physical distance between eyes " ) ;
static ApplicationUsageProxy DisplaySetting_e4 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SCREEN_DISTANCE <float> " , " physical distance between eyes and screen " ) ;
static ApplicationUsageProxy DisplaySetting_e5 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SCREEN_HEIGHT <float> " , " physical screen height " ) ;
2004-11-27 05:35:36 +08:00
static ApplicationUsageProxy DisplaySetting_e6 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SCREEN_WIDTH <float> " , " physical screen width " ) ;
static ApplicationUsageProxy DisplaySetting_e7 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING <mode> " , " LEFT_EYE_LEFT_VIEWPORT | LEFT_EYE_RIGHT_VIEWPORT " ) ;
static ApplicationUsageProxy DisplaySetting_e8 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SPLIT_STEREO_HORIZONTAL_SEPARATION <float> " , " number of pixels between viewports " ) ;
static ApplicationUsageProxy DisplaySetting_e9 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SPLIT_STEREO_VERTICAL_EYE_MAPPING <mode> " , " LEFT_EYE_TOP_VIEWPORT | LEFT_EYE_BOTTOM_VIEWPORT " ) ;
static ApplicationUsageProxy DisplaySetting_e10 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SPLIT_STEREO_AUTO_ADJUST_ASPECT_RATIO <mode> " , " OFF | ON Default to ON to compenstate for the compression of the aspect ratio when viewing in split screen stereo. Note, if you are setting fovx and fovy explicityly OFF should be used. " ) ;
static ApplicationUsageProxy DisplaySetting_e11 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SPLIT_STEREO_VERTICAL_SEPARATION <float> " , " number of pixels between viewports " ) ;
static ApplicationUsageProxy DisplaySetting_e12 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_MAX_NUMBER_OF_GRAPHICS_CONTEXTS <int> " , " maximum number of graphics contexts to be used with applications. " ) ;
2009-02-20 19:53:49 +08:00
static ApplicationUsageProxy DisplaySetting_e13 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_COMPILE_CONTEXTS <mode> " , " OFF | ON Enable/disable the use a backgrouind compile contexts and threads. " ) ;
2007-08-23 19:00:12 +08:00
static ApplicationUsageProxy DisplaySetting_e14 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_SERIALIZE_DRAW_DISPATCH <mode> " , " OFF | ON Enable/disable the use a muetx to serialize the draw dispatch when there are multiple graphics threads. " ) ;
2008-10-27 06:22:38 +08:00
static ApplicationUsageProxy DisplaySetting_e15 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_NUM_DATABASE_THREADS <int> " , " Set the hint for the total number of threads to set up in the DatabasePager. " ) ;
static ApplicationUsageProxy DisplaySetting_e16 ( ApplicationUsage : : ENVIRONMENTAL_VARIABLE , " OSG_NUM_HTTP_DATABASE_THREADS <int> " , " Set the hint for the total number of threads dedicated to http requests to set up in the DatabasePager. " ) ;
2007-08-23 19:00:12 +08:00
2001-12-22 06:48:19 +08:00
void DisplaySettings : : readEnvironmentalVariables ( )
2001-12-19 08:38:23 +08:00
{
2005-05-31 13:47:40 +08:00
const char * ptr = 0 ;
2003-10-01 23:56:52 +08:00
if ( ( ptr = getenv ( " OSG_DISPLAY_TYPE " ) ) ! = 0 )
{
if ( strcmp ( ptr , " MONITOR " ) = = 0 )
{
_displayType = MONITOR ;
}
else
if ( strcmp ( ptr , " POWERWALL " ) = = 0 )
{
_displayType = POWERWALL ;
}
else
if ( strcmp ( ptr , " REALITY_CENTER " ) = = 0 )
{
_displayType = REALITY_CENTER ;
}
else
if ( strcmp ( ptr , " HEAD_MOUNTED_DISPLAY " ) = = 0 )
{
_displayType = HEAD_MOUNTED_DISPLAY ;
}
}
2002-01-30 23:02:56 +08:00
if ( ( ptr = getenv ( " OSG_STEREO_MODE " ) ) ! = 0 )
2001-12-19 08:38:23 +08:00
{
if ( strcmp ( ptr , " QUAD_BUFFER " ) = = 0 )
{
_stereoMode = QUAD_BUFFER ;
}
2005-10-25 23:43:04 +08:00
else if ( strcmp ( ptr , " ANAGLYPHIC " ) = = 0 )
2001-12-19 08:38:23 +08:00
{
_stereoMode = ANAGLYPHIC ;
}
2005-10-25 23:43:04 +08:00
else if ( strcmp ( ptr , " HORIZONTAL_SPLIT " ) = = 0 )
2001-12-19 08:38:23 +08:00
{
_stereoMode = HORIZONTAL_SPLIT ;
}
2005-10-25 23:43:04 +08:00
else if ( strcmp ( ptr , " VERTICAL_SPLIT " ) = = 0 )
2001-12-19 08:38:23 +08:00
{
_stereoMode = VERTICAL_SPLIT ;
}
2005-10-25 23:43:04 +08:00
else if ( strcmp ( ptr , " LEFT_EYE " ) = = 0 )
2002-11-12 18:22:38 +08:00
{
_stereoMode = LEFT_EYE ;
}
2005-10-25 23:43:04 +08:00
else if ( strcmp ( ptr , " RIGHT_EYE " ) = = 0 )
2002-11-12 18:22:38 +08:00
{
_stereoMode = RIGHT_EYE ;
}
2005-10-25 23:43:04 +08:00
else if ( strcmp ( ptr , " HORIZONTAL_INTERLACE " ) = = 0 )
{
_stereoMode = HORIZONTAL_INTERLACE ;
}
else if ( strcmp ( ptr , " VERTICAL_INTERLACE " ) = = 0 )
{
_stereoMode = VERTICAL_INTERLACE ;
}
2007-08-23 22:31:23 +08:00
else if ( strcmp ( ptr , " CHECKERBOARD " ) = = 0 )
{
_stereoMode = CHECKERBOARD ;
}
2001-12-19 08:38:23 +08:00
}
2002-01-30 23:02:56 +08:00
if ( ( ptr = getenv ( " OSG_STEREO " ) ) ! = 0 )
2001-12-19 08:38:23 +08:00
{
if ( strcmp ( ptr , " OFF " ) = = 0 )
{
_stereo = false ;
}
else
if ( strcmp ( ptr , " ON " ) = = 0 )
{
_stereo = true ;
}
}
2002-08-29 11:22:27 +08:00
if ( ( ptr = getenv ( " OSG_EYE_SEPARATION " ) ) ! = 0 )
2001-12-19 08:38:23 +08:00
{
2002-08-29 11:22:27 +08:00
_eyeSeparation = atof ( ptr ) ;
2001-12-19 08:38:23 +08:00
}
2001-12-19 18:29:18 +08:00
2003-11-05 00:38:10 +08:00
if ( ( ptr = getenv ( " OSG_SCREEN_WIDTH " ) ) ! = 0 )
2001-12-19 18:29:18 +08:00
{
2003-11-05 00:38:10 +08:00
_screenWidth = atof ( ptr ) ;
2001-12-19 18:29:18 +08:00
}
2001-12-22 06:48:19 +08:00
2002-01-30 23:02:56 +08:00
if ( ( ptr = getenv ( " OSG_SCREEN_HEIGHT " ) ) ! = 0 )
2001-12-22 06:48:19 +08:00
{
_screenHeight = atof ( ptr ) ;
}
2002-02-28 08:11:31 +08:00
2003-11-05 00:38:10 +08:00
if ( ( ptr = getenv ( " OSG_SCREEN_DISTANCE " ) ) ! = 0 )
{
_screenDistance = atof ( ptr ) ;
}
2002-04-15 06:21:59 +08:00
if ( ( ptr = getenv ( " OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING " ) ) ! = 0 )
{
if ( strcmp ( ptr , " LEFT_EYE_LEFT_VIEWPORT " ) = = 0 )
{
_splitStereoHorizontalEyeMapping = LEFT_EYE_LEFT_VIEWPORT ;
}
else
if ( strcmp ( ptr , " LEFT_EYE_RIGHT_VIEWPORT " ) = = 0 )
{
_splitStereoHorizontalEyeMapping = LEFT_EYE_RIGHT_VIEWPORT ;
}
}
2002-08-29 11:22:27 +08:00
if ( ( ptr = getenv ( " OSG_SPLIT_STEREO_HORIZONTAL_SEPARATION " ) ) ! = 0 )
2002-04-15 06:21:59 +08:00
{
2002-08-29 11:22:27 +08:00
_splitStereoHorizontalSeparation = atoi ( ptr ) ;
2002-04-15 06:21:59 +08:00
}
if ( ( ptr = getenv ( " OSG_SPLIT_STEREO_VERTICAL_EYE_MAPPING " ) ) ! = 0 )
{
if ( strcmp ( ptr , " LEFT_EYE_TOP_VIEWPORT " ) = = 0 )
{
_splitStereoVerticalEyeMapping = LEFT_EYE_TOP_VIEWPORT ;
}
else
if ( strcmp ( ptr , " LEFT_EYE_BOTTOM_VIEWPORT " ) = = 0 )
{
_splitStereoVerticalEyeMapping = LEFT_EYE_BOTTOM_VIEWPORT ;
}
}
2003-05-27 19:03:49 +08:00
if ( ( ptr = getenv ( " OSG_SPLIT_STEREO_AUTO_ADJUST_ASPECT_RATIO " ) ) ! = 0 )
{
if ( strcmp ( ptr , " OFF " ) = = 0 )
{
2003-11-12 23:03:05 +08:00
_splitStereoAutoAdjustAspectRatio = false ;
2003-05-27 19:03:49 +08:00
}
else
if ( strcmp ( ptr , " ON " ) = = 0 )
{
2003-11-12 23:03:05 +08:00
_splitStereoAutoAdjustAspectRatio = true ;
2003-05-27 19:03:49 +08:00
}
}
2002-04-15 06:21:59 +08:00
2002-08-29 11:22:27 +08:00
if ( ( ptr = getenv ( " OSG_SPLIT_STEREO_VERTICAL_SEPARATION " ) ) ! = 0 )
2002-04-15 06:21:59 +08:00
{
2002-08-29 11:22:27 +08:00
_splitStereoVerticalSeparation = atoi ( ptr ) ;
2002-04-15 06:21:59 +08:00
}
2002-02-28 08:11:31 +08:00
if ( ( ptr = getenv ( " OSG_MAX_NUMBER_OF_GRAPHICS_CONTEXTS " ) ) ! = 0 )
{
2002-03-24 05:30:32 +08:00
_maxNumOfGraphicsContexts = atoi ( ptr ) ;
2002-02-28 08:11:31 +08:00
}
2007-08-11 22:49:14 +08:00
if ( ( ptr = getenv ( " OSG_COMPIlE_CONTEXTS " ) ) ! = 0 )
{
if ( strcmp ( ptr , " OFF " ) = = 0 )
{
_compileContextsHint = false ;
}
else
if ( strcmp ( ptr , " ON " ) = = 0 )
{
_compileContextsHint = true ;
}
}
2007-08-23 19:00:12 +08:00
if ( ( ptr = getenv ( " OSG_SERIALIZE_DRAW_DISPATCH " ) ) ! = 0 )
{
if ( strcmp ( ptr , " OFF " ) = = 0 )
{
_serializeDrawDispatch = false ;
}
else
if ( strcmp ( ptr , " ON " ) = = 0 )
{
_serializeDrawDispatch = true ;
}
}
2008-10-27 06:22:38 +08:00
if ( ( ptr = getenv ( " OSG_NUM_DATABASE_THREADS " ) ) ! = 0 )
{
_numDatabaseThreadsHint = atoi ( ptr ) ;
}
if ( ( ptr = getenv ( " OSG_NUM_HTTP_DATABASE_THREADS " ) ) ! = 0 )
{
_numHttpDatabaseThreadsHint = atoi ( ptr ) ;
}
2001-12-19 08:38:23 +08:00
}
2003-02-19 05:58:40 +08:00
void DisplaySettings : : readCommandLine ( ArgumentParser & arguments )
2003-02-19 00:36:42 +08:00
{
2008-11-20 20:03:21 +08:00
if ( _application . empty ( ) ) _application = arguments [ 0 ] ;
2003-02-19 05:58:40 +08:00
// report the usage options.
if ( arguments . getApplicationUsage ( ) )
{
2003-10-01 23:56:52 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --display <type> " , " MONITOR | POWERWALL | REALITY_CENTER | HEAD_MOUNTED_DISPLAY " ) ;
2003-02-19 05:58:40 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --stereo " , " Use default stereo mode which is ANAGLYPHIC if not overriden by environmental variable " ) ;
2007-08-23 22:31:23 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --stereo <mode> " , " ANAGLYPHIC | QUAD_BUFFER | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE | HORIZONTAL_INTERLACE | VERTICAL_INTERLACE | CHECKERBOARD | ON | OFF " ) ;
2003-02-19 05:58:40 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --rgba " , " Request a RGBA color buffer visual " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --stencil " , " Request a stencil buffer visual " ) ;
2005-11-26 03:18:12 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --accum-rgb " , " Request a rgb accumulator buffer visual " ) ;
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --accum-rgba " , " Request a rgb accumulator buffer visual " ) ;
2006-03-14 05:29:17 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --samples <num> " , " Request a multisample visual " ) ;
2007-08-11 22:49:14 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --cc " , " Request use of compile contexts and threads " ) ;
2007-08-23 19:00:12 +08:00
arguments . getApplicationUsage ( ) - > addCommandLineOption ( " --serialize-draw <mode> " , " OFF | ON - set the serialization of draw dispatch " ) ;
2003-02-19 05:58:40 +08:00
}
2003-10-01 23:56:52 +08:00
std : : string str ;
while ( arguments . read ( " --display " , str ) )
{
if ( str = = " MONITOR " ) _displayType = MONITOR ;
else if ( str = = " POWERWALL " ) _displayType = POWERWALL ;
else if ( str = = " REALITY_CENTER " ) _displayType = REALITY_CENTER ;
else if ( str = = " HEAD_MOUNTED_DISPLAY " ) _displayType = HEAD_MOUNTED_DISPLAY ;
}
2003-02-19 05:58:40 +08:00
2003-02-19 00:36:42 +08:00
int pos ;
2008-11-05 19:56:44 +08:00
while ( ( pos = arguments . find ( " --stereo " ) ) > 0 )
2003-02-19 00:36:42 +08:00
{
2003-02-19 05:58:40 +08:00
if ( arguments . match ( pos + 1 , " ANAGLYPHIC " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = ANAGLYPHIC ; }
else if ( arguments . match ( pos + 1 , " QUAD_BUFFER " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = QUAD_BUFFER ; }
else if ( arguments . match ( pos + 1 , " HORIZONTAL_SPLIT " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = HORIZONTAL_SPLIT ; }
else if ( arguments . match ( pos + 1 , " VERTICAL_SPLIT " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = VERTICAL_SPLIT ; }
2005-10-25 23:49:48 +08:00
else if ( arguments . match ( pos + 1 , " HORIZONTAL_INTERLACE " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = HORIZONTAL_INTERLACE ; }
else if ( arguments . match ( pos + 1 , " VERTICAL_INTERLACE " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = VERTICAL_INTERLACE ; }
2007-08-23 22:31:23 +08:00
else if ( arguments . match ( pos + 1 , " CHECKERBOARD " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = CHECKERBOARD ; }
2003-02-19 05:58:40 +08:00
else if ( arguments . match ( pos + 1 , " LEFT_EYE " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = LEFT_EYE ; }
else if ( arguments . match ( pos + 1 , " RIGHT_EYE " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; _stereoMode = RIGHT_EYE ; }
else if ( arguments . match ( pos + 1 , " ON " ) ) { arguments . remove ( pos , 2 ) ; _stereo = true ; }
else if ( arguments . match ( pos + 1 , " OFF " ) ) { arguments . remove ( pos , 2 ) ; _stereo = false ; }
else { arguments . remove ( pos ) ; _stereo = true ; }
2003-02-19 00:36:42 +08:00
}
2003-02-19 05:58:40 +08:00
while ( arguments . read ( " --rgba " ) )
2003-02-19 00:36:42 +08:00
{
_RGB = true ;
_minimumNumberAlphaBits = 1 ;
}
2003-02-19 05:58:40 +08:00
while ( arguments . read ( " --stencil " ) )
2003-02-19 00:36:42 +08:00
{
_minimumNumberStencilBits = 1 ;
}
2005-11-03 03:15:18 +08:00
while ( arguments . read ( " --accum-rgb " ) )
{
setMinimumNumAccumBits ( 8 , 8 , 8 , 0 ) ;
}
while ( arguments . read ( " --accum-rgba " ) )
{
setMinimumNumAccumBits ( 8 , 8 , 8 , 8 ) ;
}
2006-03-14 05:29:17 +08:00
while ( arguments . read ( " --samples " , str ) )
{
_numMultiSamples = atoi ( str . c_str ( ) ) ;
}
2007-08-11 22:49:14 +08:00
while ( arguments . read ( " --cc " ) )
{
_compileContextsHint = true ;
}
2007-08-23 19:00:12 +08:00
while ( arguments . read ( " --serialize-draw " , str ) )
{
if ( str = = " ON " ) _serializeDrawDispatch = true ;
else if ( str = = " OFF " ) _serializeDrawDispatch = false ;
}
2008-10-27 06:22:38 +08:00
while ( arguments . read ( " --num-db-threads " , _numDatabaseThreadsHint ) ) { }
while ( arguments . read ( " --num-http-threads " , _numHttpDatabaseThreadsHint ) ) { }
2003-02-19 00:36:42 +08:00
}