Specify the full filename when g_module_open'ing the GL library

Instead of using g_module_build_path with the short name of the GL
library (eg, "GL") and relying on glib to add the suffix and prefix,
the configure script now directly encodes the full name including the
version number (eg, "libGL.so.1"). This is necessary because distros
don't always install the non-versioned suffix for the library.

The GLES libraries are left without the version suffix because it's
not clear what should be placed here and I can't find any
documentation from Khronos to clarify this. Mesa seems to install a
file called libGLESv2.so.2 but the IMG SDK doesn't install any
versioned library. There is an example of dynamically loading
libGLESv2 in the Chromium source code and that does not use the
version suffix even though it does use the version suffix for GL. This
implies that it's at least fairly normal to load the unversioned name
for GLES.

https://bugzilla.gnome.org/show_bug.cgi?id=654593
This commit is contained in:
Neil Roberts 2011-07-18 18:07:06 +01:00
parent eb578e4e0c
commit 03c4b20931
3 changed files with 8 additions and 22 deletions

View File

@ -177,9 +177,6 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
{ {
const char *driver_name = g_getenv ("COGL_DRIVER"); const char *driver_name = g_getenv ("COGL_DRIVER");
const char *libgl_name; const char *libgl_name;
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
char *libgl_module_path;
#endif
#ifdef HAVE_COGL_GL #ifdef HAVE_COGL_GL
if (driver_name == NULL || !strcmp (driver_name, "gl")) if (driver_name == NULL || !strcmp (driver_name, "gl"))
@ -218,14 +215,9 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY #ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
libgl_module_path = g_module_build_path (NULL, /* standard lib search path */ renderer->libgl_module = g_module_open (libgl_name,
libgl_name);
renderer->libgl_module = g_module_open (libgl_module_path,
G_MODULE_BIND_LAZY); G_MODULE_BIND_LAZY);
g_free (libgl_module_path);
if (renderer->libgl_module == NULL) if (renderer->libgl_module == NULL)
{ {
g_set_error (error, COGL_DRIVER_ERROR, g_set_error (error, COGL_DRIVER_ERROR,

View File

@ -333,7 +333,6 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
{ {
CoglGLXRenderer *glx_renderer; CoglGLXRenderer *glx_renderer;
CoglXlibRenderer *xlib_renderer; CoglXlibRenderer *xlib_renderer;
char *libgl_module_path;
renderer->winsys = g_slice_new0 (CoglGLXRenderer); renderer->winsys = g_slice_new0 (CoglGLXRenderer);
@ -343,14 +342,9 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
if (!_cogl_xlib_renderer_connect (renderer, error)) if (!_cogl_xlib_renderer_connect (renderer, error))
goto error; goto error;
libgl_module_path = g_module_build_path (NULL, /* standard lib search path */ glx_renderer->libgl_module = g_module_open (COGL_GL_LIBNAME,
COGL_GL_LIBNAME);
glx_renderer->libgl_module = g_module_open (libgl_module_path,
G_MODULE_BIND_LAZY); G_MODULE_BIND_LAZY);
g_free (libgl_module_path);
if (glx_renderer->libgl_module == NULL) if (glx_renderer->libgl_module == NULL)
{ {
g_set_error (error, COGL_WINSYS_ERROR, g_set_error (error, COGL_WINSYS_ERROR,

View File

@ -387,7 +387,7 @@ AS_IF([test "x$enable_gles1" = "xyes"],
PKG_CHECK_EXISTS([glesv1_cm], PKG_CHECK_EXISTS([glesv1_cm],
[COGL_PKG_REQUIRES_GL="$COGL_PKG_REQUIRES_GL glesv1_cm" [COGL_PKG_REQUIRES_GL="$COGL_PKG_REQUIRES_GL glesv1_cm"
COGL_GLES1_LIBNAME="GLESv1_CM" COGL_GLES1_LIBNAME="libGLESv1_CM.so"
NEED_EGL=yes NEED_EGL=yes
], ],
[ [
@ -430,10 +430,10 @@ AS_IF([test "x$enable_gles1" = "xyes"],
# bundles the GLES and EGL API together and -lGLESv1_CM # bundles the GLES and EGL API together and -lGLESv1_CM
# would be used for a standalone GLES API. # would be used for a standalone GLES API.
AC_CHECK_LIB(GLES_CM, [eglInitialize], AC_CHECK_LIB(GLES_CM, [eglInitialize],
[COGL_GLES1_LIBNAME="GLES_CM"], [COGL_GLES1_LIBNAME="libGLES_CM.so"],
[ [
AC_CHECK_LIB(GLESv1_CM, [glFlush], AC_CHECK_LIB(GLESv1_CM, [glFlush],
[COGL_GLES1_LIBNAME="GLESv1_CM" [COGL_GLES1_LIBNAME="libGLESv1_CM.so"
NEED_SEPARATE_EGL=yes NEED_SEPARATE_EGL=yes
], ],
[AC_MSG_ERROR([Unable to locate required GLES 1.x Common Profile library])]) [AC_MSG_ERROR([Unable to locate required GLES 1.x Common Profile library])])
@ -463,7 +463,7 @@ AS_IF([test "x$enable_gles2" = "xyes"],
PKG_CHECK_EXISTS([glesv2], PKG_CHECK_EXISTS([glesv2],
[COGL_PKG_REQUIRES_GL="$COGL_PKG_REQUIRES_GL glesv2" [COGL_PKG_REQUIRES_GL="$COGL_PKG_REQUIRES_GL glesv2"
COGL_GLES2_LIBNAME="GLESv2" COGL_GLES2_LIBNAME="libGLESv2.so"
], ],
[ [
# We have to check the two headers independently as GLES2/gl2ext.h # We have to check the two headers independently as GLES2/gl2ext.h
@ -477,7 +477,7 @@ AS_IF([test "x$enable_gles2" = "xyes"],
[AC_MSG_ERROR([Unable to locate GLES2/gl2ext.h])], [AC_MSG_ERROR([Unable to locate GLES2/gl2ext.h])],
[#include <GLES2/gl2.h>]) [#include <GLES2/gl2.h>])
COGL_GLES2_LIBNAME="GLESv2" COGL_GLES2_LIBNAME="libGLESv2.so"
]) ])
NEED_EGL=yes NEED_EGL=yes
@ -527,7 +527,7 @@ AS_IF([test "x$enable_gl" = "xyes"],
, ,
[AC_MSG_ERROR([Unable to locate required GL library])]) [AC_MSG_ERROR([Unable to locate required GL library])])
]) ])
COGL_GL_LIBNAME="GL" COGL_GL_LIBNAME="libGL.so.1"
]) ])
AC_DEFINE([HAVE_COGL_GL], [1], [Have GL for rendering]) AC_DEFINE([HAVE_COGL_GL], [1], [Have GL for rendering])