Further help with dri libGL version skew
diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11
index 76bf931..24a1453 100644
--- a/src/mesa/Makefile.X11
+++ b/src/mesa/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.61 2001/12/14 16:35:55 kschultz Exp $
+# $Id: Makefile.X11,v 1.62 2001/12/20 15:30:45 keithw Exp $
 
 # Mesa 3-D graphics library
 # Version:  4.1
@@ -25,6 +25,7 @@
 	vpparse.c \
 	vpstate.c \
 	api_arrayelt.c \
+	api_compat.c \
 	api_loopback.c \
 	api_noop.c \
 	api_validate.c \
diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11
index 76bf931..24a1453 100644
--- a/src/mesa/main/Makefile.X11
+++ b/src/mesa/main/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.61 2001/12/14 16:35:55 kschultz Exp $
+# $Id: Makefile.X11,v 1.62 2001/12/20 15:30:45 keithw Exp $
 
 # Mesa 3-D graphics library
 # Version:  4.1
@@ -25,6 +25,7 @@
 	vpparse.c \
 	vpstate.c \
 	api_arrayelt.c \
+	api_compat.c \
 	api_loopback.c \
 	api_noop.c \
 	api_validate.c \
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 288735d..fc2f714 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -1,4 +1,4 @@
-/* $Id: api_arrayelt.c,v 1.3 2001/06/01 22:22:10 keithw Exp $ */
+/* $Id: api_arrayelt.c,v 1.4 2001/12/20 15:30:45 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -24,9 +24,14 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/* Author:
+ *    Keith Whitwell <keith_whitwell@yahoo.com>
+ */
+
 #include "glheader.h"
 #include "api_arrayelt.h"
 #include "context.h"
+#include "glapi.h"
 #include "mem.h"
 #include "macros.h"
 #include "mtypes.h"
@@ -164,35 +169,38 @@
    (void (*)( const void * ))glNormal3dv,
 };
 
-static void (*fogcoordfuncs[8])( const void * ) = {
-   0,
-   0,
-   0,
-   0,
-   0,
-   0,
-   (void (*)( const void * ))glFogCoordfvEXT,
-   (void (*)( const void * ))glFogCoorddvEXT,
-};
-
-static void (*secondarycolorfuncs[8])( const void * ) = {
-   (void (*)( const void * ))glSecondaryColor3bvEXT,
-   (void (*)( const void * ))glSecondaryColor3ubvEXT,
-   (void (*)( const void * ))glSecondaryColor3svEXT,
-   (void (*)( const void * ))glSecondaryColor3usvEXT,
-   (void (*)( const void * ))glSecondaryColor3ivEXT,
-   (void (*)( const void * ))glSecondaryColor3uivEXT,
-   (void (*)( const void * ))glSecondaryColor3fvEXT,
-   (void (*)( const void * ))glSecondaryColor3dvEXT,
-};
-
+static void (*fogcoordfuncs[8])( const void * );
+static void (*secondarycolorfuncs[8])( const void * );
 
 GLboolean _ae_create_context( GLcontext *ctx )
 {
+   static int firsttime = 1;
+
    ctx->aelt_context = MALLOC( sizeof(AEcontext) );
    if (!ctx->aelt_context) 
       return GL_FALSE;
 
+
+   if (firsttime)
+   {
+      firsttime = 0;
+
+      /* Don't really want to use api_compat.h for this, but the
+       * rational for using _glaph_get_proc_address is the same.
+       */
+      fogcoordfuncs[0] = _glapi_get_proc_address("glSecondaryColor3bvEXT");
+      fogcoordfuncs[1] = _glapi_get_proc_address("glSecondaryColor3ubvEXT");
+      fogcoordfuncs[2] = _glapi_get_proc_address("glSecondaryColor3svEXT");
+      fogcoordfuncs[3] = _glapi_get_proc_address("glSecondaryColor3usvEXT");
+      fogcoordfuncs[4] = _glapi_get_proc_address("glSecondaryColor3ivEXT");
+      fogcoordfuncs[5] = _glapi_get_proc_address("glSecondaryColor3uivEXT");
+      fogcoordfuncs[6] = _glapi_get_proc_address("glSecondaryColor3fvEXT");
+      fogcoordfuncs[7] = _glapi_get_proc_address("glSecondaryColor3dvEXT");
+
+      secondarycolorfuncs[6] = _glapi_get_proc_address("glFogCoordfvEXT");
+      secondarycolorfuncs[7] = _glapi_get_proc_address("glFogCoorddvEXT");
+   }
+
    AE_CONTEXT(ctx)->NewState = ~0;
    return GL_TRUE;
 }
diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c
index cf38a54..7795935 100644
--- a/src/mesa/main/api_loopback.c
+++ b/src/mesa/main/api_loopback.c
@@ -1,4 +1,4 @@
-/* $Id: api_loopback.c,v 1.12 2001/12/14 02:50:01 brianp Exp $ */
+/* $Id: api_loopback.c,v 1.13 2001/12/20 15:30:45 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -32,6 +32,7 @@
 #include "glapitable.h"
 #include "macros.h"
 #include "colormac.h"
+#include "api_compat.h"
 #include "api_loopback.h"
 
 /* KW: A set of functions to convert unusual Color/Normal/Vertex/etc
@@ -43,30 +44,31 @@
  * listed in dd.h.  The easiest way for a driver to do this is to
  * install the supplied software t&l module.
  */
-#define DRIVER(x) gl##x
-#define COLORUBV(v)                 DRIVER(Color4ubv)(v)
-#define COLORF(r,g,b,a)             DRIVER(Color4f)(r,g,b,a)
-#define FOGCOORDF(x)                DRIVER(FogCoordfEXT)(x)
-#define VERTEX2(x,y)	            DRIVER(Vertex2f)(x,y)
-#define VERTEX3(x,y,z)	            DRIVER(Vertex3f)(x,y,z)
-#define VERTEX4(x,y,z,w)            DRIVER(Vertex4f)(x,y,z,w)
-#define NORMAL(x,y,z)               DRIVER(Normal3f)(x,y,z)
-#define TEXCOORD1(s)                DRIVER(TexCoord1f)(s)
-#define TEXCOORD2(s,t)              DRIVER(TexCoord2f)(s,t)
-#define TEXCOORD3(s,t,u)            DRIVER(TexCoord3f)(s,t,u)
-#define TEXCOORD4(s,t,u,v)          DRIVER(TexCoord4f)(s,t,u,v)
-#define INDEX(c)		    DRIVER(Indexi)(c)
-#define MULTI_TEXCOORD1(z,s)	    DRIVER(MultiTexCoord1fARB)(z,s)
-#define MULTI_TEXCOORD2(z,s,t)	    DRIVER(MultiTexCoord2fARB)(z,s,t)
-#define MULTI_TEXCOORD3(z,s,t,u)    DRIVER(MultiTexCoord3fARB)(z,s,t,u)
-#define MULTI_TEXCOORD4(z,s,t,u,v)  DRIVER(MultiTexCoord4fARB)(z,s,t,u,v)
-#define EVALCOORD1(x)               DRIVER(EvalCoord1f)(x)
-#define EVALCOORD2(x,y)             DRIVER(EvalCoord2f)(x,y)
-#define MATERIALFV(a,b,c)           DRIVER(Materialfv)(a,b,c)
-#define RECTF(a,b,c,d)              DRIVER(Rectf)(a,b,c,d)
-#define SECONDARYCOLORUB(a,b,c)     DRIVER(SecondaryColor3ubEXT)(a,b,c)
-#define SECONDARYCOLORF(a,b,c)      DRIVER(SecondaryColor3fEXT)(a,b,c)
-#define ATTRIB(index, x, y, z, w)   DRIVER(VertexAttrib4fNV)(index, x, y, z, w)
+#define COLORUBV(v)                 glColor4ubv(v)
+#define COLORF(r,g,b,a)             glColor4f(r,g,b,a)
+#define VERTEX2(x,y)	            glVertex2f(x,y)
+#define VERTEX3(x,y,z)	            glVertex3f(x,y,z)
+#define VERTEX4(x,y,z,w)            glVertex4f(x,y,z,w)
+#define NORMAL(x,y,z)               glNormal3f(x,y,z)
+#define TEXCOORD1(s)                glTexCoord1f(s)
+#define TEXCOORD2(s,t)              glTexCoord2f(s,t)
+#define TEXCOORD3(s,t,u)            glTexCoord3f(s,t,u)
+#define TEXCOORD4(s,t,u,v)          glTexCoord4f(s,t,u,v)
+#define INDEX(c)		    glIndexi(c)
+#define MULTI_TEXCOORD1(z,s)	    glMultiTexCoord1fARB(z,s)
+#define MULTI_TEXCOORD2(z,s,t)	    glMultiTexCoord2fARB(z,s,t)
+#define MULTI_TEXCOORD3(z,s,t,u)    glMultiTexCoord3fARB(z,s,t,u)
+#define MULTI_TEXCOORD4(z,s,t,u,v)  glMultiTexCoord4fARB(z,s,t,u,v)
+#define EVALCOORD1(x)               glEvalCoord1f(x)
+#define EVALCOORD2(x,y)             glEvalCoord2f(x,y)
+#define MATERIALFV(a,b,c)           glMaterialfv(a,b,c)
+#define RECTF(a,b,c,d)              glRectf(a,b,c,d)
+
+
+
+#define FOGCOORDF(x)                _compat_FogCoordfEXT(x)
+#define SECONDARYCOLORUB(a,b,c)     _compat_SecondaryColor3ubEXT(a,b,c)
+#define SECONDARYCOLORF(a,b,c)      _compat_SecondaryColor3fEXT(a,b,c)
 
 
 static void
@@ -1224,10 +1226,10 @@
 static void
 loopback_SecondaryColor3bvEXT( const GLbyte *v )
 {
-   const GLfloat r = BYTE_TO_FLOAT(v[0]);
-   const GLfloat g = BYTE_TO_FLOAT(v[1]);
-   const GLfloat b = BYTE_TO_FLOAT(v[2]);
-   SECONDARYCOLORF(r, g, b);
+   const GLfloat a = BYTE_TO_FLOAT(v[0]);
+   const GLfloat b = BYTE_TO_FLOAT(v[1]);
+   const GLfloat c = BYTE_TO_FLOAT(v[2]);
+   SECONDARYCOLORF(a,b,c);
 }
 
 static void
diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c
index 04212a6..3cec446 100644
--- a/src/mesa/tnl/t_imm_dlist.c
+++ b/src/mesa/tnl/t_imm_dlist.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_dlist.c,v 1.33 2001/12/14 02:51:45 brianp Exp $ */
+/* $Id: t_imm_dlist.c,v 1.34 2001/12/20 15:30:46 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -29,6 +29,7 @@
 
 
 #include "glheader.h"
+#include "api_compat.h"
 #include "context.h"
 #include "dlist.h"
 #include "debug.h"
@@ -597,7 +598,6 @@
       ASSERT((prim & PRIM_MODE_MASK) <= GL_POLYGON+1);
 
       if (prim & PRIM_BEGIN) {
-/*  	 fprintf(stderr, "begin %s\n", _mesa_prim_name[prim&PRIM_MODE_MASK]); */
 	 glBegin(prim & PRIM_MODE_MASK);
       }
 
@@ -611,23 +611,17 @@
 	    }
 	 }
 
-	 if (flags[i] & VERT_NORMAL_BIT) {
-/*  	       fprintf(stderr, "normal %d: %f %f %f\n", i, */
-/*  		       IM->Normal[i][0], IM->Normal[i][1], IM->Normal[i][2]);  */
+	 if (flags[i] & VERT_NORMAL_BIT) 
 	    glNormal3fv(IM->Normal[i]);
-	 }
 
-	 if (flags[i] & VERT_COLOR0_BIT) {
-/*  	       fprintf(stderr, "color %d: %f %f %f\n", i, */
-/*  		       IM->Color[i][0], IM->Color[i][1], IM->Color[i][2]);  */
+	 if (flags[i] & VERT_COLOR0_BIT) 
 	    glColor4fv( IM->Color[i] );
-	 }
 
 	 if (flags[i] & VERT_COLOR1_BIT)
-	    glSecondaryColor3fvEXT( IM->SecondaryColor[i] );
+	    _compat_SecondaryColor3fvEXT( IM->SecondaryColor[i] );
 
 	 if (flags[i] & VERT_FOG_BIT)
-	    glFogCoordfEXT( IM->FogCoord[i] );
+	    _compat_FogCoordfEXT( IM->FogCoord[i] );
 
 	 if (flags[i] & VERT_INDEX_BIT)
 	    glIndexi( IM->Index[i] );
@@ -638,11 +632,8 @@
 	 if (flags[i] & VERT_MATERIAL) 
 	    emit_material( IM->Material[i], IM->MaterialMask[i] );
 
-	 if (flags[i]&VERT_OBJ_234) {
-/*  	       fprintf(stderr, "vertex %d: %f %f %f\n", i, */
-/*  		       IM->Obj[i][0], IM->Obj[i][1], IM->Obj[i][2]); */
+	 if (flags[i]&VERT_OBJ_234) 
 	    vertex( IM->Obj[i] );
-	 }
 	 else if (flags[i] & VERT_EVAL_C1)
 	    glEvalCoord1f( IM->Obj[i][0] );
 	 else if (flags[i] & VERT_EVAL_P1)
@@ -654,7 +645,6 @@
       }
 
       if (prim & PRIM_END) {
-/*  	 fprintf(stderr, "end\n"); */
 	 glEnd();
       }
    }