Added preliminary handling of cases where GLX version < 1.3
This commit is contained in:
parent
23945bb506
commit
45e98d5f18
@ -27,6 +27,11 @@
|
||||
#include <X11/X.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
#ifndef GLX_VERSION_1_3
|
||||
typedef XID GLXPbuffer;
|
||||
#endif
|
||||
|
||||
|
||||
namespace osgViewer
|
||||
{
|
||||
|
||||
@ -34,37 +39,7 @@ class OSGVIEWER_EXPORT PixelBufferX11 : public osg::GraphicsContext
|
||||
{
|
||||
public:
|
||||
|
||||
PixelBufferX11(osg::GraphicsContext::Traits* traits):
|
||||
_valid(false),
|
||||
_display(0),
|
||||
_parent(0),
|
||||
_pbuffer(0),
|
||||
_visualInfo(0),
|
||||
_glxContext(0),
|
||||
_initialized(false),
|
||||
_realized(false)
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
init();
|
||||
|
||||
if (valid())
|
||||
{
|
||||
setState( new osg::State );
|
||||
getState()->setGraphicsContext(this);
|
||||
|
||||
if (_traits.valid() && _traits->sharedContext)
|
||||
{
|
||||
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
PixelBufferX11(osg::GraphicsContext::Traits* traits);
|
||||
|
||||
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const PixelBufferX11*>(object)!=0; }
|
||||
virtual const char* libraryName() const { return "osgViewer"; }
|
||||
|
@ -516,7 +516,7 @@ void GraphicsWindowX11::init()
|
||||
else
|
||||
{
|
||||
PixelBufferX11* pixelBufferX11 = dynamic_cast<PixelBufferX11*>(_traits->sharedContext);
|
||||
if (pixelBufferX11)
|
||||
if (pixelBufferX11 && pixelBufferX11->valid())
|
||||
{
|
||||
sharedContextGLX = pixelBufferX11->getGLXContext();
|
||||
}
|
||||
|
@ -25,9 +25,10 @@
|
||||
|
||||
using namespace osgViewer;
|
||||
|
||||
#ifdef GLX_VERSION_1_3
|
||||
static GLXFBConfig getFBConfigFromVisual(::Display* dpy, XVisualInfo* visualInfo)
|
||||
{
|
||||
#if defined(__APPLE__) || defined(_AIX)
|
||||
#if defined(__APPLE__) || defined(_AIX) || defined(__hpux)
|
||||
int screen = visualInfo->screen;
|
||||
int nelements;
|
||||
GLXFBConfig *configs = glXGetFBConfigs(dpy, screen, &nelements);
|
||||
@ -45,12 +46,46 @@ static GLXFBConfig getFBConfigFromVisual(::Display* dpy, XVisualInfo* visualInfo
|
||||
return glXGetFBConfigFromVisualSGIX( dpy, visualInfo );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
PixelBufferX11::PixelBufferX11(osg::GraphicsContext::Traits* traits)
|
||||
: _valid(false),
|
||||
_display(0),
|
||||
_parent(0),
|
||||
_pbuffer(0),
|
||||
_visualInfo(0),
|
||||
_glxContext(0),
|
||||
_initialized(false),
|
||||
_realized(false)
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
init();
|
||||
|
||||
if (valid())
|
||||
{
|
||||
setState( new osg::State );
|
||||
getState()->setGraphicsContext(this);
|
||||
|
||||
if (_traits.valid() && _traits->sharedContext)
|
||||
{
|
||||
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
getState()->setContextID( osg::GraphicsContext::createNewContextID() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
PixelBufferX11::~PixelBufferX11()
|
||||
{
|
||||
close(true);
|
||||
}
|
||||
|
||||
#ifdef GLX_VERSION_1_3
|
||||
bool PixelBufferX11::createVisualInfo()
|
||||
{
|
||||
typedef std::vector<int> Attributes;
|
||||
@ -93,8 +128,6 @@ void PixelBufferX11::init()
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
#ifdef GLX_VERSION_1_3
|
||||
|
||||
if (!_traits)
|
||||
{
|
||||
_valid = false;
|
||||
@ -232,13 +265,23 @@ void PixelBufferX11::init()
|
||||
|
||||
_valid = true;
|
||||
_initialized = true;
|
||||
#else
|
||||
_valid = false;
|
||||
_initialized = true;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// fallback for non GLX1.3 versions where pbuffers are not supported.
|
||||
// note, this makes the rest of the pbuffer code a non op as init is false;
|
||||
bool PixelBufferX11::createVisualInfo()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void PixelBufferX11::init()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool PixelBufferX11::realizeImplementation()
|
||||
{
|
||||
if (_realized)
|
||||
@ -310,9 +353,7 @@ void PixelBufferX11::closeImplementation()
|
||||
|
||||
if (_pbuffer)
|
||||
{
|
||||
#ifdef GLX_VERSION_1_3
|
||||
glXDestroyPbuffer(_display, _pbuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
XFlush( _display );
|
||||
@ -347,5 +388,5 @@ void PixelBufferX11::swapBuffersImplementation()
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"PixelBufferX11::swapBuffersImplementation "<<this<<" "<<OpenThreads::Thread::CurrentThread()<<std::endl;
|
||||
|
||||
glXSwapBuffers(_display, _pbuffer);
|
||||
glXSwapBuffers(_display, _pbuffer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user