changeset 31024:0e862bb517b0

Try harder to find linked OpenGL functions.
author reimar
date Sat, 24 Apr 2010 17:02:50 +0000
parents 769929c96d44
children f3897eb85625
files libvo/gl_common.c
diffstat 1 files changed, 22 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/gl_common.c	Sat Apr 24 16:58:24 2010 +0000
+++ b/libvo/gl_common.c	Sat Apr 24 17:02:50 2010 +0000
@@ -349,8 +349,24 @@
   return supported;
 }
 
-static void *setNull(const GLubyte *s) {
-  return NULL;
+#ifdef HAVE_LIBDL
+#include <dlfcn.h>
+#endif
+/**
+ * \brief find address of a linked function
+ * \param s name of function to find
+ * \return address of function or NULL if not found
+ */
+static void *getdladdr(const char *s) {
+  void *ret = NULL;
+#ifdef HAVE_LIBDL
+  void *handle = dlopen(NULL, RTLD_LAZY);
+  if (!handle)
+    return NULL;
+  ret = dlsym(handle, s);
+  dlclose(handle);
+#endif
+  return ret;
 }
 
 typedef struct {
@@ -460,7 +476,7 @@
   char *allexts;
 
   if (!getProcAddress)
-    getProcAddress = setNull;
+    getProcAddress = (void *)getdladdr;
 
   // special case, we need glGetString before starting to find the other functions
   mpglGetString = getProcAddress("glGetString");
@@ -1670,26 +1686,7 @@
 }
 #endif
 #ifdef CONFIG_GL_X11
-#ifdef HAVE_LIBDL
-#include <dlfcn.h>
-#endif
 #include "x11_common.h"
-/**
- * \brief find address of a linked function
- * \param s name of function to find
- * \return address of function or NULL if not found
- */
-static void *getdladdr(const char *s) {
-  void *ret = NULL;
-#ifdef HAVE_LIBDL
-  void *handle = dlopen(NULL, RTLD_LAZY);
-  if (!handle)
-    return NULL;
-  ret = dlsym(handle, s);
-  dlclose(handle);
-#endif
-  return ret;
-}
 
 /**
  * \brief Returns the XVisualInfo associated with Window win.
@@ -1789,8 +1786,6 @@
     getProcAddress = getdladdr("glXGetProcAddress");
     if (!getProcAddress)
       getProcAddress = getdladdr("glXGetProcAddressARB");
-    if (!getProcAddress)
-      getProcAddress = (void *)getdladdr;
     glXExtStr = getdladdr("glXQueryExtensionsString");
     if (glXExtStr)
         appendstr(&glxstr, glXExtStr(mDisplay, DefaultScreen(mDisplay)));
@@ -1803,10 +1798,10 @@
 
     getFunctions(getProcAddress, glxstr);
     if (!mpglGenPrograms && mpglGetString &&
-        getProcAddress != (void *)getdladdr &&
+        getProcAddress &&
         strstr(mpglGetString(GL_EXTENSIONS), "GL_ARB_vertex_program")) {
       mp_msg(MSGT_VO, MSGL_WARN, "Broken glXGetProcAddress detected, trying workaround\n");
-      getFunctions((void *)getdladdr, glxstr);
+      getFunctions(NULL, glxstr);
     }
     free(glxstr);
 
@@ -1858,7 +1853,7 @@
 #endif
 
 static int setGlWindow_dummy(MPGLContext *ctx) {
-  getFunctions(setNull, NULL);
+  getFunctions(NULL, NULL);
   return SET_WINDOW_OK;
 }