From: Alexandros Frantzis alexandros.frantzis@collabora.com
--- configure | 92 ++++++++++++++++++++++++++++++++++- configure.ac | 4 +- dlls/winewayland.drv/opengl.c | 36 +++++++++++++- include/config.h.in | 3 ++ 4 files changed, 132 insertions(+), 3 deletions(-)
diff --git a/configure b/configure index a96f0172579..ada319c6f20 100755 --- a/configure +++ b/configure @@ -702,6 +702,7 @@ INOTIFY_LIBS INOTIFY_CFLAGS PCSCLITE_LIBS PCAP_LIBS +OPENGL_CFLAGS EGL_LIBS EGL_CFLAGS XKBREGISTRY_LIBS @@ -1807,6 +1808,8 @@ XKBREGISTRY_CFLAGS XKBREGISTRY_LIBS EGL_CFLAGS EGL_LIBS +OPENGL_CFLAGS +OPENGL_LIBS INOTIFY_CFLAGS INOTIFY_LIBS DBUS_CFLAGS @@ -2635,6 +2638,9 @@ Some influential environment variables: Linker flags for xkbregistry, overriding pkg-config EGL_CFLAGS C compiler flags for egl, overriding pkg-config EGL_LIBS Linker flags for egl, overriding pkg-config + OPENGL_CFLAGS + C compiler flags for OpenGL, overriding pkg-config + OPENGL_LIBS Linker flags for OpenGL, overriding pkg-config INOTIFY_CFLAGS C compiler flags for libinotify, overriding pkg-config INOTIFY_LIBS @@ -16231,11 +16237,94 @@ printf "%s\n" "#define SONAME_LIBEGL "$ac_cv_lib_soname_EGL"" >>confdefs.h fi fi
+CPPFLAGS=$ac_save_CPPFLAGS + + rm -f conftest.err +if ${OPENGL_CFLAGS:+false} : +then : + if test ${PKG_CONFIG+y} +then : + OPENGL_CFLAGS=`$PKG_CONFIG --cflags OpenGL 2>conftest.err` +fi +fi + +if ${OPENGL_LIBS:+false} : +then : + if test ${PKG_CONFIG+y} +then : + OPENGL_LIBS=`$PKG_CONFIG --libs OpenGL 2>/dev/null` +fi +fi + +OPENGL_LIBS=${OPENGL_LIBS:-"-lOpenGL"} +printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenGL cflags: $OPENGL_CFLAGS" >&5 +printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenGL libs: $OPENGL_LIBS" >&5 +if test -s conftest.err; then + printf %s "$as_me:${as_lineno-$LINENO}: OpenGL errors: " >&5 + cat conftest.err >&5 +fi +rm -f conftest.err +ac_save_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $OPENGL_CFLAGS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -lOpenGL" >&5 +printf %s "checking for -lOpenGL... " >&6; } +if test ${ac_cv_lib_soname_OpenGL+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_soname_save_LIBS=$LIBS +LIBS="-lOpenGL $OPENGL_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char glFlush (); +int +main (void) +{ +return glFlush (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + case "$LIBEXT" in + dll) ac_cv_lib_soname_OpenGL=`$ac_cv_path_LDD conftest.exe | grep "OpenGL" | sed -e "s/dll.*/dll/"';2,$d'` ;; + dylib) ac_cv_lib_soname_OpenGL=`$OTOOL -L conftest$ac_exeext | grep "libOpenGL\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*/(libOpenGL.[0-9A-Za-z.]*dylib).*$/\1/"';2,$d'` ;; + *) ac_cv_lib_soname_OpenGL=`$READELF -d conftest$ac_exeext | grep "NEEDED.*libOpenGL\.$LIBEXT" | sed -e "s/^.*\[\(libOpenGL\.$LIBEXT[^ ]*\)\].*$/\1/"';2,$d'` + if ${ac_cv_lib_soname_OpenGL:+false} : +then : + ac_cv_lib_soname_OpenGL=`$LDD conftest$ac_exeext | grep "libOpenGL\.$LIBEXT" | sed -e "s/^.*(libOpenGL.$LIBEXT[^ ]*).*$/\1/"';2,$d'` +fi ;; + esac +else $as_nop + ac_cv_lib_soname_OpenGL= +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_soname_save_LIBS +fi +if ${ac_cv_lib_soname_OpenGL:+false} : +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +printf "%s\n" "not found" >&6; } + +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_soname_OpenGL" >&5 +printf "%s\n" "$ac_cv_lib_soname_OpenGL" >&6; } + +printf "%s\n" "#define SONAME_LIBOPENGL "$ac_cv_lib_soname_OpenGL"" >>confdefs.h + + +fi CPPFLAGS=$ac_save_CPPFLAGS
if test "x$with_wayland" != "x" then - if test -z "$SONAME_LIBEGL" + if test -z "$SONAME_LIBEGL" -o -z "$SONAME_LIBOPENGL" then : case "x$with_opengl" in x) as_fn_append wine_notices "|Wayland EGL/GL ${notice_platform}development files not found, the Wayland driver won't support OpenGL" ;; @@ -23850,6 +23939,7 @@ XKBREGISTRY_CFLAGS = $XKBREGISTRY_CFLAGS XKBREGISTRY_LIBS = $XKBREGISTRY_LIBS EGL_CFLAGS = $EGL_CFLAGS EGL_LIBS = $EGL_LIBS +OPENGL_CFLAGS = $OPENGL_CFLAGS PCAP_LIBS = $PCAP_LIBS PCSCLITE_LIBS = $PCSCLITE_LIBS INOTIFY_CFLAGS = $INOTIFY_CFLAGS diff --git a/configure.ac b/configure.ac index 9af42badc31..69e9f1675c3 100644 --- a/configure.ac +++ b/configure.ac @@ -1382,9 +1382,11 @@ then WINE_PACKAGE_FLAGS(EGL,[egl],[-lEGL],,, [AC_CHECK_HEADER([EGL/egl.h], [WINE_CHECK_SONAME(EGL,eglGetProcAddress,,,[$EGL_LIBS])])]) + WINE_PACKAGE_FLAGS(OPENGL,[OpenGL],[-lOpenGL],,, + [WINE_CHECK_SONAME(OpenGL,glFlush,,,[$OPENGL_LIBS])]) if test "x$with_wayland" != "x" then - WINE_NOTICE_WITH(opengl, [test -z "$SONAME_LIBEGL"], + WINE_NOTICE_WITH(opengl, [test -z "$SONAME_LIBEGL" -o -z "$SONAME_LIBOPENGL"], [Wayland EGL/GL ${notice_platform}development files not found, the Wayland driver won't support OpenGL]) fi fi diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 54ae281c86a..86d48428d6e 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -29,7 +29,7 @@ #include "waylanddrv.h" #include "wine/debug.h"
-#if defined(SONAME_LIBEGL) +#if defined(SONAME_LIBEGL) && defined(SONAME_LIBOPENGL)
WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
@@ -39,10 +39,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv); #include "wine/wgl_driver.h"
static void *egl_handle; +static void *opengl_handle; static struct opengl_funcs opengl_funcs; static EGLDisplay egl_display; static EGLint egl_version[2];
+#define USE_GL_FUNC(name) #name, +static const char *opengl_func_names[] = { ALL_WGL_FUNCS }; +#undef USE_GL_FUNC + #define DECL_FUNCPTR(f) static __typeof__(f) * p_##f = NULL DECL_FUNCPTR(eglGetDisplay); DECL_FUNCPTR(eglGetError); @@ -57,6 +62,22 @@ static void* load_symbol(void *handle, const char *symbol) return addr; }
+static BOOL init_opengl_funcs(void) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(opengl_func_names); i++) + { + if (!(((void **)&opengl_funcs.gl)[i] = load_symbol(opengl_handle, opengl_func_names[i]))) + { + ERR("%s not found, disabling OpenGL.\n", opengl_func_names[i]); + return FALSE; + } + } + + return TRUE; +} + static void init_opengl(void) { if (!(egl_handle = dlopen(SONAME_LIBEGL, RTLD_NOW|RTLD_GLOBAL))) @@ -65,6 +86,12 @@ static void init_opengl(void) goto err; }
+ if (!(opengl_handle = dlopen(SONAME_LIBOPENGL, RTLD_NOW|RTLD_GLOBAL))) + { + ERR("Failed to load %s: %s\n", SONAME_LIBOPENGL, dlerror()); + goto err; + } + if (!(p_eglGetProcAddress = dlsym(egl_handle, "eglGetProcAddress"))) { ERR("Failed to load eglGetProcAddress\n"); @@ -94,6 +121,8 @@ static void init_opengl(void) } TRACE("EGL version %u.%u\n", egl_version[0], egl_version[1]);
+ if (!init_opengl_funcs()) goto err; + return;
err: @@ -102,6 +131,11 @@ err: dlclose(egl_handle); egl_handle = NULL; } + if (opengl_handle) + { + dlclose(opengl_handle); + opengl_handle = NULL; + } }
static BOOL has_opengl(void) diff --git a/include/config.h.in b/include/config.h.in index a910b2c85f1..5888781d1a0 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -759,6 +759,9 @@ /* Define to the soname of the libodbc library. */ #undef SONAME_LIBODBC
+/* Define to the soname of the libOpenGL library. */ +#undef SONAME_LIBOPENGL + /* Define to the soname of the libOSMesa library. */ #undef SONAME_LIBOSMESA