From Andy Skinner, "Someone was using our code on a system that does not seem to have the SGIX symbols used in osgViewer.cpp.

I used osgSetGLExtensionsFuncPtr to remove the symbols.  I don't know how to test this path, but it did remove the symbols from libosgViewer.so.  I have also not been able yet to see if that was sufficient for our customer.

 

I did this by looking at other cases, and I tried to follow some of the same practices in PixelBufferX11, like using _useSGIX in a similar way to the previous _useGLX1_3."




git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.4@15042 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2015-08-03 19:14:11 +00:00
parent e9b75e0ded
commit 5e8d5b50db
2 changed files with 41 additions and 7 deletions

View File

@ -83,6 +83,17 @@ class OSGVIEWER_EXPORT PixelBufferX11 : public osg::GraphicsContext, public osgV
bool _realized; bool _realized;
bool _useGLX1_3; bool _useGLX1_3;
bool _useSGIX;
typedef Pbuffer ( *GLXCreateGLXPbufferSGIX_FuncPtr) (Display *dpy, GLXFBConfig config, unsigned int, unsigned height, int* attrib_list);
typedef void ( *GLXDestroyGLXPbufferSGIX_FuncPtr) (Display *dpy, Pbuffer pbuf);
typedef int ( *GLXQueryGLXPbufferSGIX_FuncCPtr) (Display *dpy, Pbuffer pbuf, int attribute, unsigned int *value);
typedef GLXFBConfig ( *GLXGetFBConfigFromVisualSGIX_FuncPtr) (Display *dpy, XVisualInfo *vis);
GLXCreateGLXPbufferSGIX_FuncPtr _glXCreateGLXPbufferSGIX;
GLXDestroyGLXPbufferSGIX_FuncPtr _glXDestroyGLXPbufferSGIX;
GLXQueryGLXPbufferSGIX_FuncCPtr _glXQueryGLXPbufferSGIX;
GLXGetFBConfigFromVisualSGIX_FuncPtr _glXGetFBConfigFromVisualSGIX;
}; };
} }

View File

@ -32,7 +32,12 @@ PixelBufferX11::PixelBufferX11(osg::GraphicsContext::Traits* traits)
_visualInfo(0), _visualInfo(0),
_initialized(false), _initialized(false),
_realized(false), _realized(false),
_useGLX1_3(false) _useGLX1_3(false),
_useSGIX(false),
_glXCreateGLXPbufferSGIX(NULL),
_glXDestroyGLXPbufferSGIX(NULL),
_glXQueryGLXPbufferSGIX(NULL),
_glXGetFBConfigFromVisualSGIX(NULL)
{ {
_traits = traits; _traits = traits;
@ -181,6 +186,20 @@ void PixelBufferX11::init()
const char *extensions = glXQueryExtensionsString(_display, screen); const char *extensions = glXQueryExtensionsString(_display, screen);
haveSGIX_pbuffer = osg::isExtensionInExtensionString("GLX_SGIX_pbuffer", extensions) haveSGIX_pbuffer = osg::isExtensionInExtensionString("GLX_SGIX_pbuffer", extensions)
&& osg::isExtensionInExtensionString("GLX_SGIX_fbconfig", extensions); && osg::isExtensionInExtensionString("GLX_SGIX_fbconfig", extensions);
if (haveSGIX_pbuffer)
{
osg::setGLExtensionFuncPtr(_glXCreateGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
osg::setGLExtensionFuncPtr(_glXDestroyGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
osg::setGLExtensionFuncPtr(_glXQueryGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
osg::setGLExtensionFuncPtr(_glXGetFBConfigFromVisualSGIX, "glXGetFBConfigFromVisualSGIX");
if (_glXCreateGLXPbufferSGIX == NULL ||
_glXDestroyGLXPbufferSGIX == NULL ||
_glXQueryGLXPbufferSGIX == NULL ||
_glXGetFBConfigFromVisualSGIX == NULL) {
haveSGIX_pbuffer = false;
}
}
} }
#endif #endif
@ -283,7 +302,7 @@ void PixelBufferX11::init()
// If we still have no pbuffer but a capable display with the SGIX extension, try to use that // If we still have no pbuffer but a capable display with the SGIX extension, try to use that
if (!_pbuffer && haveSGIX_pbuffer) if (!_pbuffer && haveSGIX_pbuffer)
{ {
GLXFBConfigSGIX fbconfig = glXGetFBConfigFromVisualSGIX( _display, _visualInfo ); GLXFBConfigSGIX fbconfig = _glXGetFBConfigFromVisualSGIX( _display, _visualInfo );
typedef std::vector <int> AttributeList; typedef std::vector <int> AttributeList;
AttributeList attributes; AttributeList attributes;
@ -291,13 +310,14 @@ void PixelBufferX11::init()
attributes.push_back( GL_TRUE ); attributes.push_back( GL_TRUE );
attributes.push_back( 0L ); attributes.push_back( 0L );
_pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, &attributes.front() ); _pbuffer = _glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, &attributes.front() );
if (_pbuffer) if (_pbuffer)
{ {
_useSGIX = true;
int iWidth = 0; int iWidth = 0;
int iHeight = 0; int iHeight = 0;
glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_WIDTH_SGIX , (unsigned int *)&iWidth); _glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_WIDTH_SGIX , (unsigned int *)&iWidth);
glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_HEIGHT_SGIX, (unsigned int *)&iHeight); _glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_HEIGHT_SGIX, (unsigned int *)&iHeight);
if (_traits->width != iWidth || _traits->height != iHeight) if (_traits->width != iWidth || _traits->height != iHeight)
{ {
@ -351,7 +371,10 @@ void PixelBufferX11::closeImplementation()
else else
{ {
#ifdef GLX_SGIX_pbuffer #ifdef GLX_SGIX_pbuffer
glXDestroyGLXPbufferSGIX(_display, _pbuffer); if (_useSGIX)
{
_glXDestroyGLXPbufferSGIX(_display, _pbuffer);
}
#endif #endif
} }
} }