i965: Get a ralloc context into brw_compile.
[mesa.git] / src / mesa / drivers / x11 / glxapi.c
index 67649f403d29121d1879f6c524292490f3809e87..255a37bf295d928efcbeaa0bb851b89efbd7a30e 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: glxapi.c,v 1.21 2001/05/24 00:00:57 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  7.1
  * 
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -27,8 +25,8 @@
 
 /*
  * This is the GLX API dispatcher.  Calls to the glX* functions are
- * either routed to real (SGI / Utah) GLX encoders or to Mesa's
- * pseudo-GLX module.
+ * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
+ * See the glxapi.h file for more details.
  */
 
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-/*#include <dlfcn.h>*/ /* XXX not portable? */
-#include "glapi.h"
+#include "main/glheader.h"
+#include "main/compiler.h"
+#include "glapi/glapi.h"
 #include "glxapi.h"
 
 
-/*
- * XXX - this really shouldn't be here.
- * Instead, add -DUSE_MESA_GLX to the compiler flags when needed.
- */
-#define USE_MESA_GLX 1
-
-
-/* Rather than include possibly non-existant headers... */
-#ifdef USE_SGI_GLX
-extern struct _glxapi_table *_sgi_GetGLXDispatchTable(void);
-#endif
-#ifdef USE_UTAH_GLX
-extern struct _glxapi_table *_utah_GetGLXDispatchTable(void);
-#endif
-#ifdef USE_MESA_GLX
+extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
 extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
-#endif
-
 
 
 struct display_dispatch {
@@ -67,6 +50,36 @@ struct display_dispatch {
    struct display_dispatch *Next;
 };
 
+
+/**
+ * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
+ * libglapi.a.  We need to define them here.
+ */
+#ifdef GLX_INDIRECT_RENDERING
+
+#include "glapi/glapitable.h"
+
+#define KEYWORD1 PUBLIC
+
+#if defined(USE_MGL_NAMESPACE)
+#define NAME(func)  mgl##func
+#else
+#define NAME(func)  gl##func
+#endif
+
+#define DISPATCH(FUNC, ARGS, MESSAGE)          \
+   GET_DISPATCH()->FUNC ARGS
+
+#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE)   \
+   return GET_DISPATCH()->FUNC ARGS
+
+/* skip normal ones */
+#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
+#include "glapi/glapitemp.h"
+
+#endif /* GLX_INDIRECT_RENDERING */
+
+
 static struct display_dispatch *DispatchList = NULL;
 
 
@@ -94,32 +107,11 @@ get_dispatch(Display *dpy)
       }
    }
 
-   /* A new display, determine if we should use real GLX (SGI / Utah)
+   /* A new display, determine if we should use real GLX
     * or Mesa's pseudo-GLX.
     */
    {
-      struct _glxapi_table *t = NULL;
-
-#if defined(USE_SGI_GLX) || defined(USE_UTAH_GLX)
-      if (!getenv("MESA_FORCE_SOFTX")) {
-         int ignore;
-         if (XQueryExtension( dpy, "GLX", &ignore, &ignore, &ignore )) {
-            /* the X server has the GLX extension */
-#if defined(USE_SGI_GLX)
-            t = _sgi_GetGLXDispatchTable();
-#elif defined(USE_UTAH_GLX)
-            t = _utah_GetGLXDispatchTable();
-#endif
-         }
-      }
-#endif
-
-#if defined(USE_MESA_GLX)
-      if (!t) {
-         t = _mesa_GetGLXDispatchTable();
-         assert(t);  /* this has to work */
-      }
-#endif
+      struct _glxapi_table *t = _mesa_GetGLXDispatchTable();
 
       if (t) {
          struct display_dispatch *d;
@@ -146,6 +138,9 @@ get_dispatch(Display *dpy)
 }
 
 
+/* Don't use the GET_DISPATCH defined in glthread.h */
+#undef GET_DISPATCH
+
 #define GET_DISPATCH(DPY, TABLE)       \
    if (DPY == prevDisplay) {           \
       TABLE = prevTable;               \
@@ -160,20 +155,40 @@ get_dispatch(Display *dpy)
    
 
 
-/* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
-static Display *CurrentDisplay = NULL;
+/**
+ * GLX API current context.
+ */
+#if defined(GLX_USE_TLS)
+PUBLIC __thread void * CurrentContext
+    __attribute__((tls_model("initial-exec")));
+#elif defined(THREADS)
+static _glthread_TSD ContextTSD;         /**< Per-thread context pointer */
+#else
 static GLXContext CurrentContext = 0;
-static GLXDrawable CurrentDrawable = 0;
-static GLXDrawable CurrentReadDrawable = 0;
+#endif
+
 
+static void
+SetCurrentContext(GLXContext c)
+{
+#if defined(GLX_USE_TLS)
+   CurrentContext = c;
+#elif defined(THREADS)
+   _glthread_SetTSD(&ContextTSD, c);
+#else
+   CurrentContext = c;
+#endif
+}
 
 
 /*
  * GLX API entrypoints
  */
 
+/*** GLX_VERSION_1_0 ***/
 
-XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list)
+XVisualInfo PUBLIC *
+glXChooseVisual(Display *dpy, int screen, int *list)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -183,7 +198,8 @@ XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list)
 }
 
 
-void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
+void PUBLIC
+glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -193,7 +209,8 @@ void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long
 }
 
 
-GLXContext glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
+GLXContext PUBLIC
+glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -203,7 +220,8 @@ GLXContext glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext share
 }
 
 
-GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
+GLXPixmap PUBLIC
+glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -213,17 +231,21 @@ GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
 }
 
 
-void glXDestroyContext(Display *dpy, GLXContext ctx)
+void PUBLIC
+glXDestroyContext(Display *dpy, GLXContext ctx)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
    if (!t)
       return;
+   if (glXGetCurrentContext() == ctx)
+      SetCurrentContext(NULL);
    (t->DestroyContext)(dpy, ctx);
 }
 
 
-void glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
+void PUBLIC
+glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -233,7 +255,8 @@ void glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
 }
 
 
-int glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
+int PUBLIC
+glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -243,19 +266,29 @@ int glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
 }
 
 
-GLXContext glXGetCurrentContext(void)
+GLXContext PUBLIC
+glXGetCurrentContext(void)
 {
+#if defined(GLX_USE_TLS)
+   return CurrentContext;
+#elif defined(THREADS)
+   return (GLXContext) _glthread_GetTSD(&ContextTSD);
+#else
    return CurrentContext;
+#endif
 }
 
 
-GLXDrawable glXGetCurrentDrawable(void)
+GLXDrawable PUBLIC
+glXGetCurrentDrawable(void)
 {
-   return CurrentDrawable;
+   __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+   return gc ? gc->currentDrawable : 0;
 }
 
 
-Bool glXIsDirect(Display *dpy, GLXContext ctx)
+Bool PUBLIC
+glXIsDirect(Display *dpy, GLXContext ctx)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -265,25 +298,25 @@ Bool glXIsDirect(Display *dpy, GLXContext ctx)
 }
 
 
-Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
+Bool PUBLIC
+glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
 {
    Bool b;
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
-   if (!t)
+   if (!t) {
       return False;
+   }
    b = (*t->MakeCurrent)(dpy, drawable, ctx);
    if (b) {
-      CurrentDisplay = dpy;
-      CurrentContext = ctx;
-      CurrentDrawable = drawable;
-      CurrentReadDrawable = drawable;
+      SetCurrentContext(ctx);
    }
    return b;
 }
 
 
-Bool glXQueryExtension(Display *dpy, int *errorb, int *event)
+Bool PUBLIC
+glXQueryExtension(Display *dpy, int *errorb, int *event)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -293,7 +326,8 @@ Bool glXQueryExtension(Display *dpy, int *errorb, int *event)
 }
 
 
-Bool glXQueryVersion(Display *dpy, int *maj, int *min)
+Bool PUBLIC
+glXQueryVersion(Display *dpy, int *maj, int *min)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -303,7 +337,8 @@ Bool glXQueryVersion(Display *dpy, int *maj, int *min)
 }
 
 
-void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
+void PUBLIC
+glXSwapBuffers(Display *dpy, GLXDrawable drawable)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -313,30 +348,36 @@ void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
 }
 
 
-void glXUseXFont(Font font, int first, int count, int listBase)
+void PUBLIC
+glXUseXFont(Font font, int first, int count, int listBase)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
    if (!t)
       return;
    (t->UseXFont)(font, first, count, listBase);
 }
 
 
-void glXWaitGL(void)
+void PUBLIC
+glXWaitGL(void)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
    if (!t)
       return;
    (t->WaitGL)();
 }
 
 
-void glXWaitX(void)
+void PUBLIC
+glXWaitX(void)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
    if (!t)
       return;
    (t->WaitX)();
@@ -344,9 +385,10 @@ void glXWaitX(void)
 
 
 
-#ifdef GLX_VERSION_1_1
+/*** GLX_VERSION_1_1 ***/
 
-const char *glXGetClientString(Display *dpy, int name)
+const char PUBLIC *
+glXGetClientString(Display *dpy, int name)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -356,7 +398,8 @@ const char *glXGetClientString(Display *dpy, int name)
 }
 
 
-const char *glXQueryExtensionsString(Display *dpy, int screen)
+const char PUBLIC *
+glXQueryExtensionsString(Display *dpy, int screen)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -366,7 +409,8 @@ const char *glXQueryExtensionsString(Display *dpy, int screen)
 }
 
 
-const char *glXQueryServerString(Display *dpy, int screen, int name)
+const char PUBLIC *
+glXQueryServerString(Display *dpy, int screen, int name)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -375,22 +419,24 @@ const char *glXQueryServerString(Display *dpy, int screen, int name)
    return (t->QueryServerString)(dpy, screen, name);
 }
 
-#endif
-
 
+/*** GLX_VERSION_1_2 ***/
 
-#ifdef GLX_VERSION_1_2
-Display *glXGetCurrentDisplay(void)
+Display PUBLIC *
+glXGetCurrentDisplay(void)
 {
-   return CurrentDisplay;
+   /* Same code as in libGL's glxext.c */
+   __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+   if (NULL == gc) return NULL;
+   return gc->currentDpy;
 }
-#endif
 
 
 
-#ifdef GLX_VERSION_1_3
+/*** GLX_VERSION_1_3 ***/
 
-GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
+GLXFBConfig PUBLIC *
+glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -400,7 +446,8 @@ GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList,
 }
 
 
-GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
+GLXContext PUBLIC
+glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -410,7 +457,8 @@ GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType,
 }
 
 
-GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
+GLXPbuffer PUBLIC
+glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -420,7 +468,8 @@ GLXPbuffer glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribL
 }
 
 
-GLXPixmap glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
+GLXPixmap PUBLIC
+glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -430,7 +479,8 @@ GLXPixmap glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const
 }
 
 
-GLXWindow glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
+GLXWindow PUBLIC
+glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -440,7 +490,8 @@ GLXWindow glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const in
 }
 
 
-void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
+void PUBLIC
+glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -450,7 +501,8 @@ void glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
 }
 
 
-void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
+void PUBLIC
+glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -460,7 +512,8 @@ void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
 }
 
 
-void glXDestroyWindow(Display *dpy, GLXWindow window)
+void PUBLIC
+glXDestroyWindow(Display *dpy, GLXWindow window)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -470,13 +523,16 @@ void glXDestroyWindow(Display *dpy, GLXWindow window)
 }
 
 
-GLXDrawable glXGetCurrentReadDrawable(void)
+GLXDrawable PUBLIC
+glXGetCurrentReadDrawable(void)
 {
-   return CurrentReadDrawable;
+   __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+   return gc ? gc->currentReadable : 0;
 }
 
 
-int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
+int PUBLIC
+glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -486,7 +542,8 @@ int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *v
 }
 
 
-GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
+GLXFBConfig PUBLIC *
+glXGetFBConfigs(Display *dpy, int screen, int *nelements)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -495,7 +552,8 @@ GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
    return (t->GetFBConfigs)(dpy, screen, nelements);
 }
 
-void glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+void PUBLIC
+glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -505,7 +563,8 @@ void glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask
 }
 
 
-XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
+XVisualInfo PUBLIC *
+glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -515,7 +574,8 @@ XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
 }
 
 
-Bool glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+Bool PUBLIC
+glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
 {
    Bool b;
    struct _glxapi_table *t;
@@ -524,16 +584,14 @@ Bool glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLX
       return False;
    b = (t->MakeContextCurrent)(dpy, draw, read, ctx);
    if (b) {
-      CurrentDisplay = dpy;
-      CurrentContext = ctx;
-      CurrentDrawable = draw;
-      CurrentReadDrawable = read;
+      SetCurrentContext(ctx);
    }
    return b;
 }
 
 
-int glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
+int PUBLIC
+glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -544,7 +602,8 @@ int glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
 }
 
 
-void glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
+void PUBLIC
+glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -554,7 +613,8 @@ void glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned in
 }
 
 
-void glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
+void PUBLIC
+glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -563,72 +623,72 @@ void glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
    (t->SelectEvent)(dpy, drawable, mask);
 }
 
-#endif /* GLX_VERSION_1_3 */
 
 
-#ifdef GLX_SGI_swap_control
+/*** GLX_SGI_swap_control ***/
 
-int glXSwapIntervalSGI(int interval)
+int PUBLIC
+glXSwapIntervalSGI(int interval)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
    if (!t)
       return 0;
    return (t->SwapIntervalSGI)(interval);
 }
 
-#endif
 
 
-#ifdef GLX_SGI_video_sync
+/*** GLX_SGI_video_sync ***/
 
-int glXGetVideoSyncSGI(unsigned int *count)
+int PUBLIC
+glXGetVideoSyncSGI(unsigned int *count)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
-   if (!t)
-      return 0;
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
+   if (!t || !glXGetCurrentContext())
+      return GLX_BAD_CONTEXT;
    return (t->GetVideoSyncSGI)(count);
 }
 
-int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+int PUBLIC
+glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
-   if (!t)
-      return 0;
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
+   if (!t || !glXGetCurrentContext())
+      return GLX_BAD_CONTEXT;
    return (t->WaitVideoSyncSGI)(divisor, remainder, count);
 }
 
-#endif
 
 
-#ifdef GLX_SGI_make_current_read
+/*** GLX_SGI_make_current_read ***/
 
-Bool glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+Bool PUBLIC
+glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
    if (!t)
-      return 0;
+      return False;
    return (t->MakeCurrentReadSGI)(dpy, draw, read, ctx);
 }
 
-GLXDrawable glXGetCurrentReadDrawableSGI(void)
+GLXDrawable PUBLIC
+glXGetCurrentReadDrawableSGI(void)
 {
-   struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
-   if (!t)
-      return 0;
-   return (t->GetCurrentReadDrawableSGI)();
+   return glXGetCurrentReadDrawable();
 }
 
-#endif
-
 
-#if defined(_VL_H) && defined(GLX_SGIX_video_source)
+#if defined(_VL_H)
 
-GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
+GLXVideoSourceSGIX PUBLIC
+glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -637,7 +697,8 @@ GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServe
    return (t->CreateGLXVideoSourceSGIX)(dpy, screen, server, path, nodeClass, drainNode);
 }
 
-void glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
+void PUBLIC
+glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -649,9 +710,10 @@ void glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
 #endif
 
 
-#ifdef GLX_EXT_import_context
+/*** GLX_EXT_import_context ***/
 
-void glXFreeContextEXT(Display *dpy, GLXContext context)
+void PUBLIC
+glXFreeContextEXT(Display *dpy, GLXContext context)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -660,22 +722,20 @@ void glXFreeContextEXT(Display *dpy, GLXContext context)
    (t->FreeContextEXT)(dpy, context);
 }
 
-GLXContextID glXGetContextIDEXT(const GLXContext context)
+GLXContextID PUBLIC
+glXGetContextIDEXT(const GLXContext context)
 {
-   /* XXX is this function right? */
-   struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
-   if (!t)
-      return 0;
-   return (t->GetContextIDEXT)(context);
+   return ((__GLXcontext *) context)->xid;
 }
 
-Display *glXGetCurrentDisplayEXT(void)
+Display PUBLIC *
+glXGetCurrentDisplayEXT(void)
 {
-   return CurrentDisplay;
+   return glXGetCurrentDisplay();
 }
 
-GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
+GLXContext PUBLIC
+glXImportContextEXT(Display *dpy, GLXContextID contextID)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -684,7 +744,8 @@ GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
    return (t->ImportContextEXT)(dpy, contextID);
 }
 
-int glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
+int PUBLIC
+glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -693,12 +754,12 @@ int glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *
    return (t->QueryContextInfoEXT)(dpy, context, attribute, value);
 }
 
-#endif
 
 
-#ifdef GLX_SGIX_fbconfig
+/*** GLX_SGIX_fbconfig ***/
 
-int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
+int PUBLIC
+glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -707,7 +768,8 @@ int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute
    return (t->GetFBConfigAttribSGIX)(dpy, config, attribute, value);
 }
 
-GLXFBConfigSGIX *glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
+GLXFBConfigSGIX PUBLIC *
+glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -716,7 +778,8 @@ GLXFBConfigSGIX *glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_lis
    return (t->ChooseFBConfigSGIX)(dpy, screen, attrib_list, nelements);
 }
 
-GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
+GLXPixmap PUBLIC
+glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -725,7 +788,8 @@ GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
    return (t->CreateGLXPixmapWithConfigSGIX)(dpy, config, pixmap);
 }
 
-GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
+GLXContext PUBLIC
+glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -734,7 +798,8 @@ GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
    return (t->CreateContextWithConfigSGIX)(dpy, config, render_type, share_list, direct);
 }
 
-XVisualInfo * glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
+XVisualInfo PUBLIC *
+glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -743,7 +808,8 @@ XVisualInfo * glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
    return (t->GetVisualFromFBConfigSGIX)(dpy, config);
 }
 
-GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
+GLXFBConfigSGIX PUBLIC
+glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -752,12 +818,12 @@ GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
    return (t->GetFBConfigFromVisualSGIX)(dpy, vis);
 }
 
-#endif
 
 
-#ifdef GLX_SGIX_pbuffer
+/*** GLX_SGIX_pbuffer ***/
 
-GLXPbufferSGIX glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
+GLXPbufferSGIX PUBLIC
+glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -766,7 +832,8 @@ GLXPbufferSGIX glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, uns
    return (t->CreateGLXPbufferSGIX)(dpy, config, width, height, attrib_list);
 }
 
-void glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
+void PUBLIC
+glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -775,7 +842,8 @@ void glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
    (t->DestroyGLXPbufferSGIX)(dpy, pbuf);
 }
 
-int glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
+int PUBLIC
+glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -784,7 +852,8 @@ int glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, uns
    return (t->QueryGLXPbufferSGIX)(dpy, pbuf, attribute, value);
 }
 
-void glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
+void PUBLIC
+glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -793,7 +862,8 @@ void glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
    (t->SelectEventSGIX)(dpy, drawable, mask);
 }
 
-void glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+void PUBLIC
+glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -802,12 +872,12 @@ void glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *
    (t->GetSelectedEventSGIX)(dpy, drawable, mask);
 }
 
-#endif
 
 
-#ifdef GLX_SGI_cushion
+/*** GLX_SGI_cushion ***/
 
-void glXCushionSGI(Display *dpy, Window win, float cushion)
+void PUBLIC
+glXCushionSGI(Display *dpy, Window win, float cushion)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -816,12 +886,12 @@ void glXCushionSGI(Display *dpy, Window win, float cushion)
    (t->CushionSGI)(dpy, win, cushion);
 }
 
-#endif
 
 
-#ifdef GLX_SGIX_video_resize
+/*** GLX_SGIX_video_resize ***/
 
-int glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
+int PUBLIC
+glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -830,7 +900,8 @@ int glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window wi
    return (t->BindChannelToWindowSGIX)(dpy, screen, channel, window);
 }
 
-int glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+int PUBLIC
+glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -839,7 +910,8 @@ int glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int
    return (t->ChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
 }
 
-int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
+int PUBLIC
+glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -848,7 +920,8 @@ int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *
    return (t->QueryChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
 }
 
-int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+int PUBLIC
+glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -857,7 +930,8 @@ int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, in
    return (t->QueryChannelDeltasSGIX)(dpy, screen, channel, dx, dy, dw, dh);
 }
 
-int glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
+int PUBLIC
+glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -866,12 +940,12 @@ int glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctyp
    return (t->ChannelRectSyncSGIX)(dpy, screen, channel, synctype);
 }
 
-#endif
 
 
-#if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
+#if defined(_DM_BUFFER_H_)
 
-Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+Bool PUBLIC
+glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -883,9 +957,10 @@ Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *p
 #endif
 
 
-#ifdef GLX_SGIX_swap_group
+/*** GLX_SGIX_swap_group ***/
 
-void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
+void PUBLIC
+glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -894,12 +969,11 @@ void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member
    (*t->JoinSwapGroupSGIX)(dpy, drawable, member);
 }
 
-#endif
-
 
-#ifdef GLX_SGIX_swap_barrier
+/*** GLX_SGIX_swap_barrier ***/
 
-void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
+void PUBLIC
+glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -908,7 +982,8 @@ void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
    (*t->BindSwapBarrierSGIX)(dpy, drawable, barrier);
 }
 
-Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+Bool PUBLIC
+glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -917,12 +992,12 @@ Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
    return (*t->QueryMaxSwapBarriersSGIX)(dpy, screen, max);
 }
 
-#endif
 
 
-#ifdef GLX_SUN_get_transparent_index
+/*** GLX_SUN_get_transparent_index ***/
 
-Status glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+Status PUBLIC
+glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -931,12 +1006,12 @@ Status glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay,
    return (*t->GetTransparentIndexSUN)(dpy, overlay, underlay, pTransparent);
 }
 
-#endif
 
 
-#ifdef GLX_MESA_copy_sub_buffer
+/*** GLX_MESA_copy_sub_buffer ***/
 
-void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
+void PUBLIC
+glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -945,12 +1020,12 @@ void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int
    (t->CopySubBufferMESA)(dpy, drawable, x, y, width, height);
 }
 
-#endif
 
 
-#ifdef GLX_MESA_release_buffers
+/*** GLX_MESA_release_buffers ***/
 
-Bool glXReleaseBuffersMESA(Display *dpy, Window w)
+Bool PUBLIC
+glXReleaseBuffersMESA(Display *dpy, Window w)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -959,12 +1034,12 @@ Bool glXReleaseBuffersMESA(Display *dpy, Window w)
    return (t->ReleaseBuffersMESA)(dpy, w);
 }
 
-#endif
 
 
-#ifdef GLX_MESA_pixmap_colormap
+/*** GLX_MESA_pixmap_colormap ***/
 
-GLXPixmap glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
+GLXPixmap PUBLIC
+glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
 {
    struct _glxapi_table *t;
    GET_DISPATCH(dpy, t);
@@ -973,23 +1048,89 @@ GLXPixmap glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixm
    return (t->CreateGLXPixmapMESA)(dpy, visinfo, pixmap, cmap);
 }
 
-#endif
 
 
-#ifdef GLX_MESA_set_3dfx_mode
+/*** GLX_MESA_set_3dfx_mode ***/
 
-Bool glXSet3DfxModeMESA(int mode)
+Bool PUBLIC
+glXSet3DfxModeMESA(int mode)
 {
    struct _glxapi_table *t;
-   GET_DISPATCH(CurrentDisplay, t);
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
    if (!t)
       return False;
    return (t->Set3DfxModeMESA)(mode);
 }
 
-#endif
 
 
+/*** GLX_NV_vertex_array_range ***/
+
+void PUBLIC *
+glXAllocateMemoryNV( GLsizei size,
+                     GLfloat readFrequency,
+                     GLfloat writeFrequency,
+                     GLfloat priority )
+{
+   struct _glxapi_table *t;
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
+   if (!t)
+      return NULL;
+   return (t->AllocateMemoryNV)(size, readFrequency, writeFrequency, priority);
+}
+
+
+void PUBLIC
+glXFreeMemoryNV( GLvoid *pointer )
+{
+   struct _glxapi_table *t;
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
+   if (!t)
+      return;
+   (t->FreeMemoryNV)(pointer);
+}
+
+
+
+
+/*** GLX_MESA_agp_offset */
+
+GLuint PUBLIC
+glXGetAGPOffsetMESA( const GLvoid *pointer )
+{
+   struct _glxapi_table *t;
+   Display *dpy = glXGetCurrentDisplay();
+   GET_DISPATCH(dpy, t);
+   if (!t)
+      return ~0;
+   return (t->GetAGPOffsetMESA)(pointer);
+}
+
+
+/*** GLX_EXT_texture_from_pixmap */
+
+void PUBLIC
+glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
+                   const int *attrib_list)
+{
+   struct _glxapi_table *t;
+   GET_DISPATCH(dpy, t);
+   if (t)
+      t->BindTexImageEXT(dpy, drawable, buffer, attrib_list);
+}
+
+void PUBLIC
+glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
+{
+   struct _glxapi_table *t;
+   GET_DISPATCH(dpy, t);
+   if (t)
+      t->ReleaseTexImageEXT(dpy, drawable, buffer);
+}
+
 
 /**********************************************************************/
 /* GLX API management functions                                       */
@@ -1027,6 +1168,18 @@ _glxapi_get_extensions(void)
 #endif
 #ifdef GLX_MESA_set_3dfx_mode
       "GLX_MESA_set_3dfx_mode",
+#endif
+#ifdef GLX_SGIX_fbconfig
+      "GLX_SGIX_fbconfig",
+#endif
+#ifdef GLX_SGIX_pbuffer
+      "GLX_SGIX_pbuffer",
+#endif
+#ifdef GLX_EXT_texture_from_pixmap
+      "GLX_EXT_texture_from_pixmap",
+#endif
+#ifdef GLX_INTEL_swap_event
+      "GLX_INTEL_swap_event",
 #endif
       NULL
    };
@@ -1057,240 +1210,160 @@ generic_no_op_func(void)
 void
 _glxapi_set_no_op_table(struct _glxapi_table *t)
 {
+   typedef int (*nop_func)(void);
+   nop_func *dispatch = (nop_func *) t;
    GLuint n = _glxapi_get_dispatch_table_size();
    GLuint i;
-   void **dispatch = (void **) t;
    for (i = 0; i < n; i++) {
-      dispatch[i] = (void *) generic_no_op_func;
+      dispatch[i] = generic_no_op_func;
    }
 }
 
 
-#if 00
-/*
- * Open the named library and use dlsym() to populate the given dispatch
- * table with GLX function pointers.
- * Return: true = all OK
- *         false = can't open libName or can't get required GLX function
- */
-GLboolean
-_glxapi_load_library_table(const char *libName, struct _glxapi_table *t)
-{
-   void *libHandle;
-   void **entry;   /* used to avoid a lot of cast/type warnings */
-
-   libHandle = dlopen(libName, 0);
-   if (!libHandle) {
-      return GL_FALSE;
-   }
-
-#define GET_REQ_FUNCTION(ENTRY, NAME)                                  \
-   entry = (void **) &(t->ENTRY);                                      \
-   *entry = dlsym(libHandle, NAME);                                    \
-   if (!*entry) {                                                      \
-      fprintf(stderr, "libGL Error: couldn't load %s from %s\n",       \
-              NAME, libName);                                          \
-      dlclose(libHandle);                                              \
-      return GL_FALSE;                                                 \
-   }
-
-   /* 1.0 and 1.1 functions */
-   GET_REQ_FUNCTION(ChooseVisual, "glXChooseVisual");
-   GET_REQ_FUNCTION(CopyContext, "glXCopyContext");
-   GET_REQ_FUNCTION(CreateContext, "glXCreateContext");
-   GET_REQ_FUNCTION(CreateGLXPixmap, "glXCreateGLXPixmap");
-   GET_REQ_FUNCTION(DestroyContext, "glXDestroyContext");
-   GET_REQ_FUNCTION(GetConfig, "glXGetConfig");
-   GET_REQ_FUNCTION(IsDirect, "glXIsDirect");
-   GET_REQ_FUNCTION(MakeCurrent, "glXMakeCurrent");
-   GET_REQ_FUNCTION(QueryExtension, "glXQueryExtension");
-   GET_REQ_FUNCTION(QueryVersion, "glXQueryVersion");
-   GET_REQ_FUNCTION(SwapBuffers, "glXSwapBuffers");
-   GET_REQ_FUNCTION(UseXFont, "glXUseXFont");
-   GET_REQ_FUNCTION(WaitGL, "glXWaitGL");
-   GET_REQ_FUNCTION(WaitX, "glXWaitX");
-   GET_REQ_FUNCTION(GetClientString, "glXGetClientString");
-   GET_REQ_FUNCTION(QueryExtensionsString, "glXQueryExtensionsString");
-   GET_REQ_FUNCTION(QueryServerString, "glXQueryServerString");
-
-#define GET_OPT_FUNCTION(ENTRY, NAME)                                  \
-   entry = (void **) &(t->ENTRY);                                      \
-   *entry = dlsym(libHandle, NAME);                                    \
-   if (!*entry) {                                                      \
-      *entry = (void *) generic_no_op_func;                            \
-   }
-
-   /* 1.2, 1.3 and extensions */
-   GET_OPT_FUNCTION(ChooseFBConfig, "glXChooseFBConfig");
-   GET_OPT_FUNCTION(CreateNewContext, "glXCreateNewContext");
-   GET_OPT_FUNCTION(CreatePbuffer, "glXCreatePbuffer");
-   GET_OPT_FUNCTION(CreatePixmap, "glXCreatePixmap");
-   GET_OPT_FUNCTION(CreateWindow, "glXCreateWindow");
-   GET_OPT_FUNCTION(DestroyPbuffer, "glXDestroyPbuffer");
-   GET_OPT_FUNCTION(DestroyPixmap, "glXDestroyPixmap");
-   GET_OPT_FUNCTION(DestroyWindow, "glXDestroyWindow");
-   GET_OPT_FUNCTION(GetFBConfigAttrib, "glXGetFBConfigAttrib");
-   GET_OPT_FUNCTION(GetFBConfigs, "glXGetFBConfigs");
-   GET_OPT_FUNCTION(GetSelectedEvent, "glXGetSelectedEvent");
-   GET_OPT_FUNCTION(GetVisualFromFBConfig, "glXGetVisualFromFBConfig");
-   GET_OPT_FUNCTION(MakeContextCurrent, "glXMakeContextCurrent");
-   GET_OPT_FUNCTION(QueryContext, "glXQueryContext");
-   GET_OPT_FUNCTION(QueryDrawable, "glXQueryDrawable");
-   GET_OPT_FUNCTION(SelectEvent, "glXSelectEvent");
-#ifdef GLX_SGI_swap_control
-   GET_OPT_FUNCTION(SwapIntervalSGI, "glXSwapIntervalSGI");
-#endif
-#ifdef GLX_SGI_video_sync
-   GET_OPT_FUNCTION(GetVideoSyncSGI, "glXGetVideoSyncSGI");
-   GET_OPT_FUNCTION(WaitVideoSyncSGI, "glXWaitVideoSyncSGI");
-#endif
-#ifdef GLX_SGI_make_current_read
-   GET_OPT_FUNCTION(MakeCurrentReadSGI, "glXMakeCurrentReadSGI");
-   GET_OPT_FUNCTION(GetCurrentReadDrawableSGI, "glXGetCurrentReadDrawableSGI");
-#endif
-#if defined(_VL_H) && defined(GLX_SGIX_video_source)
-   GET_OPT_FUNCTION(CreateGLXVideoSourceSGIX, "glXCreateGLXVideoSourceSGIX");
-   GET_OPT_FUNCTION(DestroyGLXVideoSourceSGIX, "glXDestroyGLXVideoSourceSGIX");
-#endif
-#ifdef GLX_EXT_import_context
-   GET_OPT_FUNCTION(FreeContextEXT, "glXFreeContextEXT");
-   GET_OPT_FUNCTION(GetContextIDEXT, "glXGetContextIDEXT");
-   GET_OPT_FUNCTION(GetCurrentDisplayEXT, "glXGetCurrentDisplayEXT");
-   GET_OPT_FUNCTION(ImportContextEXT, "glXImportContextEXT");
-   GET_OPT_FUNCTION(QueryContextInfoEXT, "glXQueryContextInfoEXT");
-#endif
-#ifdef GLX_SGIX_fbconfig
-   GET_OPT_FUNCTION(GetFBConfigAttribSGIX, "glXGetFBConfigAttribSGIX");
-   GET_OPT_FUNCTION(ChooseFBConfigSGIX, "glXChooseFBConfigSGIX");
-   GET_OPT_FUNCTION(CreateGLXPixmapWithConfigSGIX, "glXCreateGLXPixmapWithConfigSGIX");
-   GET_OPT_FUNCTION(CreateContextWithConfigSGIX, "glXCreateContextWithConfigSGIX");
-   GET_OPT_FUNCTION(GetVisualFromFBConfigSGIX, "glXGetVisualFromFBConfigSGIX");
-   GET_OPT_FUNCTION(GetFBConfigFromVisualSGIX, "glXGetFBConfigFromVisualSGIX");
-#endif
-#ifdef GLX_SGIX_pbuffer
-   GET_OPT_FUNCTION(CreateGLXPbufferSGIX, "glXCreateGLXPbufferSGIX");
-   GET_OPT_FUNCTION(DestroyGLXPbufferSGIX, "glXDestroyGLXPbufferSGIX");
-   GET_OPT_FUNCTION(QueryGLXPbufferSGIX, "glXQueryGLXPbufferSGIX");
-   GET_OPT_FUNCTION(SelectEventSGIX, "glXSelectEventSGIX");
-   GET_OPT_FUNCTION(GetSelectedEventSGIX, "glXGetSelectedEventSGIX");
-#endif
-#ifdef GLX_SGI_cushion
-   GET_OPT_FUNCTION(CushionSGI, "glXCushionSGI");
-#endif
-#ifdef GLX_SGIX_video_resize
-   GET_OPT_FUNCTION(BindChannelToWindowSGIX, "glXBindChannelToWindowSGIX");
-   GET_OPT_FUNCTION(ChannelRectSGIX, "glXChannelRectSGIX");
-   GET_OPT_FUNCTION(QueryChannelRectSGIX, "glXQueryChannelRectSGIX");
-   GET_OPT_FUNCTION(QueryChannelDeltasSGIX, "glXQueryChannelDeltasSGIX");
-   GET_OPT_FUNCTION(ChannelRectSyncSGIX, "glXChannelRectSyncSGIX");
-#endif
-#if defined (_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
-   GET_OPT_FUNCTION(AssociateDMPbufferSGIX, "glXAssociateDMPbufferSGIX");
-#endif
-#ifdef GLX_SGIX_swap_group
-   GET_OPT_FUNCTION(JoinSwapGroupSGIX, "glXJoinSwapGroupSGIX");
-#endif
-#ifdef GLX_SGIX_swap_barrier
-   GET_OPT_FUNCTION(BindSwapBarrierSGIX, "glXBindSwapBarrierSGIX");
-   GET_OPT_FUNCTION(QueryMaxSwapBarriersSGIX, "glXQueryMaxSwapBarriersSGIX");
-#endif
-#ifdef GLX_SUN_get_transparent_index
-   GET_OPT_FUNCTION(GetTransparentIndexSUN, "glXGetTransparentIndexSUN");
-#endif
-#ifdef GLX_MESA_copy_sub_buffer
-   GET_OPT_FUNCTION(CopySubBufferMESA, "glXCopySubBufferMESA");
-#endif
-#ifdef GLX_MESA_release_buffers
-   GET_OPT_FUNCTION(ReleaseBuffersMESA, "glXReleaseBuffersMESA");
-#endif
-#ifdef GLX_MESA_pixmap_colormap
-   GET_OPT_FUNCTION(CreateGLXPixmapMESA, "glXCreateGLXPixmapMESA");
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
-   GET_OPT_FUNCTION(Set3DfxModeMESA, "glXSet3DfxModeMESA");
-#endif
-
-   return GL_TRUE;
-}
-#endif
-
-
-
 struct name_address_pair {
    const char *Name;
-   GLvoid *Address;
+   __GLXextFuncPtr Address;
 };
 
 static struct name_address_pair GLX_functions[] = {
-   { "glXChooseVisual", (GLvoid *) glXChooseVisual },
-   { "glXCopyContext", (GLvoid *) glXCopyContext },
-   { "glXCreateContext", (GLvoid *) glXCreateContext },
-   { "glXCreateGLXPixmap", (GLvoid *) glXCreateGLXPixmap },
-   { "glXDestroyContext", (GLvoid *) glXDestroyContext },
-   { "glXDestroyGLXPixmap", (GLvoid *) glXDestroyGLXPixmap },
-   { "glXGetConfig", (GLvoid *) glXGetConfig },
-   { "glXGetCurrentContext", (GLvoid *) glXGetCurrentContext },
-   { "glXGetCurrentDrawable", (GLvoid *) glXGetCurrentDrawable },
-   { "glXIsDirect", (GLvoid *) glXIsDirect },
-   { "glXMakeCurrent", (GLvoid *) glXMakeCurrent },
-   { "glXQueryExtension", (GLvoid *) glXQueryExtension },
-   { "glXQueryVersion", (GLvoid *) glXQueryVersion },
-   { "glXSwapBuffers", (GLvoid *) glXSwapBuffers },
-   { "glXUseXFont", (GLvoid *) glXUseXFont },
-   { "glXWaitGL", (GLvoid *) glXWaitGL },
-   { "glXWaitX", (GLvoid *) glXWaitX },
-
-#ifdef GLX_VERSION_1_1
-   { "glXGetClientString", (GLvoid *) glXGetClientString },
-   { "glXQueryExtensionsString", (GLvoid *) glXQueryExtensionsString },
-   { "glXQueryServerString", (GLvoid *) glXQueryServerString },
+   /*** GLX_VERSION_1_0 ***/
+   { "glXChooseVisual", (__GLXextFuncPtr) glXChooseVisual },
+   { "glXCopyContext", (__GLXextFuncPtr) glXCopyContext },
+   { "glXCreateContext", (__GLXextFuncPtr) glXCreateContext },
+   { "glXCreateGLXPixmap", (__GLXextFuncPtr) glXCreateGLXPixmap },
+   { "glXDestroyContext", (__GLXextFuncPtr) glXDestroyContext },
+   { "glXDestroyGLXPixmap", (__GLXextFuncPtr) glXDestroyGLXPixmap },
+   { "glXGetConfig", (__GLXextFuncPtr) glXGetConfig },
+   { "glXGetCurrentContext", (__GLXextFuncPtr) glXGetCurrentContext },
+   { "glXGetCurrentDrawable", (__GLXextFuncPtr) glXGetCurrentDrawable },
+   { "glXIsDirect", (__GLXextFuncPtr) glXIsDirect },
+   { "glXMakeCurrent", (__GLXextFuncPtr) glXMakeCurrent },
+   { "glXQueryExtension", (__GLXextFuncPtr) glXQueryExtension },
+   { "glXQueryVersion", (__GLXextFuncPtr) glXQueryVersion },
+   { "glXSwapBuffers", (__GLXextFuncPtr) glXSwapBuffers },
+   { "glXUseXFont", (__GLXextFuncPtr) glXUseXFont },
+   { "glXWaitGL", (__GLXextFuncPtr) glXWaitGL },
+   { "glXWaitX", (__GLXextFuncPtr) glXWaitX },
+
+   /*** GLX_VERSION_1_1 ***/
+   { "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },
+   { "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },
+   { "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },
+
+   /*** GLX_VERSION_1_2 ***/
+   { "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },
+
+   /*** GLX_VERSION_1_3 ***/
+   { "glXChooseFBConfig", (__GLXextFuncPtr) glXChooseFBConfig },
+   { "glXCreateNewContext", (__GLXextFuncPtr) glXCreateNewContext },
+   { "glXCreatePbuffer", (__GLXextFuncPtr) glXCreatePbuffer },
+   { "glXCreatePixmap", (__GLXextFuncPtr) glXCreatePixmap },
+   { "glXCreateWindow", (__GLXextFuncPtr) glXCreateWindow },
+   { "glXDestroyPbuffer", (__GLXextFuncPtr) glXDestroyPbuffer },
+   { "glXDestroyPixmap", (__GLXextFuncPtr) glXDestroyPixmap },
+   { "glXDestroyWindow", (__GLXextFuncPtr) glXDestroyWindow },
+   { "glXGetCurrentReadDrawable", (__GLXextFuncPtr) glXGetCurrentReadDrawable },
+   { "glXGetFBConfigAttrib", (__GLXextFuncPtr) glXGetFBConfigAttrib },
+   { "glXGetFBConfigs", (__GLXextFuncPtr) glXGetFBConfigs },
+   { "glXGetSelectedEvent", (__GLXextFuncPtr) glXGetSelectedEvent },
+   { "glXGetVisualFromFBConfig", (__GLXextFuncPtr) glXGetVisualFromFBConfig },
+   { "glXMakeContextCurrent", (__GLXextFuncPtr) glXMakeContextCurrent },
+   { "glXQueryContext", (__GLXextFuncPtr) glXQueryContext },
+   { "glXQueryDrawable", (__GLXextFuncPtr) glXQueryDrawable },
+   { "glXSelectEvent", (__GLXextFuncPtr) glXSelectEvent },
+
+   /*** GLX_VERSION_1_4 ***/
+   { "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },
+
+   /*** GLX_SGI_swap_control ***/
+   { "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },
+
+   /*** GLX_SGI_video_sync ***/
+   { "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },
+   { "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },
+
+   /*** GLX_SGI_make_current_read ***/
+   { "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },
+   { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },
+
+   /*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+   { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },
+   { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },
 #endif
 
-#ifdef GLX_VERSION_1_2
-   { "glXGetCurrentDisplay", (GLvoid *) glXGetCurrentDisplay },
+   /*** GLX_EXT_import_context ***/
+   { "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },
+   { "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },
+   { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },
+   { "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },
+   { "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },
+
+   /*** GLX_SGIX_fbconfig ***/
+   { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr) glXGetFBConfigAttribSGIX },
+   { "glXChooseFBConfigSGIX", (__GLXextFuncPtr) glXChooseFBConfigSGIX },
+   { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr) glXCreateGLXPixmapWithConfigSGIX },
+   { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr) glXCreateContextWithConfigSGIX },
+   { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr) glXGetVisualFromFBConfigSGIX },
+   { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr) glXGetFBConfigFromVisualSGIX },
+
+   /*** GLX_SGIX_pbuffer ***/
+   { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },
+   { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },
+   { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },
+   { "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },
+   { "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },
+
+   /*** GLX_SGI_cushion ***/
+   { "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },
+
+   /*** GLX_SGIX_video_resize ***/
+   { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },
+   { "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },
+   { "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },
+   { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },
+   { "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },
+
+   /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+   { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },
 #endif
 
-#ifdef GLX_VERSION_1_3
-   { "glXChooseFBConfig", (GLvoid *) glXChooseFBConfig },
-   { "glXCreateNewContext", (GLvoid *) glXCreateNewContext },
-   { "glXCreatePbuffer", (GLvoid *) glXCreatePbuffer },
-   { "glXCreatePixmap", (GLvoid *) glXCreatePixmap },
-   { "glXCreateWindow", (GLvoid *) glXCreateWindow },
-   { "glXDestroyPbuffer", (GLvoid *) glXDestroyPbuffer },
-   { "glXDestroyPixmap", (GLvoid *) glXDestroyPixmap },
-   { "glXDestroyWindow", (GLvoid *) glXDestroyWindow },
-   { "glXGetCurrentReadDrawable", (GLvoid *) glXGetCurrentReadDrawable },
-   { "glXGetFBConfigAttrib", (GLvoid *) glXGetFBConfigAttrib },
-   { "glXGetSelectedEvent", (GLvoid *) glXGetSelectedEvent },
-   { "glXGetVisualFromFBConfig", (GLvoid *) glXGetVisualFromFBConfig },
-   { "glXMakeContextCurrent", (GLvoid *) glXMakeContextCurrent },
-   { "glXQueryContext", (GLvoid *) glXQueryContext },
-   { "glXQueryDrawable", (GLvoid *) glXQueryDrawable },
-   { "glXSelectEvent", (GLvoid *) glXSelectEvent },
-#endif
+   /*** GLX_SGIX_swap_group ***/
+   { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr) glXJoinSwapGroupSGIX },
 
-#ifdef GLX_SGI_video_sync
-   { "glXGetVideoSyncSGI", (GLvoid *) glXGetVideoSyncSGI },
-   { "glXWaitVideoSyncSGI", (GLvoid *) glXWaitVideoSyncSGI },
-#endif
+   /*** GLX_SGIX_swap_barrier ***/
+   { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr) glXBindSwapBarrierSGIX },
+   { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr) glXQueryMaxSwapBarriersSGIX },
 
-#ifdef GLX_MESA_copy_sub_buffer
-   { "glXCopySubBufferMESA", (GLvoid *) glXCopySubBufferMESA },
-#endif
+   /*** GLX_SUN_get_transparent_index ***/
+   { "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
 
-#ifdef GLX_MESA_release_buffers
-   { "glXReleaseBuffersMESA", (GLvoid *) glXReleaseBuffersMESA },
-#endif
+   /*** GLX_MESA_copy_sub_buffer ***/
+   { "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
 
-#ifdef GLX_MESA_pixmap_colormap
-   { "glXCreateGLXPixmapMESA", (GLvoid *) glXCreateGLXPixmapMESA },
-#endif
+   /*** GLX_MESA_pixmap_colormap ***/
+   { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
 
-#ifdef GLX_MESA_set_3dfx_mode
-   { "glXSet3DfxModeMESA", (GLvoid *) glXSet3DfxModeMESA },
-#endif
+   /*** GLX_MESA_release_buffers ***/
+   { "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
+
+   /*** GLX_MESA_set_3dfx_mode ***/
+   { "glXSet3DfxModeMESA", (__GLXextFuncPtr) glXSet3DfxModeMESA },
+
+   /*** GLX_ARB_get_proc_address ***/
+   { "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
+
+   /*** GLX_NV_vertex_array_range ***/
+   { "glXAllocateMemoryNV", (__GLXextFuncPtr) glXAllocateMemoryNV },
+   { "glXFreeMemoryNV", (__GLXextFuncPtr) glXFreeMemoryNV },
+
+   /*** GLX_MESA_agp_offset ***/
+   { "glXGetAGPOffsetMESA", (__GLXextFuncPtr) glXGetAGPOffsetMESA },
 
-   { "glXGetProcAddressARB", (GLvoid *) glXGetProcAddressARB },
+   /*** GLX_EXT_texture_from_pixmap ***/
+   { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
+   { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
 
    { NULL, NULL }   /* end of list */
 };
@@ -1300,12 +1373,17 @@ static struct name_address_pair GLX_functions[] = {
 /*
  * Return address of named glX function, or NULL if not found.
  */
-const GLvoid *
+__GLXextFuncPtr
 _glxapi_get_proc_address(const char *funcName)
 {
    GLuint i;
    for (i = 0; GLX_functions[i].Name; i++) {
+#ifdef MANGLE
+      /* skip the "m" prefix on the name */
+      if (strcmp(GLX_functions[i].Name, funcName+1) == 0)
+#else
       if (strcmp(GLX_functions[i].Name, funcName) == 0)
+#endif
          return GLX_functions[i].Address;
    }
    return NULL;
@@ -1317,16 +1395,24 @@ _glxapi_get_proc_address(const char *funcName)
  * This function does not get dispatched through the dispatch table
  * since it's really a "meta" function.
  */
-void (*glXGetProcAddressARB(const GLubyte *procName))()
+__GLXextFuncPtr PUBLIC
+glXGetProcAddressARB(const GLubyte *procName)
 {
-   typedef void (*gl_function)();
-   gl_function f;
+   __GLXextFuncPtr f;
 
-   f = (gl_function) _glxapi_get_proc_address((const char *) procName);
+   f = _glxapi_get_proc_address((const char *) procName);
    if (f) {
       return f;
    }
 
-   f = (gl_function) _glapi_get_proc_address((const char *) procName);
+   f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
    return f;
 }
+
+
+/* GLX 1.4 */
+void PUBLIC
+(*glXGetProcAddress(const GLubyte *procName))()
+{
+   return glXGetProcAddressARB(procName);
+}