Changeset 13041 for OpenSceneGraph/trunk/src/osgViewer/PixelBufferX11.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgViewer/PixelBufferX11.cpp
r12292 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 38 38 39 39 init(); 40 40 41 41 if (valid()) 42 42 { … … 47 47 { 48 48 getState()->setContextID( _traits->sharedContext->getState()->getContextID() ); 49 incrementContextIDUsageCount( getState()->getContextID() ); 49 incrementContextIDUsageCount( getState()->getContextID() ); 50 50 } 51 51 else … … 67 67 typedef std::vector<int> Attributes; 68 68 Attributes attributes; 69 69 70 70 attributes.push_back(GLX_USE_GL); 71 71 72 72 attributes.push_back(GLX_RGBA); 73 73 74 74 if (_traits->doubleBuffer) attributes.push_back(GLX_DOUBLEBUFFER); 75 75 76 76 attributes.push_back(GLX_RED_SIZE); attributes.push_back(_traits->red); 77 77 attributes.push_back(GLX_GREEN_SIZE); attributes.push_back(_traits->green); 78 78 attributes.push_back(GLX_BLUE_SIZE); attributes.push_back(_traits->blue); 79 79 attributes.push_back(GLX_DEPTH_SIZE); attributes.push_back(_traits->depth); 80 80 81 81 if (_traits->alpha) { attributes.push_back(GLX_ALPHA_SIZE); attributes.push_back(_traits->alpha); } 82 82 83 83 if (_traits->stencil) { attributes.push_back(GLX_STENCIL_SIZE); attributes.push_back(_traits->stencil); } 84 84 … … 93 93 // GLX_ACCUM_RED_SIZE 94 94 // GLX_ACCUM_GREEN_SIZE 95 95 96 96 attributes.push_back(None); 97 97 98 98 _visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) ); 99 99 … … 110 110 return; 111 111 } 112 112 113 113 if (_traits->target != 0) 114 114 { … … 120 120 121 121 _display = XOpenDisplay(_traits->displayName().c_str()); 122 122 123 123 unsigned int screen = _traits->screenNum; 124 124 … … 195 195 } 196 196 197 197 198 198 if (!createVisualInfo()) 199 199 { 200 _traits->red /= 2; 201 _traits->green /= 2; 202 _traits->blue /= 2; 203 _traits->alpha /= 2; 204 _traits->depth /= 2; 205 200 _traits->red /= 2; 201 _traits->green /= 2; 202 _traits->blue /= 2; 203 _traits->alpha /= 2; 204 _traits->depth /= 2; 205 206 206 OSG_INFO<<"Relaxing traits"<<std::endl; 207 207 … … 213 213 _valid = false; 214 214 return; 215 } 216 } 217 215 } 216 } 217 218 218 // get any shared GLX contexts 219 219 GraphicsHandleX11* graphicsHandleX11 = dynamic_cast<GraphicsHandleX11*>(_traits->sharedContext); … … 230 230 return; 231 231 } 232 232 233 233 #ifdef GLX_VERSION_1_3 234 234 // First try the regular glx extension if we have a new enough version available. … … 245 245 { 246 246 typedef std::vector <int> AttributeList; 247 247 248 248 AttributeList attributes; 249 249 attributes.push_back( GLX_PBUFFER_WIDTH ); … … 254 254 attributes.push_back( GL_TRUE ); 255 255 attributes.push_back( 0L ); 256 256 257 257 _pbuffer = glXCreatePbuffer(_display, fbconfigs[i], &attributes.front() ); 258 258 _useGLX1_3 = true; … … 286 286 GLXFBConfigSGIX fbconfig = glXGetFBConfigFromVisualSGIX( _display, _visualInfo ); 287 287 typedef std::vector <int> AttributeList; 288 288 289 289 AttributeList attributes; 290 290 attributes.push_back( GLX_LARGEST_PBUFFER_SGIX ); 291 291 attributes.push_back( GL_TRUE ); 292 292 attributes.push_back( 0L ); 293 293 294 294 _pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, &attributes.front() ); 295 295 if (_pbuffer) … … 299 299 glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_WIDTH_SGIX , (unsigned int *)&iWidth); 300 300 glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_HEIGHT_SGIX, (unsigned int *)&iHeight); 301 301 302 302 if (_traits->width != iWidth || _traits->height != iHeight) 303 303 { … … 340 340 glXDestroyContext(_display, _context ); 341 341 } 342 342 343 343 if (_pbuffer) 344 344 { … … 360 360 XSync( _display,0 ); 361 361 } 362 362 363 363 _pbuffer = 0; 364 364 _context = 0; … … 415 415 416 416 if (!_initialized) init(); 417 417 418 418 if (!_initialized) return false; 419 419
