diff --git a/simgear/screen/RenderTexture.cpp b/simgear/screen/RenderTexture.cpp index 5a59bb9f..53f5e3d2 100644 --- a/simgear/screen/RenderTexture.cpp +++ b/simgear/screen/RenderTexture.cpp @@ -1821,29 +1821,21 @@ bool RenderTexture::_VerifyExtensions() #elif defined( __APPLE__ ) #else - int minor, major; - _pDisplay = glXGetCurrentDisplay(); - if (!glXQueryVersion(_pDisplay, &major, &minor)) - return false; + // First try the glX version 1.3 functions. + glXChooseFBConfigPtr = (glXChooseFBConfigProc)SGLookupFunction("glXChooseFBConfig"); + glXCreateGLXPbufferPtr = (glXCreateGLXPbufferProc)SGLookupFunction("glXCreatePbuffer"); + glXGetVisualFromFBConfigPtr = (glXGetVisualFromFBConfigProc)SGLookupFunction("glXGetVisualFromFBConfig"); + glXCreateContextPtr = (glXCreateContextProc)SGLookupFunction("glXCreateContext"); + glXDestroyPbufferPtr = (glXDestroyPbufferProc)SGLookupFunction("glXDestroyPbuffer"); + glXQueryDrawablePtr = (glXQueryDrawableProc)SGLookupFunction("glXQueryDrawable"); - glXVersion1_3Present = major >= 1 && minor >= 3; - if (glXVersion1_3Present) - { - glXChooseFBConfigPtr = (glXChooseFBConfigProc)SGLookupFunction("glXChooseFBConfig"); - glXCreateGLXPbufferPtr = (glXCreateGLXPbufferProc)SGLookupFunction("glXCreatePbuffer"); - glXGetVisualFromFBConfigPtr = (glXGetVisualFromFBConfigProc)SGLookupFunction("glXGetVisualFromFBConfig"); - glXCreateContextPtr = (glXCreateContextProc)SGLookupFunction("glXCreateContext"); - glXDestroyPbufferPtr = (glXDestroyPbufferProc)SGLookupFunction("glXDestroyPbuffer"); - glXQueryDrawablePtr = (glXQueryDrawableProc)SGLookupFunction("glXQueryDrawable"); - - if (!glXChooseFBConfigPtr || - !glXCreateGLXPbufferPtr || - !glXGetVisualFromFBConfigPtr || - !glXCreateContextPtr || - !glXDestroyPbufferPtr || - !glXQueryDrawablePtr) - return false; - } + if (glXChooseFBConfigPtr && + glXCreateGLXPbufferPtr && + glXGetVisualFromFBConfigPtr && + glXCreateContextPtr && + glXDestroyPbufferPtr && + glXQueryDrawablePtr) + glXVersion1_3Present = true; else { glXChooseFBConfigPtr = (glXChooseFBConfigProc)SGLookupFunction("glXChooseFBConfigSGIX"); @@ -1863,16 +1855,6 @@ bool RenderTexture::_VerifyExtensions() return false; } -// if (!GLX_SGIX_pbuffer) -// { -// PrintExtensionError("GL_SGIX_pbuffer"); -// return false; -// } -// if (!GLX_SGIX_fbconfig) -// { -// PrintExtensionError("GLX_SGIX_fbconfig"); -// return false; -// } if (_bIsDepthTexture && !GL_ARB_depth_texture) { PrintExtensionError("GL_ARB_depth_texture"); diff --git a/simgear/screen/extensions.cxx b/simgear/screen/extensions.cxx index 9a6de53b..a317bda4 100644 --- a/simgear/screen/extensions.cxx +++ b/simgear/screen/extensions.cxx @@ -107,11 +107,14 @@ void *SGGetGLProcAddress(const char *func) { */ dlerror(); + /* + * Since libGL must be linked to the binary we run on, this is the + * right handle. That 'current binary' handle also avoids conflicts which + * arise from linking with a different libGL at link time an than later + * use the standard libGL at runtime ... + */ if (libHandle == NULL) - libHandle = dlopen("libGL.so", RTLD_LAZY); - - if (libHandle == NULL) - libHandle = dlopen("libGL.so.1", RTLD_LAZY); + libHandle = dlopen(NULL, RTLD_LAZY); if (libHandle != NULL) { fptr = dlsym(libHandle, func);