From 306f45fbf267bfead75877462210d5cca902e8b9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 26 Jan 2010 17:04:55 +0000 Subject: [PATCH] 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 and , > 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." --- src/osgViewer/PixelBufferWin32.cpp | 2 ++ src/osgViewer/PixelBufferX11.cpp | 44 ++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/osgViewer/PixelBufferWin32.cpp b/src/osgViewer/PixelBufferWin32.cpp index 84819cd4c..f36b4f96f 100644 --- a/src/osgViewer/PixelBufferWin32.cpp +++ b/src/osgViewer/PixelBufferWin32.cpp @@ -632,6 +632,8 @@ void PixelBufferWin32::init() osg::notify(osg::NOTICE) << "PixelBufferWin32::init(), pbuffer created with different size then requsted" << std::endl; osg::notify(osg::NOTICE) << "\tRequested size (" << _traits->width << "," << _traits->height << ")" << std::endl; osg::notify(osg::NOTICE) << "\tPbuffer size (" << iWidth << "," << iHeight << ")" << std::endl; + _traits->width = iWidth; + _traits->height = iHeight; } _initialized = true; diff --git a/src/osgViewer/PixelBufferX11.cpp b/src/osgViewer/PixelBufferX11.cpp index fee2e3590..8fe65282d 100644 --- a/src/osgViewer/PixelBufferX11.cpp +++ b/src/osgViewer/PixelBufferX11.cpp @@ -250,6 +250,8 @@ void PixelBufferX11::init() attributes.push_back( _traits->width ); attributes.push_back( GLX_PBUFFER_HEIGHT ); attributes.push_back( _traits->height ); + attributes.push_back( GLX_LARGEST_PBUFFER ); + attributes.push_back( GL_TRUE ); attributes.push_back( 0L ); _pbuffer = glXCreatePbuffer(_display, fbconfigs[i], &attributes.front() ); @@ -257,7 +259,22 @@ void PixelBufferX11::init() } } } + if (_pbuffer) + { + int iWidth = 0; + int iHeight = 0; + glXQueryDrawable(_display, _pbuffer, GLX_WIDTH , (unsigned int *)&iWidth); + glXQueryDrawable(_display, _pbuffer, GLX_HEIGHT , (unsigned int *)&iHeight); + if (_traits->width != iWidth || _traits->height != iHeight) + { + osg::notify(osg::NOTICE) << "PixelBufferX11::init(), pbuffer created with different size then requsted" << std::endl; + osg::notify(osg::NOTICE) << "\tRequested size (" << _traits->width << "," << _traits->height << ")" << std::endl; + osg::notify(osg::NOTICE) << "\tPbuffer size (" << iWidth << "," << iHeight << ")" << std::endl; + _traits->width = iWidth; + _traits->height = iHeight; + } + } XFree( fbconfigs ); } #endif @@ -267,9 +284,30 @@ void PixelBufferX11::init() if (!_pbuffer && haveSGIX_pbuffer) { GLXFBConfigSGIX fbconfig = glXGetFBConfigFromVisualSGIX( _display, _visualInfo ); - - _pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, 0 ); - + typedef std::vector AttributeList; + + AttributeList attributes; + attributes.push_back( GLX_LARGEST_PBUFFER_SGIX ); + attributes.push_back( GL_TRUE ); + attributes.push_back( 0L ); + + _pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, &attributes.front() ); + if (_pbuffer) + { + int iWidth = 0; + int iHeight = 0; + glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_WIDTH_SGIX , (unsigned int *)&iWidth); + glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_HEIGHT_SGIX, (unsigned int *)&iHeight); + + if (_traits->width != iWidth || _traits->height != iHeight) + { + osg::notify(osg::NOTICE) << "PixelBufferX11::init(), SGIX_pbuffer created with different size then requsted" << std::endl; + osg::notify(osg::NOTICE) << "\tRequested size (" << _traits->width << "," << _traits->height << ")" << std::endl; + osg::notify(osg::NOTICE) << "\tPbuffer size (" << iWidth << "," << iHeight << ")" << std::endl; + _traits->width = iWidth; + _traits->height = iHeight; + } + } XFree( fbconfig ); } #endif