Changeset 10740
- Timestamp:
- 11/11/09 16:25:42 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 5 modified
-
include/osg/DisplaySettings (modified) (2 diffs)
-
include/osg/GraphicsContext (modified) (2 diffs)
-
src/osg/DisplaySettings.cpp (modified) (6 diffs)
-
src/osg/GraphicsContext.cpp (modified) (1 diff)
-
src/osgViewer/View.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/DisplaySettings
r10601 r10740 206 206 void setMaxBufferObjectPoolSize(unsigned int size) { _maxBufferObjectPoolSize = size; } 207 207 unsigned int getMaxBufferObjectPoolSize() const { return _maxBufferObjectPoolSize; } 208 209 /** Set the hint of which OpenGL version to attempt to create a graphics context for.*/ 210 void setGLContextVersion(const std::string& version) { _glContextVersion = version; } 211 212 /** Get the hint of which OpenGL version to attempt to create a graphics context for.*/ 213 const std::string getGLContextVersion() const { return _glContextVersion; } 214 215 /** Set the hint of the flags to use in when creating graphic contexts.*/ 216 void setGLContextFlags(unsigned int flags) { _glContextFlags = flags; } 217 218 /** Get the hint of the flags to use in when creating graphic contexts.*/ 219 unsigned int getGLContextFlags() const { return _glContextFlags; } 220 221 /** Set the hint of the profile mask to use in when creating graphic contexts.*/ 222 void setGLContextProfileMask(unsigned int mask) { _glContextProfileMask = mask; } 223 224 /** Get the hint of the profile mask to use in when creating graphic contexts.*/ 225 unsigned int getGLContextProfileMask() const { return _glContextProfileMask; } 208 226 209 227 protected: … … 250 268 unsigned int _maxTexturePoolSize; 251 269 unsigned int _maxBufferObjectPoolSize; 270 271 std::string _glContextVersion; 272 unsigned int _glContextFlags; 273 unsigned int _glContextProfileMask; 252 274 }; 253 275 -
OpenSceneGraph/trunk/include/osg/GraphicsContext
r9916 r10740 69 69 struct Traits : public osg::Referenced, public ScreenIdentifier 70 70 { 71 Traits(): 72 x(0), 73 y(0), 74 width(0), 75 height(0), 76 windowDecoration(false), 77 supportsResize(true), 78 red(8), 79 blue(8), 80 green(8), 81 alpha(0), 82 depth(24), 83 stencil(0), 84 sampleBuffers(0), 85 samples(0), 86 pbuffer(false), 87 quadBufferStereo(false), 88 doubleBuffer(false), 89 target(0), 90 format(0), 91 level(0), 92 face(0), 93 mipMapGeneration(false), 94 vsync(true), 95 useMultiThreadedOpenGLEngine(false), 96 useCursor(true), 97 sharedContext(0), 98 setInheritedWindowPixelFormat(false), 99 overrideRedirect(false) {} 71 Traits(DisplaySettings* ds=0); 100 72 101 73 // graphics context original and size … … 142 114 // enable cursor 143 115 bool useCursor; 116 117 // settings used in set up of graphics context, only presently used by GL3 build of OSG. 118 std::string glContextVersion; 119 unsigned int glContextFlags; 120 unsigned int glContextProfileMask; 121 144 122 145 123 // shared context -
OpenSceneGraph/trunk/src/osg/DisplaySettings.cpp
r10601 r10740 84 84 _maxTexturePoolSize = vs._maxTexturePoolSize; 85 85 _maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize; 86 87 _glContextVersion = vs._glContextVersion; 88 _glContextFlags = vs._glContextFlags; 89 _glContextProfileMask = vs._glContextProfileMask; 86 90 } 87 91 … … 157 161 _maxTexturePoolSize = 0; 158 162 _maxBufferObjectPoolSize = 0; 163 164 _glContextVersion = "1.0"; 165 _glContextFlags = 0; 166 _glContextProfileMask = 0; 159 167 } 160 168 … … 199 207 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 208 static ApplicationUsageProxy DisplaySetting_e20(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_FBO_POOL_SIZE <int>","Set the hint size of frame buffer object pool to manage."); 209 static ApplicationUsageProxy DisplaySetting_e21(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_VERSION <major.minor>","Set the hint for the GL version to create contexts for."); 210 static ApplicationUsageProxy DisplaySetting_e22(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_FLAGS <uint>","Set the hint for the GL context flags to use when creating contexts."); 211 static ApplicationUsageProxy DisplaySetting_e23(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_PROFILE_MASK <uint>","Set the hint for the GL context profile mask to use when creating contexts."); 201 212 202 213 void DisplaySettings::readEnvironmentalVariables() … … 404 415 { 405 416 _maxBufferObjectPoolSize = atoi(ptr); 417 } 418 419 if( (ptr = getenv("OSG_GL_VERSION")) != 0 || (ptr = getenv("OSG_GL_CONTEXT_VERSION")) != 0) 420 { 421 _glContextVersion = ptr; 422 } 423 424 if( (ptr = getenv("OSG_GL_CONTEXT_FLAGS")) != 0) 425 { 426 _glContextFlags = atoi(ptr); 427 } 428 429 if( (ptr = getenv("OSG_GL_CONTEXT_PROFILE_MASK")) != 0) 430 { 431 _glContextProfileMask = atoi(ptr); 406 432 } 407 433 } … … 424 450 arguments.getApplicationUsage()->addCommandLineOption("--cc","Request use of compile contexts and threads"); 425 451 arguments.getApplicationUsage()->addCommandLineOption("--serialize-draw <mode>","OFF | ON - set the serialization of draw dispatch"); 452 arguments.getApplicationUsage()->addCommandLineOption("--gl-version <major.minor>","Set the hint of which GL version to use when creating graphics contexts."); 453 arguments.getApplicationUsage()->addCommandLineOption("--gl-flags <mask>","Set the hint of which GL flags projfile mask to use when creating graphics contexts."); 454 arguments.getApplicationUsage()->addCommandLineOption("--gl-profile-mask <mask>","Set the hint of which GL context profile mask to use when creating graphics contexts."); 426 455 } 427 456 … … 495 524 while(arguments.read("--buffer-object-pool-size",_maxBufferObjectPoolSize)) {} 496 525 497 } 498 499 500 526 while (arguments.read("--gl-version", _glContextVersion)) {} 527 while (arguments.read("--gl-flags", _glContextFlags)) {} 528 while (arguments.read("--gl-profile-mask", _glContextProfileMask)) {} 529 530 } 531 532 533 -
OpenSceneGraph/trunk/src/osg/GraphicsContext.cpp
r10260 r10740 152 152 osg::notify(osg::NOTICE)<<" screenNum "<<screenNum<<std::endl; 153 153 #endif 154 } 155 156 GraphicsContext::Traits::Traits(DisplaySettings* ds): 157 x(0), 158 y(0), 159 width(0), 160 height(0), 161 windowDecoration(false), 162 supportsResize(true), 163 red(8), 164 blue(8), 165 green(8), 166 alpha(0), 167 depth(24), 168 stencil(0), 169 sampleBuffers(0), 170 samples(0), 171 pbuffer(false), 172 quadBufferStereo(false), 173 doubleBuffer(false), 174 target(0), 175 format(0), 176 level(0), 177 face(0), 178 mipMapGeneration(false), 179 vsync(true), 180 useMultiThreadedOpenGLEngine(false), 181 useCursor(true), 182 glContextVersion("1.0"), 183 glContextFlags(0), 184 glContextProfileMask(0), 185 sharedContext(0), 186 setInheritedWindowPixelFormat(false), 187 overrideRedirect(false) 188 { 189 if (ds) 190 { 191 alpha = ds->getMinimumNumAlphaBits(); 192 stencil = ds->getMinimumNumStencilBits(); 193 sampleBuffers = ds->getMultiSamples(); 194 samples = ds->getNumMultiSamples(); 195 if (ds->getStereo()) 196 { 197 switch(ds->getStereoMode()) 198 { 199 case(osg::DisplaySettings::QUAD_BUFFER): quadBufferStereo = true; break; 200 case(osg::DisplaySettings::VERTICAL_INTERLACE): 201 case(osg::DisplaySettings::CHECKERBOARD): 202 case(osg::DisplaySettings::HORIZONTAL_INTERLACE): stencil = 8; break; 203 default: break; 204 } 205 } 206 207 glContextVersion = ds->getGLContextVersion(); 208 glContextFlags = ds->getGLContextFlags(); 209 glContextProfileMask = ds->getGLContextProfileMask(); 210 } 154 211 } 155 212 -
OpenSceneGraph/trunk/src/osgViewer/View.cpp
r10729 r10740 450 450 wsi->getScreenResolution(si, width, height); 451 451 452 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits ;452 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds); 453 453 traits->hostName = si.hostName; 454 454 traits->displayNum = si.displayNum; … … 458 458 traits->width = width; 459 459 traits->height = height; 460 traits->alpha = ds->getMinimumNumAlphaBits();461 traits->stencil = ds->getMinimumNumStencilBits();462 460 traits->windowDecoration = false; 463 461 traits->doubleBuffer = true; 464 462 traits->sharedContext = 0; 465 traits->sampleBuffers = ds->getMultiSamples();466 traits->samples = ds->getNumMultiSamples();467 if (ds->getStereo())468 {469 switch(ds->getStereoMode())470 {471 case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;472 case(osg::DisplaySettings::VERTICAL_INTERLACE):473 case(osg::DisplaySettings::CHECKERBOARD):474 case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;475 default: break;476 }477 }478 463 479 464 osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); … … 532 517 wsi->getScreenResolution(si, width, height); 533 518 534 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits ;519 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds); 535 520 traits->hostName = si.hostName; 536 521 traits->displayNum = si.displayNum; … … 541 526 traits->width = width; 542 527 traits->height = height; 543 traits->alpha = ds->getMinimumNumAlphaBits();544 traits->stencil = ds->getMinimumNumStencilBits();545 528 traits->windowDecoration = false; 546 529 traits->doubleBuffer = true; 547 530 traits->sharedContext = 0; 548 traits->sampleBuffers = ds->getMultiSamples();549 traits->samples = ds->getNumMultiSamples();550 if (ds->getStereo())551 {552 switch(ds->getStereoMode())553 {554 case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;555 case(osg::DisplaySettings::VERTICAL_INTERLACE):556 case(osg::DisplaySettings::CHECKERBOARD):557 case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;558 default: break;559 }560 }561 531 562 532 osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); … … 611 581 osg::DisplaySettings* ds = _displaySettings.valid() ? _displaySettings.get() : osg::DisplaySettings::instance(); 612 582 613 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits ;583 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds); 614 584 615 585 traits->readDISPLAY(); … … 621 591 traits->width = width; 622 592 traits->height = height; 623 traits->alpha = ds->getMinimumNumAlphaBits();624 traits->stencil = ds->getMinimumNumStencilBits();625 593 traits->windowDecoration = true; 626 594 traits->doubleBuffer = true; 627 595 traits->sharedContext = 0; 628 traits->sampleBuffers = ds->getMultiSamples();629 traits->samples = ds->getNumMultiSamples();630 if (ds->getStereo())631 {632 switch(ds->getStereoMode())633 {634 case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;635 case(osg::DisplaySettings::VERTICAL_INTERLACE):636 case(osg::DisplaySettings::CHECKERBOARD):637 case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;638 default: break;639 }640 }641 596 642 597 osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); … … 695 650 wsi->getScreenResolution(si, width, height); 696 651 697 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits ;652 osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds); 698 653 traits->hostName = si.hostName; 699 654 traits->displayNum = si.displayNum; … … 703 658 traits->width = width; 704 659 traits->height = height; 705 traits->alpha = ds->getMinimumNumAlphaBits();706 traits->stencil = ds->getMinimumNumStencilBits();707 660 traits->windowDecoration = false; 708 661 traits->doubleBuffer = true; 709 662 traits->sharedContext = 0; 710 traits->sampleBuffers = ds->getMultiSamples();711 traits->samples = ds->getNumMultiSamples();712 if (ds->getStereo())713 {714 switch(ds->getStereoMode())715 {716 case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;717 case(osg::DisplaySettings::VERTICAL_INTERLACE):718 case(osg::DisplaySettings::CHECKERBOARD):719 case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;720 default: break;721 }722 }723 663 724 664 osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
