| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include <osg/DisplaySettings> |
|---|
| 14 | #include <osg/ArgumentParser> |
|---|
| 15 | #include <osg/ApplicationUsage> |
|---|
| 16 | #include <osg/Math> |
|---|
| 17 | #include <osg/Notify> |
|---|
| 18 | #include <osg/ref_ptr> |
|---|
| 19 | |
|---|
| 20 | #include <algorithm> |
|---|
| 21 | #include <string.h> |
|---|
| 22 | |
|---|
| 23 | using namespace osg; |
|---|
| 24 | using namespace std; |
|---|
| 25 | |
|---|
| 26 | DisplaySettings* DisplaySettings::instance() |
|---|
| 27 | { |
|---|
| 28 | static ref_ptr<DisplaySettings> s_displaySettings = new DisplaySettings; |
|---|
| 29 | return s_displaySettings.get(); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | DisplaySettings::DisplaySettings(const DisplaySettings& vs):Referenced(true) |
|---|
| 33 | { |
|---|
| 34 | setDisplaySettings(vs); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | DisplaySettings::~DisplaySettings() |
|---|
| 38 | { |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | DisplaySettings& DisplaySettings::operator = (const DisplaySettings& vs) |
|---|
| 43 | { |
|---|
| 44 | if (this==&vs) return *this; |
|---|
| 45 | setDisplaySettings(vs); |
|---|
| 46 | return *this; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | void DisplaySettings::setDisplaySettings(const DisplaySettings& vs) |
|---|
| 50 | { |
|---|
| 51 | _displayType = vs._displayType; |
|---|
| 52 | _stereo = vs._stereo; |
|---|
| 53 | _stereoMode = vs._stereoMode; |
|---|
| 54 | _eyeSeparation = vs._eyeSeparation; |
|---|
| 55 | _screenWidth = vs._screenWidth; |
|---|
| 56 | _screenHeight = vs._screenHeight; |
|---|
| 57 | _screenDistance = vs._screenDistance; |
|---|
| 58 | |
|---|
| 59 | _splitStereoHorizontalEyeMapping = vs._splitStereoHorizontalEyeMapping; |
|---|
| 60 | _splitStereoHorizontalSeparation = vs._splitStereoHorizontalSeparation; |
|---|
| 61 | |
|---|
| 62 | _splitStereoVerticalEyeMapping = vs._splitStereoVerticalEyeMapping; |
|---|
| 63 | _splitStereoVerticalSeparation = vs._splitStereoVerticalSeparation; |
|---|
| 64 | |
|---|
| 65 | _splitStereoAutoAdjustAspectRatio = vs._splitStereoAutoAdjustAspectRatio; |
|---|
| 66 | |
|---|
| 67 | _doubleBuffer = vs._doubleBuffer; |
|---|
| 68 | _RGB = vs._RGB; |
|---|
| 69 | _depthBuffer = vs._depthBuffer; |
|---|
| 70 | _minimumNumberAlphaBits = vs._minimumNumberAlphaBits; |
|---|
| 71 | _minimumNumberStencilBits = vs._minimumNumberStencilBits; |
|---|
| 72 | |
|---|
| 73 | _maxNumOfGraphicsContexts = vs._maxNumOfGraphicsContexts; |
|---|
| 74 | _numMultiSamples = vs._numMultiSamples; |
|---|
| 75 | |
|---|
| 76 | _compileContextsHint = vs._compileContextsHint; |
|---|
| 77 | _serializeDrawDispatch = vs._serializeDrawDispatch; |
|---|
| 78 | |
|---|
| 79 | _numDatabaseThreadsHint = vs._numDatabaseThreadsHint; |
|---|
| 80 | _numHttpDatabaseThreadsHint = vs._numHttpDatabaseThreadsHint; |
|---|
| 81 | |
|---|
| 82 | _application = vs._application; |
|---|
| 83 | |
|---|
| 84 | _maxTexturePoolSize = vs._maxTexturePoolSize; |
|---|
| 85 | _maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | void DisplaySettings::merge(const DisplaySettings& vs) |
|---|
| 89 | { |
|---|
| 90 | if (_stereo || vs._stereo) _stereo = true; |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | if (_doubleBuffer || vs._doubleBuffer) _doubleBuffer = true; |
|---|
| 95 | if (_RGB || vs._RGB) _RGB = true; |
|---|
| 96 | if (_depthBuffer || vs._depthBuffer) _depthBuffer = true; |
|---|
| 97 | |
|---|
| 98 | if (vs._minimumNumberAlphaBits>_minimumNumberAlphaBits) _minimumNumberAlphaBits = vs._minimumNumberAlphaBits; |
|---|
| 99 | if (vs._minimumNumberStencilBits>_minimumNumberStencilBits) _minimumNumberStencilBits = vs._minimumNumberStencilBits; |
|---|
| 100 | if (vs._numMultiSamples>_numMultiSamples) _numMultiSamples = vs._numMultiSamples; |
|---|
| 101 | |
|---|
| 102 | if (vs._compileContextsHint) _compileContextsHint = vs._compileContextsHint; |
|---|
| 103 | if (vs._serializeDrawDispatch) _serializeDrawDispatch = vs._serializeDrawDispatch; |
|---|
| 104 | |
|---|
| 105 | if (vs._numDatabaseThreadsHint>_numDatabaseThreadsHint) _numDatabaseThreadsHint = vs._numDatabaseThreadsHint; |
|---|
| 106 | if (vs._numHttpDatabaseThreadsHint>_numHttpDatabaseThreadsHint) _numHttpDatabaseThreadsHint = vs._numHttpDatabaseThreadsHint; |
|---|
| 107 | |
|---|
| 108 | if (_application.empty()) _application = vs._application; |
|---|
| 109 | |
|---|
| 110 | if (vs._maxTexturePoolSize>_maxTexturePoolSize) _maxTexturePoolSize = vs._maxTexturePoolSize; |
|---|
| 111 | if (vs._maxBufferObjectPoolSize>_maxBufferObjectPoolSize) _maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | void DisplaySettings::setDefaults() |
|---|
| 115 | { |
|---|
| 116 | _displayType = MONITOR; |
|---|
| 117 | |
|---|
| 118 | _stereo = false; |
|---|
| 119 | _stereoMode = ANAGLYPHIC; |
|---|
| 120 | _eyeSeparation = 0.05f; |
|---|
| 121 | _screenWidth = 0.325f; |
|---|
| 122 | _screenHeight = 0.26f; |
|---|
| 123 | _screenDistance = 0.5f; |
|---|
| 124 | |
|---|
| 125 | _splitStereoHorizontalEyeMapping = LEFT_EYE_LEFT_VIEWPORT; |
|---|
| 126 | _splitStereoHorizontalSeparation = 0; |
|---|
| 127 | |
|---|
| 128 | _splitStereoVerticalEyeMapping = LEFT_EYE_TOP_VIEWPORT; |
|---|
| 129 | _splitStereoVerticalSeparation = 0; |
|---|
| 130 | |
|---|
| 131 | _splitStereoAutoAdjustAspectRatio = true; |
|---|
| 132 | |
|---|
| 133 | _doubleBuffer = true; |
|---|
| 134 | _RGB = true; |
|---|
| 135 | _depthBuffer = true; |
|---|
| 136 | _minimumNumberAlphaBits = 0; |
|---|
| 137 | _minimumNumberStencilBits = 0; |
|---|
| 138 | _minimumNumberAccumRedBits = 0; |
|---|
| 139 | _minimumNumberAccumGreenBits = 0; |
|---|
| 140 | _minimumNumberAccumBlueBits = 0; |
|---|
| 141 | _minimumNumberAccumAlphaBits = 0; |
|---|
| 142 | |
|---|
| 143 | _maxNumOfGraphicsContexts = 32; |
|---|
| 144 | _numMultiSamples = 0; |
|---|
| 145 | |
|---|
| 146 | #ifdef __sgi |
|---|
| 147 | |
|---|
| 148 | _numMultiSamples = 4; |
|---|
| 149 | #endif |
|---|
| 150 | |
|---|
| 151 | _compileContextsHint = false; |
|---|
| 152 | _serializeDrawDispatch = true; |
|---|
| 153 | |
|---|
| 154 | _numDatabaseThreadsHint = 2; |
|---|
| 155 | _numHttpDatabaseThreadsHint = 1; |
|---|
| 156 | |
|---|
| 157 | _maxTexturePoolSize = 0; |
|---|
| 158 | _maxBufferObjectPoolSize = 0; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num) |
|---|
| 162 | { |
|---|
| 163 | _maxNumOfGraphicsContexts = num; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | unsigned int DisplaySettings::getMaxNumberOfGraphicsContexts() const |
|---|
| 167 | { |
|---|
| 168 | |
|---|
| 169 | return _maxNumOfGraphicsContexts; |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | void DisplaySettings::setMinimumNumAccumBits(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) |
|---|
| 173 | { |
|---|
| 174 | _minimumNumberAccumRedBits = red; |
|---|
| 175 | _minimumNumberAccumGreenBits = green; |
|---|
| 176 | _minimumNumberAccumBlueBits = blue; |
|---|
| 177 | _minimumNumberAccumAlphaBits = alpha; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | static ApplicationUsageProxy DisplaySetting_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DISPLAY_TYPE <type>","MONITOR | POWERWALL | REALITY_CENTER | HEAD_MOUNTED_DISPLAY"); |
|---|
| 181 | 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"); |
|---|
| 182 | static ApplicationUsageProxy DisplaySetting_e2(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_STEREO <mode>","OFF | ON"); |
|---|
| 183 | static ApplicationUsageProxy DisplaySetting_e3(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_EYE_SEPARATION <float>","physical distance between eyes"); |
|---|
| 184 | static ApplicationUsageProxy DisplaySetting_e4(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SCREEN_DISTANCE <float>","physical distance between eyes and screen"); |
|---|
| 185 | static ApplicationUsageProxy DisplaySetting_e5(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SCREEN_HEIGHT <float>","physical screen height"); |
|---|
| 186 | static ApplicationUsageProxy DisplaySetting_e6(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SCREEN_WIDTH <float>","physical screen width"); |
|---|
| 187 | static ApplicationUsageProxy DisplaySetting_e7(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING <mode>","LEFT_EYE_LEFT_VIEWPORT | LEFT_EYE_RIGHT_VIEWPORT"); |
|---|
| 188 | static ApplicationUsageProxy DisplaySetting_e8(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SPLIT_STEREO_HORIZONTAL_SEPARATION <float>","number of pixels between viewports"); |
|---|
| 189 | static ApplicationUsageProxy DisplaySetting_e9(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SPLIT_STEREO_VERTICAL_EYE_MAPPING <mode>","LEFT_EYE_TOP_VIEWPORT | LEFT_EYE_BOTTOM_VIEWPORT"); |
|---|
| 190 | 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."); |
|---|
| 191 | static ApplicationUsageProxy DisplaySetting_e11(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SPLIT_STEREO_VERTICAL_SEPARATION <float>","number of pixels between viewports"); |
|---|
| 192 | static ApplicationUsageProxy DisplaySetting_e12(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_NUMBER_OF_GRAPHICS_CONTEXTS <int>","maximum number of graphics contexts to be used with applications."); |
|---|
| 193 | static ApplicationUsageProxy DisplaySetting_e13(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_COMPILE_CONTEXTS <mode>","OFF | ON Enable/disable the use a backgrouind compile contexts and threads."); |
|---|
| 194 | 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."); |
|---|
| 195 | 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."); |
|---|
| 196 | 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."); |
|---|
| 197 | static ApplicationUsageProxy DisplaySetting_e17(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MULTI_SAMPLES <int>","Set the hint for the number of samples to use when multi-sampling."); |
|---|
| 198 | static ApplicationUsageProxy DisplaySetting_e18(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_TEXTURE_POOL_SIZE <int>","Set the hint size of texture pool to manage."); |
|---|
| 199 | static ApplicationUsageProxy DisplaySetting_e19(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_BUFFER_OBJECT_POOL_SIZE <int>","Set the hint size of vertex buffer object pool to manage."); |
|---|
| 200 | static ApplicationUsageProxy DisplaySetting_e20(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_FBO_POOL_SIZE <int>","Set the hint size of frame buffer object pool to manage."); |
|---|
| 201 | |
|---|
| 202 | void DisplaySettings::readEnvironmentalVariables() |
|---|
| 203 | { |
|---|
| 204 | const char* ptr = 0; |
|---|
| 205 | |
|---|
| 206 | if ((ptr = getenv("OSG_DISPLAY_TYPE")) != 0) |
|---|
| 207 | { |
|---|
| 208 | if (strcmp(ptr,"MONITOR")==0) |
|---|
| 209 | { |
|---|
| 210 | _displayType = MONITOR; |
|---|
| 211 | } |
|---|
| 212 | else |
|---|
| 213 | if (strcmp(ptr,"POWERWALL")==0) |
|---|
| 214 | { |
|---|
| 215 | _displayType = POWERWALL; |
|---|
| 216 | } |
|---|
| 217 | else |
|---|
| 218 | if (strcmp(ptr,"REALITY_CENTER")==0) |
|---|
| 219 | { |
|---|
| 220 | _displayType = REALITY_CENTER; |
|---|
| 221 | } |
|---|
| 222 | else |
|---|
| 223 | if (strcmp(ptr,"HEAD_MOUNTED_DISPLAY")==0) |
|---|
| 224 | { |
|---|
| 225 | _displayType = HEAD_MOUNTED_DISPLAY; |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | if( (ptr = getenv("OSG_STEREO_MODE")) != 0) |
|---|
| 230 | { |
|---|
| 231 | if (strcmp(ptr,"QUAD_BUFFER")==0) |
|---|
| 232 | { |
|---|
| 233 | _stereoMode = QUAD_BUFFER; |
|---|
| 234 | } |
|---|
| 235 | else if (strcmp(ptr,"ANAGLYPHIC")==0) |
|---|
| 236 | { |
|---|
| 237 | _stereoMode = ANAGLYPHIC; |
|---|
| 238 | } |
|---|
| 239 | else if (strcmp(ptr,"HORIZONTAL_SPLIT")==0) |
|---|
| 240 | { |
|---|
| 241 | _stereoMode = HORIZONTAL_SPLIT; |
|---|
| 242 | } |
|---|
| 243 | else if (strcmp(ptr,"VERTICAL_SPLIT")==0) |
|---|
| 244 | { |
|---|
| 245 | _stereoMode = VERTICAL_SPLIT; |
|---|
| 246 | } |
|---|
| 247 | else if (strcmp(ptr,"LEFT_EYE")==0) |
|---|
| 248 | { |
|---|
| 249 | _stereoMode = LEFT_EYE; |
|---|
| 250 | } |
|---|
| 251 | else if (strcmp(ptr,"RIGHT_EYE")==0) |
|---|
| 252 | { |
|---|
| 253 | _stereoMode = RIGHT_EYE; |
|---|
| 254 | } |
|---|
| 255 | else if (strcmp(ptr,"HORIZONTAL_INTERLACE")==0) |
|---|
| 256 | { |
|---|
| 257 | _stereoMode = HORIZONTAL_INTERLACE; |
|---|
| 258 | } |
|---|
| 259 | else if (strcmp(ptr,"VERTICAL_INTERLACE")==0) |
|---|
| 260 | { |
|---|
| 261 | _stereoMode = VERTICAL_INTERLACE; |
|---|
| 262 | } |
|---|
| 263 | else if (strcmp(ptr,"CHECKERBOARD")==0) |
|---|
| 264 | { |
|---|
| 265 | _stereoMode = CHECKERBOARD; |
|---|
| 266 | } |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | if( (ptr = getenv("OSG_STEREO")) != 0) |
|---|
| 270 | { |
|---|
| 271 | if (strcmp(ptr,"OFF")==0) |
|---|
| 272 | { |
|---|
| 273 | _stereo = false; |
|---|
| 274 | } |
|---|
| 275 | else |
|---|
| 276 | if (strcmp(ptr,"ON")==0) |
|---|
| 277 | { |
|---|
| 278 | _stereo = true; |
|---|
| 279 | } |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | if( (ptr = getenv("OSG_EYE_SEPARATION")) != 0) |
|---|
| 283 | { |
|---|
| 284 | _eyeSeparation = osg::asciiToFloat(ptr); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | if( (ptr = getenv("OSG_SCREEN_WIDTH")) != 0) |
|---|
| 288 | { |
|---|
| 289 | _screenWidth = osg::asciiToFloat(ptr); |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | if( (ptr = getenv("OSG_SCREEN_HEIGHT")) != 0) |
|---|
| 293 | { |
|---|
| 294 | _screenHeight = osg::asciiToFloat(ptr); |
|---|
| 295 | } |
|---|
| 296 | |
|---|
| 297 | if( (ptr = getenv("OSG_SCREEN_DISTANCE")) != 0) |
|---|
| 298 | { |
|---|
| 299 | _screenDistance = osg::asciiToFloat(ptr); |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | if( (ptr = getenv("OSG_SPLIT_STEREO_HORIZONTAL_EYE_MAPPING")) != 0) |
|---|
| 303 | { |
|---|
| 304 | if (strcmp(ptr,"LEFT_EYE_LEFT_VIEWPORT")==0) |
|---|
| 305 | { |
|---|
| 306 | _splitStereoHorizontalEyeMapping = LEFT_EYE_LEFT_VIEWPORT; |
|---|
| 307 | } |
|---|
| 308 | else |
|---|
| 309 | if (strcmp(ptr,"LEFT_EYE_RIGHT_VIEWPORT")==0) |
|---|
| 310 | { |
|---|
| 311 | _splitStereoHorizontalEyeMapping = LEFT_EYE_RIGHT_VIEWPORT; |
|---|
| 312 | } |
|---|
| 313 | } |
|---|
| 314 | |
|---|
| 315 | if( (ptr = getenv("OSG_SPLIT_STEREO_HORIZONTAL_SEPARATION")) != 0) |
|---|
| 316 | { |
|---|
| 317 | _splitStereoHorizontalSeparation = atoi(ptr); |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | if( (ptr = getenv("OSG_SPLIT_STEREO_VERTICAL_EYE_MAPPING")) != 0) |
|---|
| 322 | { |
|---|
| 323 | if (strcmp(ptr,"LEFT_EYE_TOP_VIEWPORT")==0) |
|---|
| 324 | { |
|---|
| 325 | _splitStereoVerticalEyeMapping = LEFT_EYE_TOP_VIEWPORT; |
|---|
| 326 | } |
|---|
| 327 | else |
|---|
| 328 | if (strcmp(ptr,"LEFT_EYE_BOTTOM_VIEWPORT")==0) |
|---|
| 329 | { |
|---|
| 330 | _splitStereoVerticalEyeMapping = LEFT_EYE_BOTTOM_VIEWPORT; |
|---|
| 331 | } |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | if( (ptr = getenv("OSG_SPLIT_STEREO_AUTO_ADJUST_ASPECT_RATIO")) != 0) |
|---|
| 335 | { |
|---|
| 336 | if (strcmp(ptr,"OFF")==0) |
|---|
| 337 | { |
|---|
| 338 | _splitStereoAutoAdjustAspectRatio = false; |
|---|
| 339 | } |
|---|
| 340 | else |
|---|
| 341 | if (strcmp(ptr,"ON")==0) |
|---|
| 342 | { |
|---|
| 343 | _splitStereoAutoAdjustAspectRatio = true; |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | if( (ptr = getenv("OSG_SPLIT_STEREO_VERTICAL_SEPARATION")) != 0) |
|---|
| 348 | { |
|---|
| 349 | _splitStereoVerticalSeparation = atoi(ptr); |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | if( (ptr = getenv("OSG_MAX_NUMBER_OF_GRAPHICS_CONTEXTS")) != 0) |
|---|
| 353 | { |
|---|
| 354 | _maxNumOfGraphicsContexts = atoi(ptr); |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | if( (ptr = getenv("OSG_COMPIlE_CONTEXTS")) != 0) |
|---|
| 358 | { |
|---|
| 359 | if (strcmp(ptr,"OFF")==0) |
|---|
| 360 | { |
|---|
| 361 | _compileContextsHint = false; |
|---|
| 362 | } |
|---|
| 363 | else |
|---|
| 364 | if (strcmp(ptr,"ON")==0) |
|---|
| 365 | { |
|---|
| 366 | _compileContextsHint = true; |
|---|
| 367 | } |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | if( (ptr = getenv("OSG_SERIALIZE_DRAW_DISPATCH")) != 0) |
|---|
| 371 | { |
|---|
| 372 | if (strcmp(ptr,"OFF")==0) |
|---|
| 373 | { |
|---|
| 374 | _serializeDrawDispatch = false; |
|---|
| 375 | } |
|---|
| 376 | else |
|---|
| 377 | if (strcmp(ptr,"ON")==0) |
|---|
| 378 | { |
|---|
| 379 | _serializeDrawDispatch = true; |
|---|
| 380 | } |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | if( (ptr = getenv("OSG_NUM_DATABASE_THREADS")) != 0) |
|---|
| 384 | { |
|---|
| 385 | _numDatabaseThreadsHint = atoi(ptr); |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | if( (ptr = getenv("OSG_NUM_HTTP_DATABASE_THREADS")) != 0) |
|---|
| 389 | { |
|---|
| 390 | _numHttpDatabaseThreadsHint = atoi(ptr); |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | if( (ptr = getenv("OSG_MULTI_SAMPLES")) != 0) |
|---|
| 394 | { |
|---|
| 395 | _numMultiSamples = atoi(ptr); |
|---|
| 396 | } |
|---|
| 397 | |
|---|
| 398 | if( (ptr = getenv("OSG_TEXTURE_POOL_SIZE")) != 0) |
|---|
| 399 | { |
|---|
| 400 | _maxTexturePoolSize = atoi(ptr); |
|---|
| 401 | } |
|---|
| 402 | |
|---|
| 403 | if( (ptr = getenv("OSG_BUFFER_OBJECT_POOL_SIZE")) != 0) |
|---|
| 404 | { |
|---|
| 405 | _maxBufferObjectPoolSize = atoi(ptr); |
|---|
| 406 | } |
|---|
| 407 | } |
|---|
| 408 | |
|---|
| 409 | void DisplaySettings::readCommandLine(ArgumentParser& arguments) |
|---|
| 410 | { |
|---|
| 411 | if (_application.empty()) _application = arguments[0]; |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | if (arguments.getApplicationUsage()) |
|---|
| 415 | { |
|---|
| 416 | arguments.getApplicationUsage()->addCommandLineOption("--display <type>","MONITOR | POWERWALL | REALITY_CENTER | HEAD_MOUNTED_DISPLAY"); |
|---|
| 417 | arguments.getApplicationUsage()->addCommandLineOption("--stereo","Use default stereo mode which is ANAGLYPHIC if not overriden by environmental variable"); |
|---|
| 418 | arguments.getApplicationUsage()->addCommandLineOption("--stereo <mode>","ANAGLYPHIC | QUAD_BUFFER | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE | HORIZONTAL_INTERLACE | VERTICAL_INTERLACE | CHECKERBOARD | ON | OFF "); |
|---|
| 419 | arguments.getApplicationUsage()->addCommandLineOption("--rgba","Request a RGBA color buffer visual"); |
|---|
| 420 | arguments.getApplicationUsage()->addCommandLineOption("--stencil","Request a stencil buffer visual"); |
|---|
| 421 | arguments.getApplicationUsage()->addCommandLineOption("--accum-rgb","Request a rgb accumulator buffer visual"); |
|---|
| 422 | arguments.getApplicationUsage()->addCommandLineOption("--accum-rgba","Request a rgb accumulator buffer visual"); |
|---|
| 423 | arguments.getApplicationUsage()->addCommandLineOption("--samples <num>","Request a multisample visual"); |
|---|
| 424 | arguments.getApplicationUsage()->addCommandLineOption("--cc","Request use of compile contexts and threads"); |
|---|
| 425 | arguments.getApplicationUsage()->addCommandLineOption("--serialize-draw <mode>","OFF | ON - set the serialization of draw dispatch"); |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | std::string str; |
|---|
| 429 | while(arguments.read("--display",str)) |
|---|
| 430 | { |
|---|
| 431 | if (str=="MONITOR") _displayType = MONITOR; |
|---|
| 432 | else if (str=="POWERWALL") _displayType = POWERWALL; |
|---|
| 433 | else if (str=="REALITY_CENTER") _displayType = REALITY_CENTER; |
|---|
| 434 | else if (str=="HEAD_MOUNTED_DISPLAY") _displayType = HEAD_MOUNTED_DISPLAY; |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | int pos; |
|---|
| 438 | while ((pos=arguments.find("--stereo"))>0) |
|---|
| 439 | { |
|---|
| 440 | if (arguments.match(pos+1,"ANAGLYPHIC")) { arguments.remove(pos,2); _stereo = true;_stereoMode = ANAGLYPHIC; } |
|---|
| 441 | else if (arguments.match(pos+1,"QUAD_BUFFER")) { arguments.remove(pos,2); _stereo = true;_stereoMode = QUAD_BUFFER; } |
|---|
| 442 | else if (arguments.match(pos+1,"HORIZONTAL_SPLIT")) { arguments.remove(pos,2); _stereo = true;_stereoMode = HORIZONTAL_SPLIT; } |
|---|
| 443 | else if (arguments.match(pos+1,"VERTICAL_SPLIT")) { arguments.remove(pos,2); _stereo = true;_stereoMode = VERTICAL_SPLIT; } |
|---|
| 444 | else if (arguments.match(pos+1,"HORIZONTAL_INTERLACE")) { arguments.remove(pos,2); _stereo = true;_stereoMode = HORIZONTAL_INTERLACE; } |
|---|
| 445 | else if (arguments.match(pos+1,"VERTICAL_INTERLACE")) { arguments.remove(pos,2); _stereo = true;_stereoMode = VERTICAL_INTERLACE; } |
|---|
| 446 | else if (arguments.match(pos+1,"CHECKERBOARD")) { arguments.remove(pos,2); _stereo = true;_stereoMode = CHECKERBOARD; } |
|---|
| 447 | else if (arguments.match(pos+1,"LEFT_EYE")) { arguments.remove(pos,2); _stereo = true;_stereoMode = LEFT_EYE; } |
|---|
| 448 | else if (arguments.match(pos+1,"RIGHT_EYE")) { arguments.remove(pos,2); _stereo = true;_stereoMode = RIGHT_EYE; } |
|---|
| 449 | else if (arguments.match(pos+1,"ON")) { arguments.remove(pos,2); _stereo = true; } |
|---|
| 450 | else if (arguments.match(pos+1,"OFF")) { arguments.remove(pos,2); _stereo = false; } |
|---|
| 451 | else { arguments.remove(pos); _stereo = true; } |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | while (arguments.read("--rgba")) |
|---|
| 455 | { |
|---|
| 456 | _RGB = true; |
|---|
| 457 | _minimumNumberAlphaBits = 1; |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | while (arguments.read("--stencil")) |
|---|
| 461 | { |
|---|
| 462 | _minimumNumberStencilBits = 1; |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | while (arguments.read("--accum-rgb")) |
|---|
| 466 | { |
|---|
| 467 | setMinimumNumAccumBits(8,8,8,0); |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | while (arguments.read("--accum-rgba")) |
|---|
| 471 | { |
|---|
| 472 | setMinimumNumAccumBits(8,8,8,8); |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | while(arguments.read("--samples",str)) |
|---|
| 476 | { |
|---|
| 477 | _numMultiSamples = atoi(str.c_str()); |
|---|
| 478 | } |
|---|
| 479 | |
|---|
| 480 | while(arguments.read("--cc")) |
|---|
| 481 | { |
|---|
| 482 | _compileContextsHint = true; |
|---|
| 483 | } |
|---|
| 484 | |
|---|
| 485 | while(arguments.read("--serialize-draw",str)) |
|---|
| 486 | { |
|---|
| 487 | if (str=="ON") _serializeDrawDispatch = true; |
|---|
| 488 | else if (str=="OFF") _serializeDrawDispatch = false; |
|---|
| 489 | } |
|---|
| 490 | |
|---|
| 491 | while(arguments.read("--num-db-threads",_numDatabaseThreadsHint)) {} |
|---|
| 492 | while(arguments.read("--num-http-threads",_numHttpDatabaseThreadsHint)) {} |
|---|
| 493 | |
|---|
| 494 | while(arguments.read("--texture-pool-size",_maxTexturePoolSize)) {} |
|---|
| 495 | while(arguments.read("--buffer-object-pool-size",_maxBufferObjectPoolSize)) {} |
|---|
| 496 | |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | |
|---|