Better detection of OpenGL.

diff --git a/configure.in b/configure.in
index 28cefc4..f63f0f9 100644
--- a/configure.in
+++ b/configure.in
@@ -135,8 +135,8 @@
     fi
 
     dnl Check for the presence of Mesa
-    AC_CHECK_HEADERS(GL/gl.h GL/osmesa.h)
-    if test "$ac_cv_header_GL_gl_h" = "yes" -a "$ac_cv_header_GL_osmesa_h" = "yes"
+    AC_CHECK_HEADERS(GL/gl.h GL/glx.h GL/osmesa.h)
+    if test "$ac_cv_header_GL_gl_h" = "yes" -a "$ac_cv_header_GL_glx_h" = "yes"
     then
         dnl Check for some problems due to old Mesa versions
         AC_CACHE_CHECK("for up-to-date Mesa version", wine_cv_mesa_version_OK,
@@ -151,7 +151,11 @@
         if test "$wine_cv_mesa_version_OK" = "yes"
         then
 	    dnl Check for the presense of the library
-            AC_CHECK_LIB(MesaGL,OSMesaCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lMesaGL",,$X_LIBS -lXext -lX11 -lm)
+            AC_CHECK_LIB(GL,glXCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lGL",,$X_LIBS -lXext -lX11 -lm)
+	    if test "$ac_cv_lib_GL_glXCreateContext" = "no"
+	    then
+		AC_CHECK_LIB(MesaGL,glXCreateContext,AC_DEFINE(HAVE_LIBMESAGL) X_PRE_LIBS="$X_PRE_LIBS -lGL",,$X_LIBS -lXext -lX11 -lm)
+	    fi
         fi
     fi