From 669d9a89ca438e3b4a092c6f9d928fe16f371572 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 5 Sep 2005 09:02:56 +0000 Subject: [PATCH] =?utf8?q?Mathias=20Fr=F6hlich:?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit just a few split out patches from my zoo of local work ... The patch to simgear-glxproc.diff changes dlopen to not open a specific library. If it is used with a NULL argument, we just get a handle to the current running binary including all loaded libraries. This has the advantage that we do not rely on the name of libGL on the specific platform. Also a user can link with his own different named libGL or with a static libGL.a Then the render texture again ... glxQueryVersion turns out to return the minimum of the client libraries glx version and the servers glx version. *All* Xorg servers return 1.2 here. So we never get the glxPBuffer functions which are the only ones working with ati's drivers ... Reverted back to checking the required functions and just use them if they are there. Still prefering the glx standard variants since they work on ati's drivers ... --- simgear/screen/RenderTexture.cpp | 48 ++++++++++---------------------- simgear/screen/extensions.cxx | 11 +++++--- 2 files changed, 22 insertions(+), 37 deletions(-) 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; - - 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; - } + // 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"); + + 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); -- 2.39.5