[PATCH] Workarounds for glXGetProcAddress quirks

Some people using the Nvidia binary driver on their systems are having
trouble with linking against libGL since glXGetProcAddress is not
defined. These systems seem to often have the Mesa GL headers
installed, so I can't detect this problem at compile time. Apparently
glXGetProcAddressARB is part of the Linux OpenGL ABI, so it should be
safe to always use that.

I've implemented this as a workaround in the Makefile in the hope that
the situation will resolve itself in the various libGL implementations
eventually and I'll be able to just use the headers reliably. If I
really have to make it a portable binary, I'll just have to do some
dlopen magic in the future.

diff -urN b/NQ/Makefile head/NQ/Makefile
--- b/NQ/Makefile	2004-07-25 15:59:54.000000000 +0930
+++ head/NQ/Makefile	2005-11-27 22:41:44.000000000 +1030
@@ -18,6 +18,11 @@
 %.o:	../common/%.c
 	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $^
 
+# A special rule for the glx file due to compatibility problems
+# with the Nvidia's libGL.so
+#gl_vidlinuxglx.o:	../common/gl_vidlinuxglx.c
+#	$(CC) -c $(CPPFLAGS) $(CFLAGS) -DglXGetProcAddress=glXGetProcAddressARB -o $@ $^
+
 # Rule to make the resource file
 %.res:	%.rc
 	windres -i $^ -O coff -o $@
diff -urN b/common/gl_vidlinuxglx.c head/common/gl_vidlinuxglx.c
--- b/common/gl_vidlinuxglx.c	2005-01-08 23:32:26.000000000 +1030
+++ head/common/gl_vidlinuxglx.c	2005-12-11 22:09:07.000000000 +1030
@@ -27,11 +27,6 @@
 
 #include <GL/glx.h>
 
-/* Compatibility with older GLX headers */
-#ifndef GLX_VERSION_1_4
-#define glXGetProcAddress glXGetProcAddressARB
-#endif
-
 #include <X11/keysym.h>
 #include <X11/cursorfont.h>
 #include <X11/extensions/xf86vmode.h>
@@ -53,6 +48,10 @@
 #include "x11_core.h"
 #include "in_x11.h"
 
+#if !defined(GLX_VERSION_1_4) && !defined(glXGetProcAddress)
+#define glXGetProcAddress glXGetProcAddressARB
+#endif
+
 #define WARP_WIDTH              320
 #define WARP_HEIGHT             200
 
