Changeset 11007

Show
Ignore:
Timestamp:
01/26/10 18:04:55 (4 years ago)
Author:
robert
Message:

From Laurens Voerman, "Wile working with pbuffers I noticed that the Win32 implementation uses the attribute WGL_PBUFFER_LARGEST_ARB.

quote from http://www.opengl.org/registry/specs/ARB/wgl_pbuffer.txt
The following attributes are supported by wglCreatePbufferARB:

WGL_PBUFFER_LARGEST_ARB If this attribute is set to a
non-zero value, the largest
available pbuffer is allocated
when the allocation of the pbuffer
would otherwise fail due to
insufficient resources. The width
or height of the allocated pbuffer
never exceeds <iWidth> and <iHeight>,
respectively. Use wglQueryPbufferARB
to retrieve the dimensions of the
allocated pbuffer.

It notifies the user when the size is not as requested, but I could find no way for the program to detect this. I've added two lines to write the new size back into the _traits, I think this is appropriate, but I am not absolutely sure.

In PixelBufferX11 was no support, so I've added GLX_LARGEST_PBUFFER(_SGIX) support, with the same writeback to the _trais.

I have tested the GLX_LARGEST_PBUFFER version on linux and the WGL_PBUFFER_LARGEST_ARB with windows, all tested with the modified autocapture I just submitted.

"autocapture --pbuffer --window 100 100 18192 18192 cow.osg.\[0,0,-22.7\].trans"
gives me a 4096x4096 image on my windows machine,
and a 8192x8192 image on linux."

Location:
OpenSceneGraph/trunk/src/osgViewer
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgViewer/PixelBufferWin32.cpp

    r10824 r11007  
    633633        osg::notify(osg::NOTICE) << "\tRequested size (" << _traits->width << "," << _traits->height << ")" << std::endl; 
    634634        osg::notify(osg::NOTICE) << "\tPbuffer size (" << iWidth << "," << iHeight << ")" << std::endl; 
     635        _traits->width  = iWidth; 
     636        _traits->height = iHeight; 
    635637    } 
    636638 
  • OpenSceneGraph/trunk/src/osgViewer/PixelBufferX11.cpp

    r10813 r11007  
    251251                    attributes.push_back( GLX_PBUFFER_HEIGHT ); 
    252252                    attributes.push_back( _traits->height ); 
     253                    attributes.push_back( GLX_LARGEST_PBUFFER ); 
     254                    attributes.push_back( GL_TRUE ); 
    253255                    attributes.push_back( 0L ); 
    254256                     
     
    258260            } 
    259261        } 
    260  
     262        if (_pbuffer) 
     263        { 
     264            int iWidth = 0; 
     265            int iHeight = 0; 
     266            glXQueryDrawable(_display, _pbuffer, GLX_WIDTH  , (unsigned int *)&iWidth); 
     267            glXQueryDrawable(_display, _pbuffer, GLX_HEIGHT , (unsigned int *)&iHeight); 
     268 
     269            if (_traits->width != iWidth || _traits->height != iHeight) 
     270            { 
     271                osg::notify(osg::NOTICE) << "PixelBufferX11::init(), pbuffer created with different size then requsted" << std::endl; 
     272                osg::notify(osg::NOTICE) << "\tRequested size (" << _traits->width << "," << _traits->height << ")" << std::endl; 
     273                osg::notify(osg::NOTICE) << "\tPbuffer size (" << iWidth << "," << iHeight << ")" << std::endl; 
     274                _traits->width  = iWidth; 
     275                _traits->height = iHeight; 
     276            } 
     277        } 
    261278        XFree( fbconfigs ); 
    262279    } 
     
    268285    { 
    269286        GLXFBConfigSGIX fbconfig = glXGetFBConfigFromVisualSGIX( _display, _visualInfo ); 
    270  
    271         _pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, 0 ); 
    272  
     287        typedef std::vector <int> AttributeList; 
     288        
     289        AttributeList attributes; 
     290        attributes.push_back( GLX_LARGEST_PBUFFER_SGIX ); 
     291        attributes.push_back( GL_TRUE ); 
     292        attributes.push_back( 0L ); 
     293         
     294        _pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height,  &attributes.front() ); 
     295        if (_pbuffer) 
     296        { 
     297            int iWidth = 0; 
     298            int iHeight = 0; 
     299            glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_WIDTH_SGIX , (unsigned int *)&iWidth); 
     300            glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_HEIGHT_SGIX, (unsigned int *)&iHeight); 
     301                                                                                         
     302            if (_traits->width != iWidth || _traits->height != iHeight) 
     303            { 
     304                osg::notify(osg::NOTICE) << "PixelBufferX11::init(), SGIX_pbuffer created with different size then requsted" << std::endl; 
     305                osg::notify(osg::NOTICE) << "\tRequested size (" << _traits->width << "," << _traits->height << ")" << std::endl; 
     306                osg::notify(osg::NOTICE) << "\tPbuffer size (" << iWidth << "," << iHeight << ")" << std::endl; 
     307                _traits->width =  iWidth; 
     308                _traits->height = iHeight; 
     309            } 
     310        } 
    273311        XFree( fbconfig ); 
    274312    }