Fixed includes & added a few hooks for the DRI.
diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11
index 8fb680d..da5dc45 100644
--- a/src/mesa/Makefile.X11
+++ b/src/mesa/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.5 1999/09/17 12:07:10 brianp Exp $
+# $Id: Makefile.X11,v 1.6 1999/10/08 09:27:09 keithw Exp $
 
 # Mesa 3-D graphics library
 # Version:  3.1
@@ -46,6 +46,7 @@
 	feedback.c \
 	fog.c \
 	get.c \
+	glmisc.c \
 	hash.c \
 	image.c \
 	light.c \
@@ -53,7 +54,6 @@
 	logic.c \
 	masking.c \
 	matrix.c \
-	misc.c \
 	mmath.c \
 	mthreads.c \
 	pb.c \
diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c
index 2d16048..5d0d36e 100644
--- a/src/mesa/drivers/glide/fxapi.c
+++ b/src/mesa/drivers/glide/fxapi.c
@@ -824,328 +824,196 @@
 					   GrScreenRefresh_t ref,
 					   const GLint attribList[])
 {
-  fxMesaContext fxMesa = NULL;
-  int i,type;
-  int aux;
-  GLboolean doubleBuffer=GL_FALSE;
-  GLboolean alphaBuffer=GL_FALSE;
-  GLboolean verbose=GL_FALSE;
-  GLint depthSize=0;
-  GLint stencilSize=0;
-  GLint accumSize=0;
-  GLcontext *shareCtx = NULL;
-  GLcontext *ctx = 0;
-  FX_GrContext_t glideContext = 0;
-  char *errorstr;
+   fxMesaContext fxMesa = NULL;
+   int i,type;
+   int aux;
+   GLboolean doubleBuffer=GL_FALSE;
+   GLboolean alphaBuffer=GL_FALSE;
+   GLboolean verbose=GL_FALSE;
+   GLint depthSize=0;
+   GLint stencilSize=0;
+   GLint accumSize=0;
+   GLcontext *shareCtx = NULL;
+   GLcontext *ctx = 0;
+   FX_GrContext_t glideContext = 0;
+   char *errorstr;
 
-  if (MESA_VERBOSE&VERBOSE_DRIVER) {
-    fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n");
-  }
+   if (MESA_VERBOSE&VERBOSE_DRIVER) {
+      fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n");
+   }
 
-  if(getenv("MESA_FX_INFO"))
-    verbose=GL_TRUE;
+   if(getenv("MESA_FX_INFO"))
+      verbose=GL_TRUE;
 
-  aux=0;
-  i=0;
-  while(attribList[i]!=FXMESA_NONE) {
-    switch (attribList[i]) {
-    case FXMESA_DOUBLEBUFFER:
-      doubleBuffer=GL_TRUE;
-      break;
-    case FXMESA_ALPHA_SIZE:
-      i++;
-      alphaBuffer=attribList[i]>0;
-      if(alphaBuffer)
-        aux=1;
-      break;
-    case FXMESA_DEPTH_SIZE:
-      i++;
-      depthSize=attribList[i];
-      if(depthSize)
-        aux=1;
-      break;
-    case FXMESA_STENCIL_SIZE:
-      i++;
-      stencilSize=attribList[i];
-      break;
-    case FXMESA_ACCUM_SIZE:
-      i++;
-      accumSize=attribList[i];
-      break;
-      /* XXX ugly hack here for sharing display lists */
+   aux=0;
+   i=0;
+   while(attribList[i]!=FXMESA_NONE) {
+      switch (attribList[i]) {
+      case FXMESA_DOUBLEBUFFER:
+	 doubleBuffer=GL_TRUE;
+	 break;
+      case FXMESA_ALPHA_SIZE:
+	 i++;
+	 alphaBuffer=attribList[i]>0;
+	 if(alphaBuffer)
+	    aux=1;
+	 break;
+      case FXMESA_DEPTH_SIZE:
+	 i++;
+	 depthSize=attribList[i];
+	 if(depthSize)
+	    aux=1;
+	 break;
+      case FXMESA_STENCIL_SIZE:
+	 i++;
+	 stencilSize=attribList[i];
+	 break;
+      case FXMESA_ACCUM_SIZE:
+	 i++;
+	 accumSize=attribList[i];
+	 break;
+	 /* XXX ugly hack here for sharing display lists */
 #define FXMESA_SHARE_CONTEXT 990099  /* keep in sync with xmesa1.c! */
-    case FXMESA_SHARE_CONTEXT:
+      case FXMESA_SHARE_CONTEXT:
+	 i++;
+	 {
+	    const void *vPtr = &attribList[i];
+	    GLcontext **ctx = (GLcontext **) vPtr;
+	    shareCtx = *ctx;
+	 }
+	 break;
+      default:
+	 if (MESA_VERBOSE&VERBOSE_DRIVER) {
+	    fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
+	 }
+	 return NULL;
+      }
       i++;
-      {
-        const void *vPtr = &attribList[i];
-        GLcontext **ctx = (GLcontext **) vPtr;
-        shareCtx = *ctx;
-      }
-      break;
-    default:
-      if (MESA_VERBOSE&VERBOSE_DRIVER) {
-	fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
-      }
+   }
+
+   /* A workaround for Linux GLQuake */
+   if(depthSize && alphaBuffer)
+      alphaBuffer=0;
+
+   if(verbose)
+      fprintf(stderr,"Mesa fx Voodoo Device Driver v0.30\nWritten by David Bucciarelli (davibu@tin.it.it)\n");
+
+   if((type=fxQueryHardware()) < 0) {
+      fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n");
       return NULL;
-    }
-    i++;
-  }
+   }
 
-  /* A workaround for Linux GLQuake */
-  if(depthSize && alphaBuffer)
-    alphaBuffer=0;
-
-  if(verbose)
-    fprintf(stderr,"Mesa fx Voodoo Device Driver v0.30\nWritten by David Bucciarelli (davibu@tin.it.it)\n");
-
-  if((type=fxQueryHardware()) >= 0) {
-    if(type==GR_SSTTYPE_VOODOO)
+   if(type==GR_SSTTYPE_VOODOO)
       win=0;
 
-    grSstSelect(glbCurrentBoard);
+   grSstSelect(glbCurrentBoard);
 
-#if  FXMESA_USE_ARGB
-    glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
-                     GR_COLORFORMAT_ARGB,GR_ORIGIN_LOWER_LEFT,2,aux);
-
-#else
-    glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
-                     GR_COLORFORMAT_ABGR,GR_ORIGIN_LOWER_LEFT,2,aux);
-#endif
-   if (!glideContext){
-      errorstr = "grSstWinOpen"; 
+   fxMesa=(fxMesaContext)calloc(1,sizeof(struct tfxMesaContext));
+   if(!fxMesa) {
+      errorstr = "malloc";
       goto errorhandler;
-    }
+   }
 
-    if(verbose)
+   if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO)
+      fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx > 1);
+   else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
+      fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx > 1);
+   else
+      fxMesa->haveTwoTMUs=GL_FALSE;
+
+   fxMesa->haveDoubleBuffer=doubleBuffer;
+   fxMesa->haveAlphaBuffer=alphaBuffer;
+   fxMesa->haveGlobalPaletteTexture=GL_FALSE;
+   fxMesa->haveZBuffer=depthSize ? 1 : 0;
+   fxMesa->verbose=verbose;
+   fxMesa->width=FX_grSstScreenWidth();
+   fxMesa->height=FX_grSstScreenHeight();
+   fxMesa->board=glbCurrentBoard;
+
+   if(verbose)
       fprintf(stderr,"Glide screen size: %dx%d\n",
               (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight());
-  } else {
-    fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n");
-    return NULL;
-  }
 
-  fxMesa=(fxMesaContext)calloc(1,sizeof(struct tfxMesaContext));
-  if(!fxMesa) {
-    errorstr = "malloc";
-    goto errorhandler;
-  }
+   fxMesa->glVis=gl_create_visual(GL_TRUE,     /* RGB mode */
+				  alphaBuffer,
+				  doubleBuffer,
+				  GL_FALSE,    /* stereo */
+				  depthSize,   /* depth_size */
+				  stencilSize, /* stencil_size */
+				  accumSize,   /* accum_size */
+				  0,           /* index bits */
+				  5,6,5,0);    /* RGBA bits */
+   if (!fxMesa->glVis) {
+      errorstr = "gl_create_visual";
+      goto errorhandler;
+   }
+
+   ctx = fxMesa->glCtx=gl_create_context(fxMesa->glVis,
+					 shareCtx,  /* share list context */
+					 (void *) fxMesa, GL_TRUE);
+   if (!ctx) {
+      errorstr = "gl_create_context";
+      goto errorhandler;
+   }
+
+
+   if (!fxDDInitFxMesaContext( fxMesa, win, res, ref, aux )) {
+      errorstr = "fxDDInitFxMesaContext failed"; 
+      goto errorhandler;
+   }
+
+
+   fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis);
+   if (!fxMesa->glBuffer) {
+      errorstr = "gl_create_framebuffer";
+      goto errorhandler;
+   }
   
-  FX_setupGrVertexLayout();
-  
-  fxMesa->glideContext = glideContext;
-  fxMesa->board=glbCurrentBoard;
-  fxMesa->width=FX_grSstScreenWidth();
-  fxMesa->height=FX_grSstScreenHeight();
+   glbTotNumCtx++;
 
-  fxMesa->verbose=verbose;
-
-  if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO)
-    fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx > 1);
-  else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
-    fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx > 1);
-  else
-    fxMesa->haveTwoTMUs=GL_FALSE;
-
-  if (getenv("FX_EMULATE_SINGLE_TMU")) {
-     if (MESA_VERBOSE&VERBOSE_DRIVER) 
-       fprintf(stderr, "\n\nEmulating single tmu\n\n");
-     fxMesa->haveTwoTMUs = GL_FALSE;
-  }
-
-  fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs;
-  
-  if (!getenv("FX_DONT_FAKE_MULTITEX")) {
-     if (MESA_VERBOSE&VERBOSE_DRIVER) {
-	  if (!fxMesa->haveTwoTMUs)
-	    fprintf(stderr, "\n\nEmulating multitexture\n\n");
-     }
-     fxMesa->emulateTwoTMUs = GL_TRUE;
-  }
-
-
-  fxMesa->haveDoubleBuffer=doubleBuffer;
-  fxMesa->haveAlphaBuffer=alphaBuffer;
-  fxMesa->haveGlobalPaletteTexture=GL_FALSE;
-
-  if(getenv("FX_GLIDE_SWAPINTERVAL"))
-    fxMesa->swapInterval=atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
-  else
-    fxMesa->swapInterval=1;
-
-  if(getenv("MESA_FX_SWAP_PENDING"))
-    fxMesa->maxPendingSwapBuffers=atoi(getenv("MESA_FX_SWAP_PENDING"));
-  else
-    fxMesa->maxPendingSwapBuffers=2;
-
-  fxMesa->color=0xffffffff;
-  fxMesa->clearC=0;
-  fxMesa->clearA=0;
-
-  fxMesa->stats.swapBuffer=0;
-  fxMesa->stats.reqTexUpload=0;
-  fxMesa->stats.texUpload=0;
-  fxMesa->stats.memTexUpload=0;
-
-  fxMesa->tmuSrc=FX_TMU_NONE;
-  fxMesa->lastUnitsMode=FX_UM_NONE;
-  fxTMInit(fxMesa);
-
-  /* FX units setup */
-
-  fxMesa->unitsState.alphaTestEnabled=GL_FALSE;
-  fxMesa->unitsState.alphaTestFunc=GR_CMP_ALWAYS;
-  fxMesa->unitsState.alphaTestRefValue=0;
-
-  fxMesa->unitsState.blendEnabled=GL_FALSE;
-  fxMesa->unitsState.blendSrcFuncRGB=GR_BLEND_ONE;
-  fxMesa->unitsState.blendDstFuncRGB=GR_BLEND_ZERO;
-  fxMesa->unitsState.blendSrcFuncAlpha=GR_BLEND_ONE;
-  fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO;
-
-  fxMesa->unitsState.depthTestEnabled	=GL_FALSE;
-  fxMesa->unitsState.depthMask		=GL_TRUE;
-  fxMesa->unitsState.depthTestFunc	=GR_CMP_LESS;
-
-  grColorMask(FXTRUE,alphaBuffer ? FXTRUE : FXFALSE);
-  if(doubleBuffer) {
-    fxMesa->currentFB=GR_BUFFER_BACKBUFFER;
-    grRenderBuffer(GR_BUFFER_BACKBUFFER);
-  } else {
-    fxMesa->currentFB=GR_BUFFER_FRONTBUFFER;
-    grRenderBuffer(GR_BUFFER_FRONTBUFFER);
-  }
-  
-  fxMesa->state 	= NULL;
-  fxMesa->fogTable 	= NULL;
-  
-  fxMesa->state 	= malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
-  fxMesa->fogTable 	= malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES)*sizeof(GrFog_t));
-  
-  if (!fxMesa->state || !fxMesa->fogTable) {
-     errorstr = "malloc";
-     goto errorhandler;
-  }
-
-  if(depthSize)
-    grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
-    
-#if (!FXMESA_USE_ARGB)
-  grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide supports this  */
-#endif
-
-  fxMesa->glVis=gl_create_visual(GL_TRUE,     /* RGB mode */
-                                 alphaBuffer,
-                                 doubleBuffer,
-                                 GL_FALSE,    /* stereo */
-                                 depthSize,   /* depth_size */
-                                 stencilSize, /* stencil_size */
-                                 accumSize,   /* accum_size */
-                                 0,           /* index bits */
-                                 5,6,5,0);    /* RGBA bits */
-  if (!fxMesa->glVis) {
-     errorstr = "gl_create_visual";
-     goto errorhandler;
-  }
-
-  ctx = fxMesa->glCtx=gl_create_context(fxMesa->glVis,
-					shareCtx,  /* share list context */
-					(void *) fxMesa, GL_TRUE);
-  if (!ctx) {
-     errorstr = "gl_create_context";
-     goto errorhandler;
-  }
-
-  fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis);
-  if (!fxMesa->glBuffer) {
-    errorstr = "gl_create_framebuffer";
-    goto errorhandler;
-  }
-
-  fxMesa->glCtx->Const.MaxTextureLevels=9;
-  fxMesa->glCtx->Const.MaxTextureSize=256;
-  fxMesa->glCtx->Const.MaxTextureUnits=fxMesa->emulateTwoTMUs ? 2 : 1;
-
-  fxMesa->glCtx->NewState|=NEW_DRVSTATE1;
-  fxMesa->new_state = NEW_ALL;
-  
-  fxDDSetupInit();
-  fxDDCvaInit();
-  fxDDClipInit();
-  fxDDTrifuncInit();
-  fxDDFastPathInit();
-
-  fxSetupDDPointers(fxMesa->glCtx);
-  fxDDRenderInit(fxMesa->glCtx);
-  fxDDInitExtensions(fxMesa->glCtx);  
-
-  fxDDSetNearFar(fxMesa->glCtx,1.0,100.0);
-  
-  grGlideGetState((GrState*)fxMesa->state);
-
-  /* XXX Fix me: callback not registered when main VB is created.
-   */
-  if (fxMesa->glCtx->VB) 
-     fxDDRegisterVB( fxMesa->glCtx->VB );
-  
-  /* XXX Fix me too: need to have the 'struct dd' prepared prior to
-   * creating the context... The below is broken if you try to insert
-   * new stages.  
-   */
-  if (ctx->NrPipelineStages)
-     ctx->NrPipelineStages = fxDDRegisterPipelineStages( ctx->PipelineStage,
-							 ctx->PipelineStage,
-							 ctx->NrPipelineStages);
-
-  
-  glbTotNumCtx++;
-
-  /* Run the config file */
-  gl_context_initialize( fxMesa->glCtx );
-
-  /* install signal handlers */
+   /* install signal handlers */
 #if defined(__linux__)
-  if (fxMesa->glCtx->CatchSignals) {
-     signal(SIGINT,cleangraphics_handler);
-     signal(SIGHUP,cleangraphics_handler);
-     signal(SIGPIPE,cleangraphics_handler);
-     signal(SIGFPE,cleangraphics_handler);
-     signal(SIGBUS,cleangraphics_handler);
-     signal(SIGILL,cleangraphics_handler);
-     signal(SIGSEGV,cleangraphics_handler);
-     signal(SIGTERM,cleangraphics_handler);
-  }
+   if (fxMesa->glCtx->CatchSignals) {
+      signal(SIGINT,cleangraphics_handler);
+      signal(SIGHUP,cleangraphics_handler);
+      signal(SIGPIPE,cleangraphics_handler);
+      signal(SIGFPE,cleangraphics_handler);
+      signal(SIGBUS,cleangraphics_handler);
+      signal(SIGILL,cleangraphics_handler);
+      signal(SIGSEGV,cleangraphics_handler);
+      signal(SIGTERM,cleangraphics_handler);
+   }
 #endif
 
-  if (MESA_VERBOSE&VERBOSE_DRIVER) {
-    fprintf(stderr,"fxmesa: fxMesaCreateContext() End\n");
-  }
+   if (MESA_VERBOSE&VERBOSE_DRIVER) {
+      fprintf(stderr,"fxmesa: fxMesaCreateContext() End\n");
+   }
 
-  return fxMesa;
+   return fxMesa;
 
-errorhandler:
+ errorhandler:
    if (fxMesa) {
       if (fxMesa->glideContext)
-      	FX_grSstWinClose(fxMesa->glideContext);
+	 FX_grSstWinClose(fxMesa->glideContext);
       fxMesa->glideContext = 0;
       
       if (fxMesa->state)  
-     	free(fxMesa->state);
+	 free(fxMesa->state);
       if (fxMesa->fogTable)
-     	free(fxMesa->fogTable);
+	 free(fxMesa->fogTable);
       if (fxMesa->glBuffer)
-      	gl_destroy_framebuffer(fxMesa->glBuffer);
+	 gl_destroy_framebuffer(fxMesa->glBuffer);
       if (fxMesa->glVis)
-      	gl_destroy_visual(fxMesa->glVis);
+	 gl_destroy_visual(fxMesa->glVis);
       if (fxMesa->glCtx)
-      	gl_destroy_context(fxMesa->glCtx);
+	 gl_destroy_context(fxMesa->glCtx);
       free(fxMesa);
    }
    
-  if (MESA_VERBOSE&VERBOSE_DRIVER) {
+   if (MESA_VERBOSE&VERBOSE_DRIVER) {
       fprintf(stderr,"fxmesa: fxMesaCreateContext() End (%s)\n",errorstr);
-  }
-  return NULL;
+   }
+   return NULL;
 }
 
 
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index 8ba1245..a726b0a 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -29,6 +29,7 @@
 
 #if defined(FX)
 
+#include "types.h"
 #include "fxdrv.h"
 #include "enums.h"
 #include "extensions.h"
@@ -354,55 +355,161 @@
  */
 static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
 {
-  static char *extensions="GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_logic_op GL_EXT_blend_subtract GL_EXT_paletted_texture GL_EXT_point_parameters GL_EXT_polygon_offset GL_EXT_vertex_array GL_EXT_texture_object GL_EXT_texture3D GL_MESA_window_pos GL_MESA_resize_buffers GL_EXT_shared_texture_palette GL_EXT_rescale_normal GL_EXT_abgr GL_SGIS_texture_edge_clamp 3DFX_set_global_palette GL_FXMESA_global_texture_lod_bias";
-
-  static char buf[MAX_NUM_SST][64];
-
-  fxQueryHardware();
-
-  switch (name) {
-    case GL_RENDERER:
-      if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
-        sprintf(buf[glbCurrentBoard],"Mesa Glide v0.30 Voodoo_Graphics %d CARD/%d FB/%d TM/%d TMU/%s",
-                glbCurrentBoard,
-
-                (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect ?
-                 (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam*2) :
-                 glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam),
-
-                glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.tmuConfig[GR_TMU0].tmuRam+
-                ((glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx>1) ?
-                 glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.tmuConfig[GR_TMU1].tmuRam :
-                 0),
-
-                glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx,
-
-                (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect ? "SLI" : "NOSLI")
-                );
-      }
-      else {
-        if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
-          sprintf(buf[glbCurrentBoard],"Glide v0.30 Voodoo_Rush %d CARD/%d FB/%d TM/%d TMU/NOSLI",
-                  glbCurrentBoard,
-
-                  glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam,
-
-                  glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.tmuConfig.tmuRam,
-
-                  glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx	      
-                  );
-        else
-          strcpy(buf[glbCurrentBoard],"Glide v0.30 UNKNOWN");
-      }
-      return (GLubyte *) buf[glbCurrentBoard];
-    case GL_EXTENSIONS:
-      return (GLubyte *) extensions;
-    default:
+   switch (name) {
+   case GL_RENDERER:
+#if defined(GLX_DIRECT_RENDERING)
+      return "Mesa Glide - DRI VB/V3";
+#else
+      return "Mesa Glide";
+#endif
+   default:
       return NULL;
-  }
+   }
 }
 
 
+int fxDDInitFxMesaContext( fxMesaContext fxMesa, 
+			   int win, 
+			   int res,
+			   int ref, 
+			   int aux )
+{
+   FX_GrContext_t glideContext =  FX_grSstWinOpen((FxU32)win,res,ref,
+#if  FXMESA_USE_ARGB
+						  GR_COLORFORMAT_ARGB,
+#else
+						  GR_COLORFORMAT_ABGR,
+#endif
+						  GR_ORIGIN_LOWER_LEFT,
+						  2,
+						  aux);
+   
+   if (!glideContext) return 0;
+  
+   FX_setupGrVertexLayout();
+   
+   fxMesa->glideContext = glideContext;
+   
+   if (getenv("FX_EMULATE_SINGLE_TMU")) 
+      fxMesa->haveTwoTMUs = GL_FALSE;
+      
+   fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs;
+   
+   if (!getenv("FX_DONT_FAKE_MULTITEX")) 
+      fxMesa->emulateTwoTMUs = GL_TRUE;
+      
+   if(getenv("FX_GLIDE_SWAPINTERVAL"))
+      fxMesa->swapInterval=atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
+   else
+      fxMesa->swapInterval=1;
+
+   if(getenv("MESA_FX_SWAP_PENDING"))
+      fxMesa->maxPendingSwapBuffers=atoi(getenv("MESA_FX_SWAP_PENDING"));
+   else
+      fxMesa->maxPendingSwapBuffers=2;
+   
+   fxMesa->color=0xffffffff;
+   fxMesa->clearC=0;
+   fxMesa->clearA=0;
+
+   fxMesa->stats.swapBuffer=0;
+   fxMesa->stats.reqTexUpload=0;
+   fxMesa->stats.texUpload=0;
+   fxMesa->stats.memTexUpload=0;
+
+   fxMesa->tmuSrc=FX_TMU_NONE;
+   fxMesa->lastUnitsMode=FX_UM_NONE;
+   fxTMInit(fxMesa);
+
+   /* FX units setup */
+
+   fxMesa->unitsState.alphaTestEnabled=GL_FALSE;
+   fxMesa->unitsState.alphaTestFunc=GR_CMP_ALWAYS;
+   fxMesa->unitsState.alphaTestRefValue=0;
+
+   fxMesa->unitsState.blendEnabled=GL_FALSE;
+   fxMesa->unitsState.blendSrcFuncRGB=GR_BLEND_ONE;
+   fxMesa->unitsState.blendDstFuncRGB=GR_BLEND_ZERO;
+   fxMesa->unitsState.blendSrcFuncAlpha=GR_BLEND_ONE;
+   fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO;
+
+   fxMesa->unitsState.depthTestEnabled	=GL_FALSE;
+   fxMesa->unitsState.depthMask		=GL_TRUE;
+   fxMesa->unitsState.depthTestFunc	=GR_CMP_LESS;
+
+   grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE);
+   if(fxMesa->haveDoubleBuffer) {
+      fxMesa->currentFB=GR_BUFFER_BACKBUFFER;
+      grRenderBuffer(GR_BUFFER_BACKBUFFER);
+   } else {
+      fxMesa->currentFB=GR_BUFFER_FRONTBUFFER;
+      grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+   }
+  
+   fxMesa->state 	= NULL;
+   fxMesa->fogTable 	= NULL;
+  
+   fxMesa->state 	= malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE));
+   fxMesa->fogTable 	= malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES)*sizeof(GrFog_t));
+  
+   if (!fxMesa->state || !fxMesa->fogTable) {
+      if (fxMesa->state) free(fxMesa->state);
+      if (fxMesa->fogTable) free(fxMesa->fogTable);
+      return 0;
+   }
+
+   if(fxMesa->haveZBuffer)
+      grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
+    
+#if (!FXMESA_USE_ARGB)
+   grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this  */
+#endif
+
+   fxMesa->glCtx->Const.MaxTextureLevels=9;
+   fxMesa->glCtx->Const.MaxTextureSize=256;
+   fxMesa->glCtx->Const.MaxTextureUnits=fxMesa->emulateTwoTMUs ? 2 : 1;
+   fxMesa->glCtx->NewState|=NEW_DRVSTATE1;
+   fxMesa->new_state = NEW_ALL;
+  
+   fxDDSetupInit();
+   fxDDCvaInit();
+   fxDDClipInit();
+   fxDDTrifuncInit();
+   fxDDFastPathInit();
+
+   fxSetupDDPointers(fxMesa->glCtx);
+   fxDDRenderInit(fxMesa->glCtx);
+   fxDDInitExtensions(fxMesa->glCtx);  
+
+   fxDDSetNearFar(fxMesa->glCtx,1.0,100.0);
+  
+   grGlideGetState((GrState*)fxMesa->state);
+
+   /* XXX Fix me: callback not registered when main VB is created.
+    */
+   if (fxMesa->glCtx->VB) 
+      fxDDRegisterVB( fxMesa->glCtx->VB );
+  
+   /* XXX Fix me too: need to have the 'struct dd' prepared prior to
+    * creating the context... The below is broken if you try to insert
+    * new stages.  
+    */
+   if (fxMesa->glCtx->NrPipelineStages)
+      fxMesa->glCtx->NrPipelineStages = fxDDRegisterPipelineStages( 
+	 fxMesa->glCtx->PipelineStage,
+	 fxMesa->glCtx->PipelineStage,
+	 fxMesa->glCtx->NrPipelineStages);
+
+   /* Run the config file */
+   gl_context_initialize( fxMesa->glCtx );
+
+   return 1;
+}
+
+
+
+
+
 void fxDDInitExtensions( GLcontext *ctx )
 {
    fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index 92d867b..3559ad9 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -29,11 +29,16 @@
  * you turn debugging on/off from the debugger.
  */
 
+#ifndef XFree86Server
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
 #include <assert.h>
+#else 
+#include "GL/xf86glx.h"
+#endif
+
 
 #if defined(__linux__)
 #include <signal.h>
@@ -378,9 +383,15 @@
 };
 
 #define FX_DRIVER_DATA(vb) ((struct tfxMesaVertexBuffer *)((vb)->driver_data))
-#define FX_CONTEXT(ctx) ((struct tfxMesaContext *)((ctx)->DriverCtx))
+#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
 #define FX_TEXTURE_DATA(t) ((tfxTexInfo *) ((t)->Current->DriverData))
 
+#if defined(XFree86Server) || defined(GLX_DIRECT_RENDERING)
+#include "tdfx_init.h"
+#else
+#define DRI_FX_CONTEXT
+#endif
+
 struct tfxMesaContext {
   GuTexPalette glbPalette;
 
@@ -458,12 +469,16 @@
   GLboolean haveTwoTMUs;	/* True if we really have 2 tmu's  */
   GLboolean emulateTwoTMUs;	/* True if we present 2 tmu's to mesa.  */
   GLboolean haveAlphaBuffer;
+  GLboolean haveZBuffer;
   GLboolean haveDoubleBuffer;
   GLboolean haveGlobalPaletteTexture;
   GLint swapInterval;
   GLint maxPendingSwapBuffers;
   
   FX_GrContext_t glideContext;
+
+  DRI_FX_CONTEXT
+
 };
 
 typedef void (*tfxSetupFunc)(struct vertex_buffer *, GLuint, GLuint);
@@ -475,10 +490,10 @@
 extern void fxSetupDDPointers(GLcontext *);
 extern void fxDDSetNearFar(GLcontext *, GLfloat, GLfloat);
 
-extern void fxDDSetupInit();
-extern void fxDDCvaInit();
-extern void fxDDTrifuncInit();
-extern void fxDDFastPathInit();
+extern void fxDDSetupInit(void);
+extern void fxDDCvaInit(void);
+extern void fxDDTrifuncInit(void);
+extern void fxDDFastPathInit(void);
 
 extern void fxDDChooseRenderState( GLcontext *ctx );
 
@@ -498,7 +513,7 @@
 extern render_func **fxDDChooseRenderVBTables(GLcontext *);
 
 extern void fxDDRenderInit(GLcontext *);
-extern void fxDDClipInit();
+extern void fxDDClipInit(void);
 
 extern void fxUpdateDDSpanPointers(GLcontext *);
 extern void fxSetupDDSpanPointers(GLcontext *);
@@ -554,8 +569,8 @@
 
 extern void fxDDInitExtensions( GLcontext *ctx );
 
-extern void fxTMInit(fxMesaContext);
-extern void fxTMClose(fxMesaContext);
+extern void fxTMInit(fxMesaContext ctx);
+extern void fxTMClose(fxMesaContext ctx);
 extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
 extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
 extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
@@ -603,5 +618,7 @@
 
 extern void fxDDDoRenderVB( struct vertex_buffer *VB );
 
+extern int fxDDInitFxMesaContext( fxMesaContext fxMesa, 
+				  int win, int res, int ref, int aux );
 
 #endif
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 256a47f..4dc8425 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -1,4 +1,4 @@
-/* $Id: xmesaP.h,v 1.1 1999/08/19 00:55:42 jtg Exp $ */
+/* $Id: xmesaP.h,v 1.2 1999/10/08 09:27:12 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -23,6 +23,9 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+/* $XFree86: xc/lib/GL/mesa/src/X/xmesaP.h,v 1.5 1999/07/06 14:51:28 dawes Exp $ */
+
+
 
 
 #ifndef XMESAP_H
@@ -30,20 +33,33 @@
 
 
 #ifdef XFree86Server
-#include "xf86glx_util.h"
+# include "GL/xf86glx.h"
+# include "xf86glx_util.h"
 #else
-#ifdef SHM
-#include <X11/extensions/XShm.h>
-#endif
+# ifdef GLX_DIRECT_RENDERING
+#  include "dri_mesa.h"
+# endif
+# ifdef SHM
+#  include <X11/extensions/XShm.h>
+# endif
 #endif
 #include "GL/xmesa.h"
 #include "types.h"
-#ifdef FX
+#if defined(FX) && !defined(GLX_DIRECT_RENDERING)
 #include "GL/fxmesa.h"
 #include "../FX/fxdrv.h"
 #endif
 
 
+#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
+#  include "xdriP.h"
+#else
+#  define DRI_DRAWABLE_ARG
+#  define DRI_DRAWABLE_PARM
+#  define DRI_CTX_ARG
+#endif
+
+
 /* for PF_8R8G8B24 pixel format */
 typedef struct {
    GLubyte b;
@@ -52,13 +68,17 @@
 } bgr_t;
 
 
+
+
 /*
  * "Derived" from gl_visual.  Basically corresponds to an XVisualInfo.
  */
 struct xmesa_visual {
    GLvisual *gl_visual;		/* Device independent visual parameters */
    XMesaDisplay *display;	/* The X11 display */
-#ifndef XFree86Server
+#ifdef XFree86Server
+   GLint screen_depth;	/* The depth of the screen */
+#else
    XVisualInfo *vishandle;	/* The pointer returned by glXChooseVisual */
 #endif
    XMesaVisualInfo visinfo;	/* X's visual info */
@@ -119,6 +139,13 @@
 
    GLubyte clearcolor[4];		/* current clearing color */
    unsigned long clearpixel;		/* current clearing pixel value */
+
+#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
+  __DRIcontextPrivate *driContextPriv; /* back pointer to DRI context
+					* used for locking
+					*/
+  void *private;			/* device-specific private context */
+#endif
 };
 
 
@@ -194,7 +221,14 @@
    int num_alloced;
    unsigned long alloced_colors[256];
 
-#ifdef FX
+#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
+  __DRIdrawablePrivate *driDrawPriv;	/* back pointer to DRI drawable
+					 * used for direct access to framebuffer
+					 */
+  void *private;			/* device-specific private drawable */
+#endif
+
+#if defined( FX ) && !defined(GLX_DIRECT_RENDERING)
    /* For 3Dfx Glide only */
    GLboolean FXisHackUsable;	/* Can we render into window? */
    GLboolean FXwindowHack;	/* Are we rendering into a window? */
@@ -278,6 +312,7 @@
 
 
 
+
 /*
  * If pixelformat==PF_DITHER:
  *
@@ -287,6 +322,7 @@
 #undef _R
 #undef _G
 #undef _B
+#undef _D
 #ifdef DITHER666
 # define _R   6
 # define _G   6
@@ -484,8 +520,9 @@
 /* XXX this is a hack to implement shared display lists with 3Dfx */
 extern XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v,
 					     XMesaWindow w,
-					     XMesaContext c );
-
+					     XMesaContext c
+					     DRI_DRAWABLE_ARG
+					   );
 
 /*
  * These are the extra routines required for integration with XFree86.
diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ
index 27c3556..73ffcf1 100644
--- a/src/mesa/main/Makefile.DJ
+++ b/src/mesa/main/Makefile.DJ
@@ -1,4 +1,4 @@
-# $Id: Makefile.DJ,v 1.1 1999/08/19 00:55:41 jtg Exp $
+# $Id: Makefile.DJ,v 1.2 1999/10/08 09:27:09 keithw Exp $
 
 # Makefile for core library for MS-DOS using djgpp
 
@@ -22,8 +22,11 @@
 
 
 # $Log: Makefile.DJ,v $
-# Revision 1.1  1999/08/19 00:55:41  jtg
-# Initial revision
+# Revision 1.2  1999/10/08 09:27:09  keithw
+# Fixed includes & added a few hooks for the DRI.
+#
+# Revision 1.1.1.1  1999/08/19 00:55:41  jtg
+# Imported sources
 #
 # Revision 1.1  1999/01/01 14:35:09  brianp
 # Initial revision
@@ -48,7 +51,7 @@
 	bitmap.c blend.c clip.c colortab.c context.c copypix.c depth.c \
 	dlist.c drawpix.c enable.c eval.c feedback.c fog.c \
 	get.c hash.c image.c light.c lines.c logic.c masking.c matrix.c \
-	misc.c mmath.c mthreads.c pb.c pixel.c points.c pointers.c polygon.c \
+	glmisc.c mmath.c mthreads.c pb.c pixel.c points.c pointers.c polygon.c \
 	quads.c rastpos.c readpix.c rect.c scissor.c shade.c span.c \
 	stencil.c teximage.c texobj.c texstate.c texture.c triangle.c \
 	varray.c winpos.c vb.c vbfill.c vbrender.c vbxform.c xform.c \
diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11
index 8fb680d..da5dc45 100644
--- a/src/mesa/main/Makefile.X11
+++ b/src/mesa/main/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.5 1999/09/17 12:07:10 brianp Exp $
+# $Id: Makefile.X11,v 1.6 1999/10/08 09:27:09 keithw Exp $
 
 # Mesa 3-D graphics library
 # Version:  3.1
@@ -46,6 +46,7 @@
 	feedback.c \
 	fog.c \
 	get.c \
+	glmisc.c \
 	hash.c \
 	image.c \
 	light.c \
@@ -53,7 +54,6 @@
 	logic.c \
 	masking.c \
 	matrix.c \
-	misc.c \
 	mmath.c \
 	mthreads.c \
 	pb.c \
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index 2043075..2e4f7c8 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -1,4 +1,4 @@
-/* $Id: accum.c,v 1.2 1999/08/19 11:54:28 brianp Exp $ */
+/* $Id: accum.c,v 1.3 1999/10/08 09:27:09 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,14 +25,18 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/accum.c,v 1.3 1999/04/04 00:20:17 dawes Exp $ */
 
 #ifdef PC_HEADER
 #include "all.h"
 #else
-#include <assert.h>
+#ifndef XFree86Server
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "accum.h"
 #include "context.h"
 #include "macros.h"
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 80aee7b..e0aeec8 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.4 1999/09/19 23:43:02 keithw Exp $ */
+/* $Id: attrib.c,v 1.5 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,15 +31,19 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "attrib.h"
 #include "context.h"
+#include "glmisc.h"
 #include "enable.h"
 #include "enums.h"
 #include "macros.h"
-#include "misc.h"
 #include "simple_list.h"
 #include "texstate.h"
 #include "types.h"
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 6bf3581..7e10370 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -1,4 +1,4 @@
-/* $Id: blend.c,v 1.3 1999/09/30 11:18:21 keithw Exp $ */
+/* $Id: blend.c,v 1.4 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -29,9 +29,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#include <stdio.h>
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdlib.h>
-#include <stdio.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "alphabuf.h"
 #include "blend.h"
 #include "context.h"
diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index 02b97ae..85cbd06 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -1,4 +1,4 @@
-/* $Id: clip.c,v 1.2 1999/09/18 20:41:22 keithw Exp $ */
+/* $Id: clip.c,v 1.3 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,9 +31,12 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <string.h>
 #include <stdlib.h>
-#include <stdio.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "clip.h"
 #include "context.h"
 #include "macros.h"
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 22d785b..7d167e1 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: colortab.c,v 1.2 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -23,6 +23,7 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+/* $XFree86: xc/lib/GL/mesa/src/colortab.c,v 1.2 1999/04/04 00:20:21 dawes Exp $ */
 
 
 
@@ -31,6 +32,9 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifdef XFree86Server
+#include "GL/xf86glx.h"
+#endif
 #include "colortab.h"
 #include "context.h"
 #include "macros.h"
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d7f751d..47cba24 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.9 1999/09/19 23:43:02 keithw Exp $ */
+/* $Id: context.c,v 1.10 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,6 +25,8 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/context.c,v 1.4 1999/04/04 00:20:21 dawes Exp $ */
+
 /*
  * If multi-threading is enabled (-DTHREADS) then each thread has it's
  * own rendering context.  A thread obtains the pointer to its GLcontext
@@ -38,11 +40,15 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "accum.h"
 #include "alphabuf.h"
 #include "api.h"
diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c
index 7fac718..0dfab9a 100644
--- a/src/mesa/main/depth.c
+++ b/src/mesa/main/depth.c
@@ -1,4 +1,4 @@
-/* $Id: depth.c,v 1.3 1999/09/19 23:43:02 keithw Exp $ */
+/* $Id: depth.c,v 1.4 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,6 +25,8 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/depth.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */
+
 /*
  * Depth buffer functions
  */
@@ -33,9 +35,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enums.h"
 #include "depth.h"
diff --git a/src/mesa/main/depth.h b/src/mesa/main/depth.h
index 559afc6..86706ee 100644
--- a/src/mesa/main/depth.h
+++ b/src/mesa/main/depth.h
@@ -1,4 +1,5 @@
-/* $Id: depth.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+
+/* $Id: depth.h,v 1.2 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 60547dc..b1a4ed0 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.5 1999/09/20 14:30:22 keithw Exp $ */
+/* $Id: dlist.c,v 1.6 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,13 +25,19 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/dlist.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "accum.h"
 #include "api.h"
 #include "alpha.h"
@@ -52,6 +58,7 @@
 #include "feedback.h"
 #include "fog.h"
 #include "get.h"
+#include "glmisc.h"
 #include "hash.h"
 #include "image.h"
 #include "light.h"
@@ -61,7 +68,6 @@
 #include "macros.h"
 #include "masking.h"
 #include "matrix.h"
-#include "misc.h"
 #include "pipeline.h"
 #include "pixel.h"
 #include "points.h"
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index edf5244..02016d1 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.2 1999/09/18 20:41:22 keithw Exp $ */
+/* $Id: drawpix.c,v 1.3 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,9 +31,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "drawpix.h"
 #include "feedback.h"
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index ac916d6..9de6fe5 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.5 1999/09/18 20:41:23 keithw Exp $ */
+/* $Id: enable.c,v 1.6 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,11 +25,17 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/enable.c,v 1.3 1999/04/04 00:20:23 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
-#include <string.h>
+#ifndef XFree86Server
 #include <stdio.h>
+#include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enable.h"
 #include "light.h"
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 74604a2..4d5b067 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -1,4 +1,4 @@
-/* $Id: eval.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: eval.c,v 1.2 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -44,9 +44,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "eval.h"
 #include "macros.h"
@@ -1988,7 +1992,7 @@
 
 
 
-void eval_points1( GLfloat outcoord[][4], 
+static void eval_points1( GLfloat outcoord[][4], 
 		   GLfloat coord[][4],
 		   const GLuint *flags,
 		   GLfloat du, GLfloat u1 )
@@ -2003,7 +2007,7 @@
       }
 }
 
-void eval_points2( GLfloat outcoord[][4], 
+static void eval_points2( GLfloat outcoord[][4], 
 		   GLfloat coord[][4],
 		   const GLuint *flags,
 		   GLfloat du, GLfloat u1,
@@ -2030,11 +2034,11 @@
 };
 
 
-GLvector4f *eval1_4f( GLvector4f *dest, 
-		      GLfloat coord[][4], 
-		      const GLuint *flags, 
-		      GLuint dimension,
-		      struct gl_1d_map *map )
+static GLvector4f *eval1_4f( GLvector4f *dest, 
+			     GLfloat coord[][4], 
+			     const GLuint *flags, 
+			     GLuint dimension,
+			     struct gl_1d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2055,10 +2059,10 @@
 }
 
 
-GLvector1ui *eval1_1ui( GLvector1ui *dest, 
-		       GLfloat coord[][4], 
-		       const GLuint *flags, 
-		       struct gl_1d_map *map )
+static GLvector1ui *eval1_1ui( GLvector1ui *dest, 
+			       GLfloat coord[][4], 
+			       const GLuint *flags, 
+			       struct gl_1d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2077,7 +2081,7 @@
    return dest;
 }
 
-GLvector3f *eval1_norm( GLvector3f *dest, 
+static GLvector3f *eval1_norm( GLvector3f *dest, 
 			GLfloat coord[][4],
 			GLuint *flags, /* not const */
 			struct gl_1d_map *map )
@@ -2098,7 +2102,7 @@
    return dest;
 }
 
-GLvector4ub *eval1_color( GLvector4ub *dest, 
+static GLvector4ub *eval1_color( GLvector4ub *dest, 
 			  GLfloat coord[][4],
 			  GLuint *flags, /* not const */
 			  struct gl_1d_map *map )
@@ -2124,12 +2128,12 @@
 
 
 
-GLvector4f *eval2_obj_norm( GLvector4f *obj_ptr, 
-			    GLvector3f *norm_ptr,
-			    GLfloat coord[][4], 
-			    GLuint *flags, 
-			    GLuint dimension,
-			    struct gl_2d_map *map )
+static GLvector4f *eval2_obj_norm( GLvector4f *obj_ptr, 
+				   GLvector3f *norm_ptr,
+				   GLfloat coord[][4], 
+				   GLuint *flags, 
+				   GLuint dimension,
+				   struct gl_2d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2161,11 +2165,11 @@
 }
 
 
-GLvector4f *eval2_4f( GLvector4f *dest, 
-		      GLfloat coord[][4], 
-		      const GLuint *flags, 
-		      GLuint dimension,
-		      struct gl_2d_map *map )
+static GLvector4f *eval2_4f( GLvector4f *dest, 
+			     GLfloat coord[][4], 
+			     const GLuint *flags, 
+			     GLuint dimension,
+			     struct gl_2d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2189,10 +2193,10 @@
 }
 
 
-GLvector3f *eval2_norm( GLvector3f *dest, 
-			GLfloat coord[][4], 
-			GLuint *flags, 
-			struct gl_2d_map *map )
+static GLvector3f *eval2_norm( GLvector3f *dest, 
+			       GLfloat coord[][4], 
+			       GLuint *flags, 
+			       struct gl_2d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2215,10 +2219,10 @@
 }
 
 
-GLvector1ui *eval2_1ui( GLvector1ui *dest, 
-		       GLfloat coord[][4], 
-		       const GLuint *flags, 
-		       struct gl_2d_map *map )
+static GLvector1ui *eval2_1ui( GLvector1ui *dest, 
+			       GLfloat coord[][4], 
+			       const GLuint *flags, 
+			       struct gl_2d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2244,10 +2248,10 @@
 
 
 
-GLvector4ub *eval2_color( GLvector4ub *dest,
-			  GLfloat coord[][4], 
-			  GLuint *flags,
-			  struct gl_2d_map *map )
+static GLvector4ub *eval2_color( GLvector4ub *dest,
+				 GLfloat coord[][4], 
+				 GLuint *flags,
+				 struct gl_2d_map *map )
 {
    const GLfloat u1 = map->u1;
    const GLfloat du = map->du;
@@ -2272,8 +2276,8 @@
 }
 
 
-GLvector4f *copy_4f( GLvector4f *out, CONST GLvector4f *in, 
-		     const GLuint *flags)
+static GLvector4f *copy_4f( GLvector4f *out, CONST GLvector4f *in, 
+			    const GLuint *flags)
 {
    GLfloat (*to)[4] = out->data;
    GLfloat (*from)[4] = in->data;
@@ -2286,8 +2290,8 @@
    return out;
 }
 
-GLvector3f *copy_3f( GLvector3f *out, CONST GLvector3f *in, 
-		     const GLuint *flags)
+static GLvector3f *copy_3f( GLvector3f *out, CONST GLvector3f *in, 
+			    const GLuint *flags)
 {
    GLfloat (*to)[3] = out->data;
    GLfloat (*from)[3] = in->data;
@@ -2300,8 +2304,8 @@
    return out;
 }
 
-GLvector4ub *copy_4ub( GLvector4ub *out, CONST GLvector4ub *in, 
-		       const GLuint *flags )
+static GLvector4ub *copy_4ub( GLvector4ub *out, CONST GLvector4ub *in, 
+			      const GLuint *flags )
 {
    GLubyte (*to)[4] = out->data;
    GLubyte (*from)[4] = in->data;
@@ -2314,8 +2318,8 @@
    return out;
 }
 
-GLvector1ui *copy_1ui( GLvector1ui *out, CONST GLvector1ui *in, 
-		       const GLuint *flags )
+static GLvector1ui *copy_1ui( GLvector1ui *out, CONST GLvector1ui *in, 
+			      const GLuint *flags )
 {
    GLuint *to = out->data;
    CONST GLuint *from = in->data;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 3130cac..803b650 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.4 1999/09/16 16:47:35 brianp Exp $ */
+/* $Id: extensions.c,v 1.5 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -46,10 +46,11 @@
 
 static struct { int enabled; const char *name; } default_extensions[] = {
    { ALWAYS_ENABLED, "GL_EXT_blend_color" },
-   { ALWAYS_ENABLED, "GL_EXT_blend_minmax" },
-   { ALWAYS_ENABLED, "GL_EXT_blend_logic_op" },
-   { ALWAYS_ENABLED, "GL_EXT_blend_subtract" },
-   { ALWAYS_ENABLED, "GL_EXT_paletted_texture" },
+   { DEFAULT_OFF,    "ARB_imaging" },
+   { DEFAULT_ON,     "GL_EXT_blend_minmax" },
+   { DEFAULT_ON,     "GL_EXT_blend_logic_op" },
+   { DEFAULT_ON,     "GL_EXT_blend_subtract" },
+   { DEFAULT_ON,     "GL_EXT_paletted_texture" },
    { DEFAULT_ON,     "GL_EXT_point_parameters" },
    { ALWAYS_ENABLED, "GL_EXT_polygon_offset" },
    { ALWAYS_ENABLED, "GL_EXT_vertex_array" },
@@ -62,7 +63,7 @@
    { ALWAYS_ENABLED, "GL_EXT_abgr" },
    { ALWAYS_ENABLED, "GL_SGIS_texture_edge_clamp" },
    { ALWAYS_ENABLED, "GL_EXT_stencil_wrap" },
-   { ALWAYS_ENABLED, "GL_INGR_blend_func_separate" },
+   { DEFAULT_ON,     "GL_INGR_blend_func_separate" },
    { DEFAULT_ON,     "GL_ARB_multitexture" },
    { ALWAYS_ENABLED, "GL_NV_texgen_reflection" },
    { DEFAULT_ON,     "GL_PGI_misc_hints" },
@@ -140,6 +141,7 @@
 
    if (ctx->Extensions.ext_list) {
       foreach_s( i, nexti, ctx->Extensions.ext_list ) {
+	 remove_from_list( i );
 	 free( i );
       }
    
@@ -205,7 +207,7 @@
  * Also, this function does not yet do per-context function searches.
  * Not applicable to Mesa at this time.
  */
-GLfunction gl_GetProcAddress( GLcontext *ctx, const GLubyte *procName )
+void (* gl_GetProcAddress( GLcontext *ctx, const GLubyte *procName ))()
 {
    struct proc {
       const char *name;
diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h
index 7663f43..ded2bae 100644
--- a/src/mesa/main/extensions.h
+++ b/src/mesa/main/extensions.h
@@ -1,4 +1,4 @@
-/* $Id: extensions.h,v 1.3 1999/09/11 11:48:11 brianp Exp $ */
+/* $Id: extensions.h,v 1.4 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -38,7 +38,7 @@
 /* Return 0 on success.
  */
 extern int gl_extensions_add( struct gl_context *ctx, int state, 
-			      const char *name, void (*notify)() );
+			      const char *name, void (*notify)( void ) );
 
 extern int gl_extensions_enable( struct gl_context *ctx, const char *name );
 extern int gl_extensions_disable( struct gl_context *ctx, const char *name );
@@ -46,7 +46,7 @@
 extern void gl_extensions_ctr( struct gl_context *ctx );
 extern const char *gl_extensions_get_string( struct gl_context *ctx );
 
-extern GLfunction gl_GetProcAddress( GLcontext *ctx, const GLubyte *procName );
+extern void (*gl_GetProcAddress( GLcontext *ctx, const GLubyte *procName ))( void );
 
 #endif
 
diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c
index 0fb09d0..ae5943c 100644
--- a/src/mesa/main/feedback.c
+++ b/src/mesa/main/feedback.c
@@ -1,4 +1,4 @@
-/* $Id: feedback.c,v 1.3 1999/09/19 02:03:19 tjump Exp $ */
+/* $Id: feedback.c,v 1.4 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,8 +31,12 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enums.h"
 #include "feedback.h"
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index 1579c8c..26da3f7 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -1,4 +1,4 @@
-/* $Id: fog.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: fog.c,v 1.2 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,11 +25,17 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/fog.c,v 1.4 1999/04/04 00:20:24 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <math.h>
 #include <stdlib.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "fog.h"
 #include "macros.h"
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 1fb3e6e..90df613 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.3 1999/09/16 15:46:05 brianp Exp $ */
+/* $Id: get.c,v 1.4 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,12 +25,18 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/get.c,v 1.3 1999/04/04 00:20:25 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enable.h"
 #include "enums.h"
@@ -40,9 +46,6 @@
 #include "mmath.h"
 #include "types.h"
 #include "vb.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index 3d533c8..ce5fdee 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: hash.c,v 1.2 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,13 +31,14 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "hash.h"
-#ifdef XFree86Server
+#else
 #include "GL/xf86glx.h"
 #endif
+#include "hash.h"
 #endif
 
 
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index bac0c66..acdce62 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.2 1999/09/15 13:56:44 brianp Exp $ */
+/* $Id: image.c,v 1.3 1999/10/08 09:27:10 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -29,9 +29,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "image.h"
 #include "macros.h"
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 715084b..a9a125b 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.3 1999/09/30 11:18:22 keithw Exp $ */
+/* $Id: light.c,v 1.4 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,10 +31,15 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#include <float.h>
+#ifndef XFree86Server
 #include <assert.h>
 #include <float.h>
 #include <math.h>
 #include <stdlib.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include <stdio.h>
 #include "context.h"
 #include "enums.h"
@@ -46,9 +51,6 @@
 #include "types.h"
 #include "vb.h"
 #include "xform.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
index cee566e..505bf46 100644
--- a/src/mesa/main/lines.c
+++ b/src/mesa/main/lines.c
@@ -1,4 +1,4 @@
-/* $Id: lines.c,v 1.2 1999/09/18 20:41:23 keithw Exp $ */
+/* $Id: lines.c,v 1.3 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,7 +31,11 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "depth.h"
 #include "feedback.h"
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 61e8974..e47b85f 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -1,4 +1,4 @@
-/* $Id: macros.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: macros.h,v 1.2 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -36,9 +36,12 @@
 #ifndef MACROS_H
 #define MACROS_H
 
-
+#if defined( XFree86LOADER ) && defined( XFree86Server )
+#include <GL/glx_ansic.h>
+#else
 #include <math.h>
 #include <string.h>
+#endif
 
 
 #ifdef DEBUG
@@ -49,7 +52,7 @@
 #endif
 
 
-#if defined(__GNUC__) || defined(__MWERKS__)
+#if defined(__GNUC__)
 #define INLINE __inline__
 #elif defined(__MSC__)
 #define INLINE __inline
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index b15b721..154a038 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.4 1999/09/19 23:06:40 keithw Exp $ */
+/* $Id: matrix.c,v 1.5 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -43,10 +43,14 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enums.h"
 #include "macros.h"
@@ -298,7 +302,7 @@
 
 /* Adapted from graphics gems II.
  */  
-GLboolean invert_matrix_3d_general( GLmatrix *mat )
+static GLboolean invert_matrix_3d_general( GLmatrix *mat )
 {
    const GLfloat *in = mat->m;
    GLfloat *out = mat->inv;
diff --git a/src/mesa/main/matrix.h b/src/mesa/main/matrix.h
index f89993e..fcc630f 100644
--- a/src/mesa/main/matrix.h
+++ b/src/mesa/main/matrix.h
@@ -1,4 +1,4 @@
-/* $Id: matrix.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: matrix.h,v 1.2 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -111,5 +111,9 @@
 extern void gl_matrix_analyze( GLmatrix *mat );
 
 
+extern void gl_MultMatrixd( GLcontext *ctx, const GLdouble *m );
+extern GLboolean gl_matrix_invert( GLmatrix *mat );
+extern void gl_print_matrix( const GLmatrix *m );
+
 
 #endif
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 316c357..90257b7 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: pixel.c,v 1.2 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -36,9 +36,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "macros.h"
 #include "pixel.h"
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index 6690b2a..43c4b88 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -1,4 +1,4 @@
-/* $Id: points.c,v 1.2 1999/09/18 20:41:23 keithw Exp $ */
+/* $Id: points.c,v 1.3 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -23,6 +23,7 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+/* $XFree86: xc/lib/GL/mesa/src/points.c,v 1.4 1999/04/04 00:20:29 dawes Exp $ */
 
 
 
@@ -31,18 +32,22 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
+#include <math.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "feedback.h"
 #include "macros.h"
+#include "mmath.h"
 #include "pb.h"
+#include "points.h"
 #include "span.h"
 #include "texstate.h"
 #include "types.h"
 #include "vb.h"
 #include "mmath.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index 00876feb..00fe2f1 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -1,4 +1,4 @@
-/* $Id: polygon.c,v 1.3 1999/09/20 14:30:22 keithw Exp $ */
+/* $Id: polygon.c,v 1.4 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,13 +25,19 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/polygon.c,v 1.3 1999/04/04 00:20:29 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "image.h"
 #include "enums.h"
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 000af37..217cfc0 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -1,4 +1,4 @@
-/* $Id: rastpos.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: rastpos.c,v 1.2 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -31,22 +31,24 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
+#include <math.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "clip.h"
+#include "context.h"
 #include "feedback.h"
 #include "light.h"
 #include "macros.h"
 #include "matrix.h"
 #include "mmath.h"
+#include "rastpos.h"
 #include "shade.h"
 #include "types.h"
 #include "xform.h"
-#include "context.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
 #endif
-#endif
-
 
 
 /*
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c
index 8bcced1..95dbfbf 100644
--- a/src/mesa/main/stencil.c
+++ b/src/mesa/main/stencil.c
@@ -1,4 +1,4 @@
-/* $Id: stencil.c,v 1.3 1999/09/19 02:03:19 tjump Exp $ */
+/* $Id: stencil.c,v 1.4 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,11 +25,17 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/stencil.c,v 1.3 1999/04/04 00:20:32 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "macros.h"
 #include "pb.h"
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f2f301e..aa3fbbb 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: teximage.c,v 1.2 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -25,13 +25,19 @@
  */
 
 
+/* $XFree86: xc/lib/GL/mesa/src/teximage.c,v 1.3 1999/04/04 00:20:32 dawes Exp $ */
+
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "image.h"
 #include "macros.h"
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index d94618d..0d2f5dd 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.2 1999/09/30 11:18:22 keithw Exp $ */
+/* $Id: texobj.c,v 1.3 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -23,7 +23,7 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-
+/* $XFree86: xc/lib/GL/mesa/src/texobj.c,v 1.3 1999/04/04 00:20:32 dawes Exp $ */
 
 
 
@@ -31,9 +31,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enums.h"
 #include "hash.h"
@@ -42,9 +46,6 @@
 #include "texstate.h"
 #include "texobj.h"
 #include "types.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 1b19a38..0a828ce 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.2 1999/09/07 22:31:30 brianp Exp $ */
+/* $Id: texstate.c,v 1.3 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -29,8 +29,12 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <assert.h>
 #include <stdio.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "enums.h"
 #include "macros.h"
@@ -40,9 +44,6 @@
 #include "texture.h"
 #include "types.h"
 #include "xform.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index fb8510e..f11ce2d 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,4 +1,4 @@
-/* $Id: varray.c,v 1.3 1999/09/07 22:31:30 brianp Exp $ */
+/* $Id: varray.c,v 1.4 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -27,9 +27,13 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
+#ifndef XFree86Server
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#else
+#include "GL/xf86glx.h"
+#endif
 #include "context.h"
 #include "api.h"
 #include "cva.h"
@@ -55,6 +59,11 @@
 #endif
 #endif
 
+#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) && !defined(GLX_USE_DLOPEN)
+#define NEED_MESA_FUNCS_WRAPPED
+#include "mesa_api.h"
+#endif
+
 
 void GLAPIENTRY glVertexPointer(CTX_ARG GLint size, GLenum type, GLsizei stride,
                                  const GLvoid *ptr )
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 6e1fd75..3085c42 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -1,4 +1,4 @@
-/* $Id: varray.h,v 1.2 1999/09/09 23:48:02 brianp Exp $ */
+/* $Id: varray.h,v 1.3 1999/10/08 09:27:11 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -60,6 +60,10 @@
                                 GLsizei stride, const GLboolean *ptr );
 
 
+extern void gl_GetPointerv( GLcontext *ctx, GLenum pname, GLvoid **params );
+
+
+
 extern void gl_DrawArrays( GLcontext *ctx,
                            GLenum mode, GLint first, GLsizei count );
 
@@ -89,7 +93,6 @@
                                   GLuint end, GLsizei count, GLenum type,
                                   const GLvoid *indices );
 
-
 extern void gl_save_DrawRangeElements( GLcontext *ctx, GLenum mode,
                                        GLuint start, GLuint end, GLsizei count,
                                        GLenum type, const GLvoid *indices );