Some initial RGB and RGBA floating point texture formats.
[mesa.git] / src / mesa / main / dlist.c
index fe5241587dfdcfdb4eea6d436aba8254c5cef9f4..386744fdea918c4131d2f041fe3aada6a4593745 100644 (file)
@@ -1,10 +1,13 @@
-/* $Id: dlist.c,v 1.76 2001/09/18 16:16:21 kschultz Exp $ */
+/**
+ * \file dlist.c
+ * Display lists management functions.
+ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  6.0
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
  */
 
 
-#ifdef PC_HEADER
-#include "all.h"
-#else
 #include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
 #include "api_loopback.h"
+#include "config.h"
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+#include "arbprogram.h"
+#include "program.h"
+#endif
 #include "attrib.h"
 #include "blend.h"
 #include "buffers.h"
+#if FEATURE_ARB_vertex_buffer_object
+#include "bufferobj.h"
+#endif
 #include "clip.h"
 #include "colormac.h"
 #include "colortab.h"
@@ -55,7 +65,6 @@
 #include "dlist.h"
 #include "macros.h"
 #include "matrix.h"
-#include "mem.h"
 #include "pixel.h"
 #include "points.h"
 #include "polygon.h"
 #include "texstate.h"
 #include "mtypes.h"
 #include "varray.h"
+#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
+#include "nvprogram.h"
+#include "program.h"
+#endif
 
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
 
-#endif
-
-
-
-/*
-Functions which aren't compiled but executed immediately:
-       glIsList
-       glGenLists
-       glDeleteLists
-       glEndList  --- BUT:  call ctx->Driver.EndList at end of list execution?
-       glFeedbackBuffer
-       glSelectBuffer
-       glRenderMode
-       glReadPixels
-       glPixelStore
-       glFlush
-       glFinish
-       glIsEnabled
-       glGet*
-
-Functions which cause errors if called while compiling a display list:
-       glNewList
-*/
-
 
-
-/*
- * Display list instructions are stored as sequences of "nodes".  Nodes
- * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
- * are linked together with a pointer.
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ *
+ * Checks if dd_function_table::SaveNeedFlush is marked to flush
+ * stored (save) vertices, and calls
+ * dd_function_table::SaveFlushVertices if so.
  */
-
-
-/* How many nodes to allocate at a time:
- * - reduced now that we hold vertices etc. elsewhere.
+#define SAVE_FLUSH_VERTICES(ctx)               \
+do {                                           \
+   if (ctx->Driver.SaveNeedFlush)              \
+      ctx->Driver.SaveFlushVertices(ctx);      \
+} while (0)
+
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair, with return value.
+ * 
+ * \param ctx GL context.
+ * \param retval value to return value in case the assertion fails.
  */
-#define BLOCK_SIZE 256
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)         \
+do {                                                                   \
+   if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON ||               \
+       ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
+      _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" );   \
+      return retval;                                                   \
+   }                                                                   \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair.
+ * 
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)                             \
+do {                                                                   \
+   if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON ||               \
+       ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
+      _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" );   \
+      return;                                                          \
+   }                                                                   \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair and flush the vertices.
+ * 
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)                   \
+do {                                                                   \
+   ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);                                 \
+   SAVE_FLUSH_VERTICES(ctx);                                           \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair and flush the vertices, with return value.
+ * 
+ * \param ctx GL context.
+ * \param retval value to return value in case the assertion fails.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
+do {                                                                   \
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);             \
+   SAVE_FLUSH_VERTICES(ctx);                                           \
+} while (0)
 
 
-/*
+
+/**
  * Display list opcodes.
  *
  * The fact that these identifiers are assigned consecutive
  * integer values starting at 0 is very important, see InstSize array usage)
- *
  */
 typedef enum {
        OPCODE_ACCUM,
@@ -122,7 +170,6 @@ typedef enum {
        OPCODE_BITMAP,
        OPCODE_BLEND_COLOR,
        OPCODE_BLEND_EQUATION,
-       OPCODE_BLEND_FUNC,
        OPCODE_BLEND_FUNC_SEPARATE,
         OPCODE_CALL_LIST,
         OPCODE_CALL_LIST_OFFSET,
@@ -242,6 +289,46 @@ typedef enum {
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
         /* GL_ARB_multisample */
         OPCODE_SAMPLE_COVERAGE,
+        /* GL_ARB_window_pos */
+       OPCODE_WINDOW_POS_ARB,
+        /* GL_NV_vertex_program */
+        OPCODE_BIND_PROGRAM_NV,
+        OPCODE_EXECUTE_PROGRAM_NV,
+        OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
+        OPCODE_LOAD_PROGRAM_NV,
+        OPCODE_PROGRAM_PARAMETER4F_NV,
+        OPCODE_TRACK_MATRIX_NV,
+        /* GL_NV_fragment_program */
+        OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
+        OPCODE_PROGRAM_NAMED_PARAMETER_NV,
+        /* GL_EXT_stencil_two_side */
+        OPCODE_ACTIVE_STENCIL_FACE_EXT,
+        /* GL_EXT_depth_bounds_test */
+        OPCODE_DEPTH_BOUNDS_EXT,
+        /* GL_ARB_vertex/fragment_program */
+        OPCODE_PROGRAM_STRING_ARB,
+        OPCODE_PROGRAM_ENV_PARAMETER_ARB,
+
+
+       /* Vertex attributes -- fallback for when optimized display
+        * list build isn't active.
+        */
+       OPCODE_ATTR_1F,
+       OPCODE_ATTR_2F,
+       OPCODE_ATTR_3F,
+       OPCODE_ATTR_4F,
+       OPCODE_MATERIAL,
+       OPCODE_INDEX,
+       OPCODE_EDGEFLAG,
+       OPCODE_BEGIN,
+       OPCODE_END,
+       OPCODE_RECTF,
+       OPCODE_EVAL_C1,
+       OPCODE_EVAL_C2,
+       OPCODE_EVAL_P1,
+       OPCODE_EVAL_P2,
+
+
        /* The following three are meta instructions */
        OPCODE_ERROR,           /* raise compiled-in error */
        OPCODE_CONTINUE,
@@ -250,10 +337,17 @@ typedef enum {
 } OpCode;
 
 
-/*
+
+/**
+ * Display list node.
+ *
+ * Display list instructions are stored as sequences of "nodes".  Nodes
+ * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
+ * are linked together with a pointer.
+ *
  * Each instruction in the display list is stored as a sequence of
  * contiguous nodes in memory.
- * Each node is the union of a variety of datatypes.
+ * Each node is the union of a variety of data types.
  */
 union node {
        OpCode          opcode;
@@ -271,9 +365,18 @@ union node {
 };
 
 
+/**
+ * How many nodes to allocate at a time.
+ *
+ * \note Reduced now that we hold vertices etc. elsewhere.
+ */
+#define BLOCK_SIZE 256
+
+
 
-/* Number of nodes of storage needed for each instruction.  Sizes for
- * dynamically allocated opcodes are stored in the context struct.
+/**
+ * Number of nodes of storage needed for each instruction.
+ * Sizes for dynamically allocated opcodes are stored in the context struct.
  */
 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
 
@@ -284,10 +387,6 @@ void mesa_print_display_list( GLuint list );
 /*****                           Private                          *****/
 /**********************************************************************/
 
-
-
-
-
 /*
  * Make an empty display list.  This is used by glGenLists() to
  * reserver display list IDs.
@@ -303,7 +402,7 @@ static Node *make_empty_list( void )
 
 /*
  * Destroy all nodes in a display list.
- * Input:  list - display list number
+ * \param list - display list number
  */
 void _mesa_destroy_list( GLcontext *ctx, GLuint list )
 {
@@ -328,6 +427,7 @@ void _mesa_destroy_list( GLcontext *ctx, GLuint list )
       }
       else {
         switch (n[0].opcode) {
+         /* for some commands, we need to free malloc'd memory */
         case OPCODE_MAP1:
             FREE(n[6].data);
            n += InstSize[n[0].opcode];
@@ -412,6 +512,28 @@ void _mesa_destroy_list( GLcontext *ctx, GLuint list )
             FREE(n[11].data);
             n += InstSize[n[0].opcode];
             break;
+#if FEATURE_NV_vertex_program
+         case OPCODE_LOAD_PROGRAM_NV:
+            FREE(n[4].data);  /* program string */
+            n += InstSize[n[0].opcode];
+            break;
+         case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
+            FREE(n[2].data);  /* array of program ids */
+            n += InstSize[n[0].opcode];
+            break;
+#endif
+#if FEATURE_NV_fragment_program
+         case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
+            FREE(n[3].data);  /* parameter name */
+            n += InstSize[n[0].opcode];
+            break;
+#endif
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+         case OPCODE_PROGRAM_STRING_ARB:
+            FREE(n[4].data);  /* program string */
+            n += InstSize[n[0].opcode];
+            break;
+#endif
         case OPCODE_CONTINUE:
            n = (Node *) n[1].next;
            FREE( block );
@@ -506,10 +628,9 @@ void _mesa_init_lists( void )
       InstSize[OPCODE_BITMAP] = 8;
       InstSize[OPCODE_BLEND_COLOR] = 5;
       InstSize[OPCODE_BLEND_EQUATION] = 2;
-      InstSize[OPCODE_BLEND_FUNC] = 3;
       InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
       InstSize[OPCODE_CALL_LIST] = 2;
-      InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
+      InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
       InstSize[OPCODE_CLEAR] = 2;
       InstSize[OPCODE_CLEAR_ACCUM] = 5;
       InstSize[OPCODE_CLEAR_COLOR] = 5;
@@ -627,6 +748,40 @@ void _mesa_init_lists( void )
       InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
       /* GL_ARB_multitexture */
       InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
+      /* GL_ARB_window_pos */
+      InstSize[OPCODE_WINDOW_POS_ARB] = 4;
+      /* GL_NV_vertex_program */
+      InstSize[OPCODE_BIND_PROGRAM_NV] = 3;
+      InstSize[OPCODE_EXECUTE_PROGRAM_NV] = 7;
+      InstSize[OPCODE_REQUEST_RESIDENT_PROGRAMS_NV] = 2;
+      InstSize[OPCODE_LOAD_PROGRAM_NV] = 5;
+      InstSize[OPCODE_PROGRAM_PARAMETER4F_NV] = 7;
+      InstSize[OPCODE_TRACK_MATRIX_NV] = 5;
+      /* GL_NV_fragment_program */
+      InstSize[OPCODE_PROGRAM_LOCAL_PARAMETER_ARB] = 7;
+      InstSize[OPCODE_PROGRAM_NAMED_PARAMETER_NV] = 8;
+      /* GL_EXT_stencil_two_side */
+      InstSize[OPCODE_ACTIVE_STENCIL_FACE_EXT] = 2;
+      /* GL_EXT_depth_bounds_test */
+      InstSize[OPCODE_DEPTH_BOUNDS_EXT] = 3;
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+      InstSize[OPCODE_PROGRAM_STRING_ARB] = 5;
+      InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7;
+#endif
+      InstSize[OPCODE_ATTR_1F] = 3;
+      InstSize[OPCODE_ATTR_2F] = 4;
+      InstSize[OPCODE_ATTR_3F] = 5;
+      InstSize[OPCODE_ATTR_4F] = 6;
+      InstSize[OPCODE_MATERIAL] = 7;
+      InstSize[OPCODE_INDEX] = 2;
+      InstSize[OPCODE_EDGEFLAG] = 2;
+      InstSize[OPCODE_BEGIN] = 2;
+      InstSize[OPCODE_END] = 1;
+      InstSize[OPCODE_RECTF] = 5;
+      InstSize[OPCODE_EVAL_C1] = 2;
+      InstSize[OPCODE_EVAL_C2] = 3;
+      InstSize[OPCODE_EVAL_P1] = 2;
+      InstSize[OPCODE_EVAL_P2] = 3;
    }
    init_flag = 1;
 }
@@ -634,9 +789,9 @@ void _mesa_init_lists( void )
 
 /*
  * Allocate space for a display list instruction.
- * Input:  opcode - type of instruction
+ * \param opcode - type of instruction
  *         argcount - size in bytes of data required.
- * Return: pointer to the usable data area (not including the internal
+ * \return pointer to the usable data area (not including the internal
  *         opcode).
  */
 void *
@@ -651,9 +806,9 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
    }
 #endif
 
-   if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
+   if (ctx->ListState.CurrentPos + count + 2 > BLOCK_SIZE) {
       /* This block is full.  Allocate a new block and chain to it */
-      n = ctx->CurrentBlock + ctx->CurrentPos;
+      n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
       n[0].opcode = OPCODE_CONTINUE;
       newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
       if (!newblock) {
@@ -661,12 +816,12 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
          return NULL;
       }
       n[1].next = (Node *) newblock;
-      ctx->CurrentBlock = newblock;
-      ctx->CurrentPos = 0;
+      ctx->ListState.CurrentBlock = newblock;
+      ctx->ListState.CurrentPos = 0;
    }
 
-   n = ctx->CurrentBlock + ctx->CurrentPos;
-   ctx->CurrentPos += count;
+   n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
+   ctx->ListState.CurrentPos += count;
 
    n[0].opcode = (OpCode) opcode;
 
@@ -709,7 +864,7 @@ _mesa_alloc_opcode( GLcontext *ctx,
 /*
  * Display List compilation functions
  */
-static void save_Accum( GLenum op, GLfloat value )
+static void GLAPIENTRY save_Accum( GLenum op, GLfloat value )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -725,7 +880,7 @@ static void save_Accum( GLenum op, GLfloat value )
 }
 
 
-static void save_AlphaFunc( GLenum func, GLclampf ref )
+static void GLAPIENTRY save_AlphaFunc( GLenum func, GLclampf ref )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -741,7 +896,7 @@ static void save_AlphaFunc( GLenum func, GLclampf ref )
 }
 
 
-static void save_BindTexture( GLenum target, GLuint texture )
+static void GLAPIENTRY save_BindTexture( GLenum target, GLuint texture )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -757,7 +912,7 @@ static void save_BindTexture( GLenum target, GLuint texture )
 }
 
 
-static void save_Bitmap( GLsizei width, GLsizei height,
+static void GLAPIENTRY save_Bitmap( GLsizei width, GLsizei height,
                          GLfloat xorig, GLfloat yorig,
                          GLfloat xmove, GLfloat ymove,
                          const GLubyte *pixels )
@@ -786,7 +941,7 @@ static void save_Bitmap( GLsizei width, GLsizei height,
 }
 
 
-static void save_BlendEquation( GLenum mode )
+static void GLAPIENTRY save_BlendEquation( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -801,23 +956,7 @@ static void save_BlendEquation( GLenum mode )
 }
 
 
-static void save_BlendFunc( GLenum sfactor, GLenum dfactor )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   Node *n;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC, 2 );
-   if (n) {
-      n[1].e = sfactor;
-      n[2].e = dfactor;
-   }
-   if (ctx->ExecuteFlag) {
-      (*ctx->Exec->BlendFunc)( sfactor, dfactor );
-   }
-}
-
-
-static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
+static void GLAPIENTRY save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
                                       GLenum sfactorA, GLenum dfactorA)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -837,7 +976,7 @@ static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
 }
 
 
-static void save_BlendColor( GLfloat red, GLfloat green,
+static void GLAPIENTRY save_BlendColor( GLfloat red, GLfloat green,
                              GLfloat blue, GLfloat alpha )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -856,44 +995,72 @@ static void save_BlendColor( GLfloat red, GLfloat green,
 }
 
 
-void _mesa_save_CallList( GLuint list )
+void GLAPIENTRY _mesa_save_CallList( GLuint list )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
+   SAVE_FLUSH_VERTICES(ctx);
 
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
    if (n) {
       n[1].ui = list;
    }
+   
+   /* After this, we don't know what begin/end state we're in:
+    */
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->CallList)( list );
    }
 }
 
 
-void _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
+void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
 {
    GET_CURRENT_CONTEXT(ctx);
    GLint i;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
+   GLboolean typeErrorFlag;
+
+   SAVE_FLUSH_VERTICES(ctx);
+
+   switch (type) {
+      case GL_BYTE:
+      case GL_UNSIGNED_BYTE:
+      case GL_SHORT:
+      case GL_UNSIGNED_SHORT:
+      case GL_INT:
+      case GL_UNSIGNED_INT:
+      case GL_FLOAT:
+      case GL_2_BYTES:
+      case GL_3_BYTES:
+      case GL_4_BYTES:
+         typeErrorFlag = GL_FALSE;
+         break;
+      default:
+         typeErrorFlag = GL_TRUE;
+   }
 
    for (i=0;i<n;i++) {
       GLuint list = translate_id( i, type, lists );
-      Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
+      Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
       if (n) {
          n[1].ui = list;
+         n[2].b = typeErrorFlag;
       }
    }
+
+   /* After this, we don't know what begin/end state we're in:
+    */
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->CallLists)( n, type, lists );
    }
 }
 
 
-static void save_Clear( GLbitfield mask )
+static void GLAPIENTRY save_Clear( GLbitfield mask )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -908,7 +1075,7 @@ static void save_Clear( GLbitfield mask )
 }
 
 
-static void save_ClearAccum( GLfloat red, GLfloat green,
+static void GLAPIENTRY save_ClearAccum( GLfloat red, GLfloat green,
                              GLfloat blue, GLfloat alpha )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -927,7 +1094,7 @@ static void save_ClearAccum( GLfloat red, GLfloat green,
 }
 
 
-static void save_ClearColor( GLclampf red, GLclampf green,
+static void GLAPIENTRY save_ClearColor( GLclampf red, GLclampf green,
                              GLclampf blue, GLclampf alpha )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -946,7 +1113,7 @@ static void save_ClearColor( GLclampf red, GLclampf green,
 }
 
 
-static void save_ClearDepth( GLclampd depth )
+static void GLAPIENTRY save_ClearDepth( GLclampd depth )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -961,7 +1128,7 @@ static void save_ClearDepth( GLclampd depth )
 }
 
 
-static void save_ClearIndex( GLfloat c )
+static void GLAPIENTRY save_ClearIndex( GLfloat c )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -976,7 +1143,7 @@ static void save_ClearIndex( GLfloat c )
 }
 
 
-static void save_ClearStencil( GLint s )
+static void GLAPIENTRY save_ClearStencil( GLint s )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -991,7 +1158,7 @@ static void save_ClearStencil( GLint s )
 }
 
 
-static void save_ClipPlane( GLenum plane, const GLdouble *equ )
+static void GLAPIENTRY save_ClipPlane( GLenum plane, const GLdouble *equ )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1011,7 +1178,7 @@ static void save_ClipPlane( GLenum plane, const GLdouble *equ )
 
 
 
-static void save_ColorMask( GLboolean red, GLboolean green,
+static void GLAPIENTRY save_ColorMask( GLboolean red, GLboolean green,
                             GLboolean blue, GLboolean alpha )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1030,12 +1197,11 @@ static void save_ColorMask( GLboolean red, GLboolean green,
 }
 
 
-static void save_ColorMaterial( GLenum face, GLenum mode )
+static void GLAPIENTRY save_ColorMaterial( GLenum face, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
 
    n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
    if (n) {
@@ -1048,7 +1214,7 @@ static void save_ColorMaterial( GLenum face, GLenum mode )
 }
 
 
-static void save_ColorTable( GLenum target, GLenum internalFormat,
+static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
                              GLsizei width, GLenum format, GLenum type,
                              const GLvoid *table )
 {
@@ -1087,7 +1253,7 @@ static void save_ColorTable( GLenum target, GLenum internalFormat,
 
 
 
-static void
+static void GLAPIENTRY
 save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1102,7 +1268,8 @@ save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
       n[3].f = params[0];
       if (pname == GL_COLOR_TABLE_SGI ||
           pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
-          pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
+          pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
+          pname == GL_TEXTURE_COLOR_TABLE_SGI) {
          n[4].f = params[1];
          n[5].f = params[2];
          n[6].f = params[3];
@@ -1115,7 +1282,7 @@ save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 }
 
 
-static void
+static void GLAPIENTRY
 save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1130,7 +1297,8 @@ save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
       n[3].i = params[0];
       if (pname == GL_COLOR_TABLE_SGI ||
           pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
-          pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) {
+          pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
+          pname == GL_TEXTURE_COLOR_TABLE_SGI) {
          n[4].i = params[1];
          n[5].i = params[2];
          n[6].i = params[3];
@@ -1144,7 +1312,7 @@ save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 
 
 
-static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
+static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
                                 GLenum format, GLenum type,
                                 const GLvoid *table)
 {
@@ -1171,7 +1339,7 @@ static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CopyColorSubTable(GLenum target, GLsizei start,
                        GLint x, GLint y, GLsizei width)
 {
@@ -1193,7 +1361,7 @@ save_CopyColorSubTable(GLenum target, GLsizei start,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CopyColorTable(GLenum target, GLenum internalformat,
                     GLint x, GLint y, GLsizei width)
 {
@@ -1215,7 +1383,7 @@ save_CopyColorTable(GLenum target, GLenum internalformat,
 }
 
 
-static void
+static void GLAPIENTRY
 save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
                          GLenum format, GLenum type, const GLvoid *filter)
 {
@@ -1243,7 +1411,7 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
 }
 
 
-static void
+static void GLAPIENTRY
 save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
                          GLsizei width, GLsizei height, GLenum format,
                          GLenum type, const GLvoid *filter)
@@ -1273,7 +1441,7 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
 }
 
 
-static void
+static void GLAPIENTRY
 save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1291,7 +1459,7 @@ save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
 }
 
 
-static void
+static void GLAPIENTRY
 save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1319,7 +1487,7 @@ save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
 }
 
 
-static void
+static void GLAPIENTRY
 save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1337,7 +1505,7 @@ save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
 }
 
 
-static void
+static void GLAPIENTRY
 save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1365,7 +1533,7 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 }
 
 
-static void 
+static void GLAPIENTRY
 save_CopyPixels( GLint x, GLint y,
                 GLsizei width, GLsizei height, GLenum type )
 {
@@ -1387,7 +1555,7 @@ save_CopyPixels( GLint x, GLint y,
 
 
 
-static void
+static void GLAPIENTRY
 save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
                      GLint x, GLint y, GLsizei width, GLint border )
 {
@@ -1411,7 +1579,7 @@ save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CopyTexImage2D( GLenum target, GLint level,
                      GLenum internalformat,
                      GLint x, GLint y, GLsizei width,
@@ -1439,7 +1607,7 @@ save_CopyTexImage2D( GLenum target, GLint level,
 
 
 
-static void
+static void GLAPIENTRY
 save_CopyTexSubImage1D( GLenum target, GLint level,
                         GLint xoffset, GLint x, GLint y,
                         GLsizei width )
@@ -1462,7 +1630,7 @@ save_CopyTexSubImage1D( GLenum target, GLint level,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CopyTexSubImage2D( GLenum target, GLint level,
                         GLint xoffset, GLint yoffset,
                         GLint x, GLint y,
@@ -1489,7 +1657,7 @@ save_CopyTexSubImage2D( GLenum target, GLint level,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CopyTexSubImage3D( GLenum target, GLint level,
                         GLint xoffset, GLint yoffset, GLint zoffset,
                         GLint x, GLint y,
@@ -1518,7 +1686,7 @@ save_CopyTexSubImage3D( GLenum target, GLint level,
 }
 
 
-static void save_CullFace( GLenum mode )
+static void GLAPIENTRY save_CullFace( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1533,7 +1701,7 @@ static void save_CullFace( GLenum mode )
 }
 
 
-static void save_DepthFunc( GLenum func )
+static void GLAPIENTRY save_DepthFunc( GLenum func )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1548,7 +1716,7 @@ static void save_DepthFunc( GLenum func )
 }
 
 
-static void save_DepthMask( GLboolean mask )
+static void GLAPIENTRY save_DepthMask( GLboolean mask )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1563,7 +1731,7 @@ static void save_DepthMask( GLboolean mask )
 }
 
 
-static void save_DepthRange( GLclampd nearval, GLclampd farval )
+static void GLAPIENTRY save_DepthRange( GLclampd nearval, GLclampd farval )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1579,7 +1747,7 @@ static void save_DepthRange( GLclampd nearval, GLclampd farval )
 }
 
 
-static void save_Disable( GLenum cap )
+static void GLAPIENTRY save_Disable( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1594,7 +1762,7 @@ static void save_Disable( GLenum cap )
 }
 
 
-static void save_DrawBuffer( GLenum mode )
+static void GLAPIENTRY save_DrawBuffer( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1609,7 +1777,7 @@ static void save_DrawBuffer( GLenum mode )
 }
 
 
-static void save_DrawPixels( GLsizei width, GLsizei height,
+static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
                              GLenum format, GLenum type,
                              const GLvoid *pixels )
 {
@@ -1636,7 +1804,7 @@ static void save_DrawPixels( GLsizei width, GLsizei height,
 
 
 
-static void save_Enable( GLenum cap )
+static void GLAPIENTRY save_Enable( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1652,7 +1820,7 @@ static void save_Enable( GLenum cap )
 
 
 
-void _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
+void GLAPIENTRY _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1669,7 +1837,7 @@ void _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
 }
 
 
-void _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
+void GLAPIENTRY _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1690,7 +1858,7 @@ void _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
 
 
 
-static void save_Fogfv( GLenum pname, const GLfloat *params )
+static void GLAPIENTRY save_Fogfv( GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1709,13 +1877,13 @@ static void save_Fogfv( GLenum pname, const GLfloat *params )
 }
 
 
-static void save_Fogf( GLenum pname, GLfloat param )
+static void GLAPIENTRY save_Fogf( GLenum pname, GLfloat param )
 {
    save_Fogfv(pname, &param);
 }
 
 
-static void save_Fogiv(GLenum pname, const GLint *params )
+static void GLAPIENTRY save_Fogiv(GLenum pname, const GLint *params )
 {
    GLfloat p[4];
    switch (pname) {
@@ -1740,13 +1908,13 @@ static void save_Fogiv(GLenum pname, const GLint *params )
 }
 
 
-static void save_Fogi(GLenum pname, GLint param )
+static void GLAPIENTRY save_Fogi(GLenum pname, GLint param )
 {
    save_Fogiv(pname, &param);
 }
 
 
-static void save_FrontFace( GLenum mode )
+static void GLAPIENTRY save_FrontFace( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1761,7 +1929,7 @@ static void save_FrontFace( GLenum mode )
 }
 
 
-static void save_Frustum( GLdouble left, GLdouble right,
+static void GLAPIENTRY save_Frustum( GLdouble left, GLdouble right,
                       GLdouble bottom, GLdouble top,
                       GLdouble nearval, GLdouble farval )
 {
@@ -1783,7 +1951,7 @@ static void save_Frustum( GLdouble left, GLdouble right,
 }
 
 
-static void save_Hint( GLenum target, GLenum mode )
+static void GLAPIENTRY save_Hint( GLenum target, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1799,7 +1967,7 @@ static void save_Hint( GLenum target, GLenum mode )
 }
 
 
-static void
+static void GLAPIENTRY
 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1819,7 +1987,7 @@ save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean si
 }
 
 
-static void save_IndexMask( GLuint mask )
+static void GLAPIENTRY save_IndexMask( GLuint mask )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1834,7 +2002,7 @@ static void save_IndexMask( GLuint mask )
 }
 
 
-static void save_InitNames( void )
+static void GLAPIENTRY save_InitNames( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -1845,7 +2013,7 @@ static void save_InitNames( void )
 }
 
 
-static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
+static void GLAPIENTRY save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1899,13 +2067,13 @@ static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
 }
 
 
-static void save_Lightf( GLenum light, GLenum pname, GLfloat params )
+static void GLAPIENTRY save_Lightf( GLenum light, GLenum pname, GLfloat params )
 {
    save_Lightfv(light, pname, &params);
 }
 
 
-static void save_Lightiv( GLenum light, GLenum pname, const GLint *params )
+static void GLAPIENTRY save_Lightiv( GLenum light, GLenum pname, const GLint *params )
 {
    GLfloat fparam[4];
    switch (pname) {
@@ -1943,13 +2111,13 @@ static void save_Lightiv( GLenum light, GLenum pname, const GLint *params )
 }
 
 
-static void save_Lighti( GLenum light, GLenum pname, GLint param )
+static void GLAPIENTRY save_Lighti( GLenum light, GLenum pname, GLint param )
 {
    save_Lightiv( light, pname, &param );
 }
 
 
-static void save_LightModelfv( GLenum pname, const GLfloat *params )
+static void GLAPIENTRY save_LightModelfv( GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1968,13 +2136,13 @@ static void save_LightModelfv( GLenum pname, const GLfloat *params )
 }
 
 
-static void save_LightModelf( GLenum pname, GLfloat param )
+static void GLAPIENTRY save_LightModelf( GLenum pname, GLfloat param )
 {
    save_LightModelfv(pname, &param);
 }
 
 
-static void save_LightModeliv( GLenum pname, const GLint *params )
+static void GLAPIENTRY save_LightModeliv( GLenum pname, const GLint *params )
 {
    GLfloat fparam[4];
    switch (pname) {
@@ -1997,13 +2165,13 @@ static void save_LightModeliv( GLenum pname, const GLint *params )
 }
 
 
-static void save_LightModeli( GLenum pname, GLint param )
+static void GLAPIENTRY save_LightModeli( GLenum pname, GLint param )
 {
    save_LightModeliv(pname, &param);
 }
 
 
-static void save_LineStipple( GLint factor, GLushort pattern )
+static void GLAPIENTRY save_LineStipple( GLint factor, GLushort pattern )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2019,7 +2187,7 @@ static void save_LineStipple( GLint factor, GLushort pattern )
 }
 
 
-static void save_LineWidth( GLfloat width )
+static void GLAPIENTRY save_LineWidth( GLfloat width )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2034,7 +2202,7 @@ static void save_LineWidth( GLfloat width )
 }
 
 
-static void save_ListBase( GLuint base )
+static void GLAPIENTRY save_ListBase( GLuint base )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2049,7 +2217,7 @@ static void save_ListBase( GLuint base )
 }
 
 
-static void save_LoadIdentity( void )
+static void GLAPIENTRY save_LoadIdentity( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -2060,7 +2228,7 @@ static void save_LoadIdentity( void )
 }
 
 
-static void save_LoadMatrixf( const GLfloat *m )
+static void GLAPIENTRY save_LoadMatrixf( const GLfloat *m )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2078,7 +2246,7 @@ static void save_LoadMatrixf( const GLfloat *m )
 }
 
 
-static void save_LoadMatrixd( const GLdouble *m )
+static void GLAPIENTRY save_LoadMatrixd( const GLdouble *m )
 {
    GLfloat f[16];
    GLint i;
@@ -2089,7 +2257,7 @@ static void save_LoadMatrixd( const GLdouble *m )
 }
 
 
-static void save_LoadName( GLuint name )
+static void GLAPIENTRY save_LoadName( GLuint name )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2104,7 +2272,7 @@ static void save_LoadName( GLuint name )
 }
 
 
-static void save_LogicOp( GLenum opcode )
+static void GLAPIENTRY save_LogicOp( GLenum opcode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2119,7 +2287,7 @@ static void save_LogicOp( GLenum opcode )
 }
 
 
-static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+static void GLAPIENTRY save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
                         GLint order, const GLdouble *points)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2140,7 +2308,7 @@ static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
    }
 }
 
-static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+static void GLAPIENTRY save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
                         GLint order, const GLfloat *points)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2162,7 +2330,7 @@ static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
 }
 
 
-static void save_Map2d( GLenum target,
+static void GLAPIENTRY save_Map2d( GLenum target,
                         GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
                         GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
                         const GLdouble *points )
@@ -2194,7 +2362,7 @@ static void save_Map2d( GLenum target,
 }
 
 
-static void save_Map2f( GLenum target,
+static void GLAPIENTRY save_Map2f( GLenum target,
                         GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
                         GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
                         const GLfloat *points )
@@ -2225,7 +2393,7 @@ static void save_Map2f( GLenum target,
 }
 
 
-static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
+static void GLAPIENTRY save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2242,13 +2410,13 @@ static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
 }
 
 
-static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
+static void GLAPIENTRY save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
 {
    save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
 }
 
 
-static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+static void GLAPIENTRY save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
                             GLint vn, GLfloat v1, GLfloat v2 )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2270,15 +2438,15 @@ static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
 
 
 
-static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+static void GLAPIENTRY save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
                             GLint vn, GLdouble v1, GLdouble v2 )
 {
-   save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, 
+   save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
                  vn, (GLfloat) v1, (GLfloat) v2);
 }
 
 
-static void save_MatrixMode( GLenum mode )
+static void GLAPIENTRY save_MatrixMode( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2293,7 +2461,7 @@ static void save_MatrixMode( GLenum mode )
 }
 
 
-static void
+static void GLAPIENTRY
 save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2312,7 +2480,7 @@ save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
 }
 
 
-static void save_MultMatrixf( const GLfloat *m )
+static void GLAPIENTRY save_MultMatrixf( const GLfloat *m )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2330,7 +2498,7 @@ static void save_MultMatrixf( const GLfloat *m )
 }
 
 
-static void save_MultMatrixd( const GLdouble *m )
+static void GLAPIENTRY save_MultMatrixd( const GLdouble *m )
 {
    GLfloat f[16];
    GLint i;
@@ -2341,7 +2509,7 @@ static void save_MultMatrixd( const GLdouble *m )
 }
 
 
-static void save_NewList( GLuint list, GLenum mode )
+static void GLAPIENTRY save_NewList( GLuint list, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    /* It's an error to call this function while building a display list */
@@ -2352,7 +2520,7 @@ static void save_NewList( GLuint list, GLenum mode )
 
 
 
-static void save_Ortho( GLdouble left, GLdouble right,
+static void GLAPIENTRY save_Ortho( GLdouble left, GLdouble right,
                     GLdouble bottom, GLdouble top,
                     GLdouble nearval, GLdouble farval )
 {
@@ -2374,7 +2542,7 @@ static void save_Ortho( GLdouble left, GLdouble right,
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2393,7 +2561,7 @@ save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
 {
    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
@@ -2412,7 +2580,7 @@ save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
 {
    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
@@ -2431,7 +2599,7 @@ save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelTransferf( GLenum pname, GLfloat param )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2448,14 +2616,14 @@ save_PixelTransferf( GLenum pname, GLfloat param )
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelTransferi( GLenum pname, GLint param )
 {
    save_PixelTransferf( pname, (GLfloat) param );
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2472,7 +2640,7 @@ save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
 }
 
 
-static void
+static void GLAPIENTRY
 save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2491,13 +2659,25 @@ save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
 }
 
 
-static void save_PointParameterfEXT( GLenum pname, GLfloat param )
+static void GLAPIENTRY save_PointParameterfEXT( GLenum pname, GLfloat param )
 {
    save_PointParameterfvEXT(pname, &param);
 }
 
+static void GLAPIENTRY save_PointParameteriNV( GLenum pname, GLint param )
+{
+   GLfloat p = (GLfloat) param;
+   save_PointParameterfvEXT(pname, &p);
+}
+
+static void GLAPIENTRY save_PointParameterivNV( GLenum pname, const GLint *param )
+{
+   GLfloat p = (GLfloat) param[0];
+   save_PointParameterfvEXT(pname, &p);
+}
+
 
-static void save_PointSize( GLfloat size )
+static void GLAPIENTRY save_PointSize( GLfloat size )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2512,7 +2692,7 @@ static void save_PointSize( GLfloat size )
 }
 
 
-static void save_PolygonMode( GLenum face, GLenum mode )
+static void GLAPIENTRY save_PolygonMode( GLenum face, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2531,7 +2711,7 @@ static void save_PolygonMode( GLenum face, GLenum mode )
 /*
  * Polygon stipple must have been upacked already!
  */
-static void save_PolygonStipple( const GLubyte *pattern )
+static void GLAPIENTRY save_PolygonStipple( const GLubyte *pattern )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2549,7 +2729,7 @@ static void save_PolygonStipple( const GLubyte *pattern )
 }
 
 
-static void save_PolygonOffset( GLfloat factor, GLfloat units )
+static void GLAPIENTRY save_PolygonOffset( GLfloat factor, GLfloat units )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2565,14 +2745,14 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units )
 }
 
 
-static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
+static void GLAPIENTRY save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
 {
    GET_CURRENT_CONTEXT(ctx);
    save_PolygonOffset(factor, ctx->DepthMaxF * bias);
 }
 
 
-static void save_PopAttrib( void )
+static void GLAPIENTRY save_PopAttrib( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -2583,11 +2763,10 @@ static void save_PopAttrib( void )
 }
 
 
-static void save_PopMatrix( void )
+static void GLAPIENTRY save_PopMatrix( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
    (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->PopMatrix)();
@@ -2595,7 +2774,7 @@ static void save_PopMatrix( void )
 }
 
 
-static void save_PopName( void )
+static void GLAPIENTRY save_PopName( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -2606,7 +2785,7 @@ static void save_PopName( void )
 }
 
 
-static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
+static void GLAPIENTRY save_PrioritizeTextures( GLsizei num, const GLuint *textures,
                                      const GLclampf *priorities )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2627,12 +2806,11 @@ static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
 }
 
 
-static void save_PushAttrib( GLbitfield mask )
+static void GLAPIENTRY save_PushAttrib( GLbitfield mask )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
    if (n) {
       n[1].bf = mask;
@@ -2643,7 +2821,7 @@ static void save_PushAttrib( GLbitfield mask )
 }
 
 
-static void save_PushMatrix( void )
+static void GLAPIENTRY save_PushMatrix( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
@@ -2654,7 +2832,7 @@ static void save_PushMatrix( void )
 }
 
 
-static void save_PushName( GLuint name )
+static void GLAPIENTRY save_PushName( GLuint name )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2669,12 +2847,11 @@ static void save_PushName( GLuint name )
 }
 
 
-static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+static void GLAPIENTRY save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
    if (n) {
       n[1].f = x;
@@ -2687,125 +2864,125 @@ static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
    }
 }
 
-static void save_RasterPos2d(GLdouble x, GLdouble y)
+static void GLAPIENTRY save_RasterPos2d(GLdouble x, GLdouble y)
 {
    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
-static void save_RasterPos2f(GLfloat x, GLfloat y)
+static void GLAPIENTRY save_RasterPos2f(GLfloat x, GLfloat y)
 {
    save_RasterPos4f(x, y, 0.0F, 1.0F);
 }
 
-static void save_RasterPos2i(GLint x, GLint y)
+static void GLAPIENTRY save_RasterPos2i(GLint x, GLint y)
 {
    save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
-static void save_RasterPos2s(GLshort x, GLshort y)
+static void GLAPIENTRY save_RasterPos2s(GLshort x, GLshort y)
 {
    save_RasterPos4f(x, y, 0.0F, 1.0F);
 }
 
-static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
+static void GLAPIENTRY save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
 {
    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
-static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
+static void GLAPIENTRY save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
 {
    save_RasterPos4f(x, y, z, 1.0F);
 }
 
-static void save_RasterPos3i(GLint x, GLint y, GLint z)
+static void GLAPIENTRY save_RasterPos3i(GLint x, GLint y, GLint z)
 {
    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
-static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
+static void GLAPIENTRY save_RasterPos3s(GLshort x, GLshort y, GLshort z)
 {
    save_RasterPos4f(x, y, z, 1.0F);
 }
 
-static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+static void GLAPIENTRY save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
-static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
+static void GLAPIENTRY save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
 {
    save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
-static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
+static void GLAPIENTRY save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
 {
    save_RasterPos4f(x, y, z, w);
 }
 
-static void save_RasterPos2dv(const GLdouble *v)
+static void GLAPIENTRY save_RasterPos2dv(const GLdouble *v)
 {
    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
-static void save_RasterPos2fv(const GLfloat *v)
+static void GLAPIENTRY save_RasterPos2fv(const GLfloat *v)
 {
    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
 }
 
-static void save_RasterPos2iv(const GLint *v)
+static void GLAPIENTRY save_RasterPos2iv(const GLint *v)
 {
    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
-static void save_RasterPos2sv(const GLshort *v)
+static void GLAPIENTRY save_RasterPos2sv(const GLshort *v)
 {
    save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
 }
 
-static void save_RasterPos3dv(const GLdouble *v)
+static void GLAPIENTRY save_RasterPos3dv(const GLdouble *v)
 {
    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
-static void save_RasterPos3fv(const GLfloat *v)
+static void GLAPIENTRY save_RasterPos3fv(const GLfloat *v)
 {
    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
 }
 
-static void save_RasterPos3iv(const GLint *v)
+static void GLAPIENTRY save_RasterPos3iv(const GLint *v)
 {
    save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
-static void save_RasterPos3sv(const GLshort *v)
+static void GLAPIENTRY save_RasterPos3sv(const GLshort *v)
 {
    save_RasterPos4f(v[0], v[1], v[2], 1.0F);
 }
 
-static void save_RasterPos4dv(const GLdouble *v)
+static void GLAPIENTRY save_RasterPos4dv(const GLdouble *v)
 {
-   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
                    (GLfloat) v[2], (GLfloat) v[3]);
 }
 
-static void save_RasterPos4fv(const GLfloat *v)
+static void GLAPIENTRY save_RasterPos4fv(const GLfloat *v)
 {
    save_RasterPos4f(v[0], v[1], v[2], v[3]);
 }
 
-static void save_RasterPos4iv(const GLint *v)
+static void GLAPIENTRY save_RasterPos4iv(const GLint *v)
 {
-   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
                    (GLfloat) v[2], (GLfloat) v[3]);
 }
 
-static void save_RasterPos4sv(const GLshort *v)
+static void GLAPIENTRY save_RasterPos4sv(const GLshort *v)
 {
    save_RasterPos4f(v[0], v[1], v[2], v[3]);
 }
 
 
-static void save_PassThrough( GLfloat token )
+static void GLAPIENTRY save_PassThrough( GLfloat token )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2820,7 +2997,7 @@ static void save_PassThrough( GLfloat token )
 }
 
 
-static void save_ReadBuffer( GLenum mode )
+static void GLAPIENTRY save_ReadBuffer( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2835,7 +3012,7 @@ static void save_ReadBuffer( GLenum mode )
 }
 
 
-static void
+static void GLAPIENTRY
 save_ResetHistogram(GLenum target)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2851,7 +3028,7 @@ save_ResetHistogram(GLenum target)
 }
 
 
-static void
+static void GLAPIENTRY
 save_ResetMinmax(GLenum target)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -2867,7 +3044,7 @@ save_ResetMinmax(GLenum target)
 }
 
 
-static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
+static void GLAPIENTRY save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2885,13 +3062,13 @@ static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
 }
 
 
-static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
+static void GLAPIENTRY save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
 {
    save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
 }
 
 
-static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
+static void GLAPIENTRY save_Scalef( GLfloat x, GLfloat y, GLfloat z )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2908,13 +3085,13 @@ static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
 }
 
 
-static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
+static void GLAPIENTRY save_Scaled( GLdouble x, GLdouble y, GLdouble z )
 {
    save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
 }
 
 
-static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
+static void GLAPIENTRY save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2932,7 +3109,7 @@ static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
 }
 
 
-static void save_ShadeModel( GLenum mode )
+static void GLAPIENTRY save_ShadeModel( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2947,7 +3124,7 @@ static void save_ShadeModel( GLenum mode )
 }
 
 
-static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
+static void GLAPIENTRY save_StencilFunc( GLenum func, GLint ref, GLuint mask )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2964,7 +3141,7 @@ static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
 }
 
 
-static void save_StencilMask( GLuint mask )
+static void GLAPIENTRY save_StencilMask( GLuint mask )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2979,7 +3156,7 @@ static void save_StencilMask( GLuint mask )
 }
 
 
-static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
+static void GLAPIENTRY save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2996,7 +3173,7 @@ static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
 }
 
 
-static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
+static void GLAPIENTRY save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3016,13 +3193,13 @@ static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
 }
 
 
-static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
+static void GLAPIENTRY save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
 {
    save_TexEnvfv( target, pname, &param );
 }
 
 
-static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
+static void GLAPIENTRY save_TexEnvi( GLenum target, GLenum pname, GLint param )
 {
    GLfloat p[4];
    p[0] = (GLfloat) param;
@@ -3031,7 +3208,7 @@ static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
 }
 
 
-static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
+static void GLAPIENTRY save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
 {
    GLfloat p[4];
    p[0] = INT_TO_FLOAT( param[0] );
@@ -3042,7 +3219,7 @@ static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
 }
 
 
-static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
+static void GLAPIENTRY save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3062,7 +3239,7 @@ static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
 }
 
 
-static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
+static void GLAPIENTRY save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
 {
    GLfloat p[4];
    p[0] = (GLfloat) params[0];
@@ -3073,14 +3250,14 @@ static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
 }
 
 
-static void save_TexGend(GLenum coord, GLenum pname, GLdouble param )
+static void GLAPIENTRY save_TexGend(GLenum coord, GLenum pname, GLdouble param )
 {
    GLfloat p = (GLfloat) param;
    save_TexGenfv( coord, pname, &p );
 }
 
 
-static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
+static void GLAPIENTRY save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
 {
    GLfloat p[4];
    p[0] = (GLfloat) params[0];
@@ -3091,19 +3268,19 @@ static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
 }
 
 
-static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
+static void GLAPIENTRY save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
 {
    save_TexGenfv(coord, pname, &param);
 }
 
 
-static void save_TexGeni( GLenum coord, GLenum pname, GLint param )
+static void GLAPIENTRY save_TexGeni( GLenum coord, GLenum pname, GLint param )
 {
    save_TexGeniv( coord, pname, &param );
 }
 
 
-static void save_TexParameterfv( GLenum target,
+static void GLAPIENTRY save_TexParameterfv( GLenum target,
                              GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -3124,13 +3301,13 @@ static void save_TexParameterfv( GLenum target,
 }
 
 
-static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
+static void GLAPIENTRY save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
 {
    save_TexParameterfv(target, pname, &param);
 }
 
 
-static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
+static void GLAPIENTRY save_TexParameteri( GLenum target, GLenum pname, GLint param )
 {
    GLfloat fparam[4];
    fparam[0] = (GLfloat) param;
@@ -3139,7 +3316,7 @@ static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
 }
 
 
-static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
+static void GLAPIENTRY save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
 {
    GLfloat fparam[4];
    fparam[0] = (GLfloat) params[0];
@@ -3148,7 +3325,7 @@ static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *param
 }
 
 
-static void save_TexImage1D( GLenum target,
+static void GLAPIENTRY save_TexImage1D( GLenum target,
                              GLint level, GLint components,
                              GLsizei width, GLint border,
                              GLenum format, GLenum type,
@@ -3187,7 +3364,7 @@ static void save_TexImage1D( GLenum target,
 }
 
 
-static void save_TexImage2D( GLenum target,
+static void GLAPIENTRY save_TexImage2D( GLenum target,
                              GLint level, GLint components,
                              GLsizei width, GLsizei height, GLint border,
                              GLenum format, GLenum type,
@@ -3227,8 +3404,8 @@ static void save_TexImage2D( GLenum target,
 }
 
 
-static void save_TexImage3D( GLenum target,
-                             GLint level, GLenum internalFormat,
+static void GLAPIENTRY save_TexImage3D( GLenum target,
+                             GLint level, GLint internalFormat,
                              GLsizei width, GLsizei height, GLsizei depth,
                              GLint border,
                              GLenum format, GLenum type,
@@ -3269,7 +3446,7 @@ static void save_TexImage3D( GLenum target,
 }
 
 
-static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
+static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
                                 GLsizei width, GLenum format, GLenum type,
                                 const GLvoid *pixels )
 {
@@ -3298,7 +3475,7 @@ static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
 }
 
 
-static void save_TexSubImage2D( GLenum target, GLint level,
+static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level,
                                 GLint xoffset, GLint yoffset,
                                 GLsizei width, GLsizei height,
                                 GLenum format, GLenum type,
@@ -3331,7 +3508,7 @@ static void save_TexSubImage2D( GLenum target, GLint level,
 }
 
 
-static void save_TexSubImage3D( GLenum target, GLint level,
+static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level,
                                 GLint xoffset, GLint yoffset,GLint zoffset,
                                 GLsizei width, GLsizei height, GLsizei depth,
                                 GLenum format, GLenum type,
@@ -3367,7 +3544,7 @@ static void save_TexSubImage3D( GLenum target, GLint level,
 }
 
 
-static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
+static void GLAPIENTRY save_Translatef( GLfloat x, GLfloat y, GLfloat z )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3384,14 +3561,14 @@ static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
 }
 
 
-static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
+static void GLAPIENTRY save_Translated( GLdouble x, GLdouble y, GLdouble z )
 {
    save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
 }
 
 
 
-static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
+static void GLAPIENTRY save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3409,12 +3586,11 @@ static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
 }
 
 
-static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+static void GLAPIENTRY save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT(ctx, 0);
    n = ALLOC_INSTRUCTION( ctx,  OPCODE_WINDOW_POS, 4 );
    if (n) {
       n[1].f = x;
@@ -3427,119 +3603,119 @@ static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
    }
 }
 
-static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
+static void GLAPIENTRY save_WindowPos2dMESA(GLdouble x, GLdouble y)
 {
    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
-static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
+static void GLAPIENTRY save_WindowPos2fMESA(GLfloat x, GLfloat y)
 {
    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
 }
 
-static void save_WindowPos2iMESA(GLint x, GLint y)
+static void GLAPIENTRY save_WindowPos2iMESA(GLint x, GLint y)
 {
    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
-static void save_WindowPos2sMESA(GLshort x, GLshort y)
+static void GLAPIENTRY save_WindowPos2sMESA(GLshort x, GLshort y)
 {
    save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
 }
 
-static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
+static void GLAPIENTRY save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
 {
    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
-static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
+static void GLAPIENTRY save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
 {
    save_WindowPos4fMESA(x, y, z, 1.0F);
 }
 
-static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
+static void GLAPIENTRY save_WindowPos3iMESA(GLint x, GLint y, GLint z)
 {
    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
-static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
+static void GLAPIENTRY save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
 {
    save_WindowPos4fMESA(x, y, z, 1.0F);
 }
 
-static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+static void GLAPIENTRY save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
-static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
+static void GLAPIENTRY save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
 {
    save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
-static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
+static void GLAPIENTRY save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
 {
    save_WindowPos4fMESA(x, y, z, w);
 }
 
-static void save_WindowPos2dvMESA(const GLdouble *v)
+static void GLAPIENTRY save_WindowPos2dvMESA(const GLdouble *v)
 {
    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
-static void save_WindowPos2fvMESA(const GLfloat *v)
+static void GLAPIENTRY save_WindowPos2fvMESA(const GLfloat *v)
 {
    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
 }
 
-static void save_WindowPos2ivMESA(const GLint *v)
+static void GLAPIENTRY save_WindowPos2ivMESA(const GLint *v)
 {
    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
-static void save_WindowPos2svMESA(const GLshort *v)
+static void GLAPIENTRY save_WindowPos2svMESA(const GLshort *v)
 {
    save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
 }
 
-static void save_WindowPos3dvMESA(const GLdouble *v)
+static void GLAPIENTRY save_WindowPos3dvMESA(const GLdouble *v)
 {
    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
-static void save_WindowPos3fvMESA(const GLfloat *v)
+static void GLAPIENTRY save_WindowPos3fvMESA(const GLfloat *v)
 {
    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
 }
 
-static void save_WindowPos3ivMESA(const GLint *v)
+static void GLAPIENTRY save_WindowPos3ivMESA(const GLint *v)
 {
    save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
-static void save_WindowPos3svMESA(const GLshort *v)
+static void GLAPIENTRY save_WindowPos3svMESA(const GLshort *v)
 {
    save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
 }
 
-static void save_WindowPos4dvMESA(const GLdouble *v)
+static void GLAPIENTRY save_WindowPos4dvMESA(const GLdouble *v)
 {
-   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
                        (GLfloat) v[2], (GLfloat) v[3]);
 }
 
-static void save_WindowPos4fvMESA(const GLfloat *v)
+static void GLAPIENTRY save_WindowPos4fvMESA(const GLfloat *v)
 {
    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
 }
 
-static void save_WindowPos4ivMESA(const GLint *v)
+static void GLAPIENTRY save_WindowPos4ivMESA(const GLint *v)
 {
-   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
                        (GLfloat) v[2], (GLfloat) v[3]);
 }
 
-static void save_WindowPos4svMESA(const GLshort *v)
+static void GLAPIENTRY save_WindowPos4svMESA(const GLshort *v)
 {
    save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
 }
@@ -3547,7 +3723,7 @@ static void save_WindowPos4svMESA(const GLshort *v)
 
 
 /* GL_ARB_multitexture */
-static void save_ActiveTextureARB( GLenum target )
+static void GLAPIENTRY save_ActiveTextureARB( GLenum target )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3564,7 +3740,7 @@ static void save_ActiveTextureARB( GLenum target )
 
 /* GL_ARB_transpose_matrix */
 
-static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
+static void GLAPIENTRY save_LoadTransposeMatrixdARB( const GLdouble m[16] )
 {
    GLfloat tm[16];
    _math_transposefd(tm, m);
@@ -3572,7 +3748,7 @@ static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
 }
 
 
-static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
+static void GLAPIENTRY save_LoadTransposeMatrixfARB( const GLfloat m[16] )
 {
    GLfloat tm[16];
    _math_transposef(tm, m);
@@ -3580,7 +3756,7 @@ static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
 }
 
 
-static void
+static void GLAPIENTRY
 save_MultTransposeMatrixdARB( const GLdouble m[16] )
 {
    GLfloat tm[16];
@@ -3589,7 +3765,7 @@ save_MultTransposeMatrixdARB( const GLdouble m[16] )
 }
 
 
-static void
+static void GLAPIENTRY
 save_MultTransposeMatrixfARB( const GLfloat m[16] )
 {
    GLfloat tm[16];
@@ -3598,7 +3774,7 @@ save_MultTransposeMatrixfARB( const GLfloat m[16] )
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelTexGenSGIX(GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -3615,7 +3791,7 @@ save_PixelTexGenSGIX(GLenum mode)
 
 
 /* GL_ARB_texture_compression */
-static void
+static void GLAPIENTRY
 save_CompressedTexImage1DARB(GLenum target, GLint level,
                              GLenum internalFormat, GLsizei width,
                              GLint border, GLsizei imageSize,
@@ -3659,7 +3835,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CompressedTexImage2DARB(GLenum target, GLint level,
                              GLenum internalFormat, GLsizei width,
                              GLsizei height, GLint border, GLsizei imageSize,
@@ -3704,7 +3880,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CompressedTexImage3DARB(GLenum target, GLint level,
                              GLenum internalFormat, GLsizei width,
                              GLsizei height, GLsizei depth, GLint border,
@@ -3750,7 +3926,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
                                 GLsizei width, GLenum format,
                                 GLsizei imageSize, const GLvoid *data)
@@ -3783,12 +3959,12 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
    }
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset,
-                                               width, format, imageSize, data);
+                                            width, format, imageSize, data);
    }
 }
 
 
-static void
+static void GLAPIENTRY
 save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
                                 GLint yoffset, GLsizei width, GLsizei height,
                                 GLenum format, GLsizei imageSize,
@@ -3829,7 +4005,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
 }
 
 
-static void
+static void GLAPIENTRY
 save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
                                 GLint yoffset, GLint zoffset, GLsizei width,
                                 GLsizei height, GLsizei depth, GLenum format,
@@ -3873,7 +4049,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
 
 
 /* GL_ARB_multisample */
-static void
+static void GLAPIENTRY
 save_SampleCoverageARB(GLclampf value, GLboolean invert)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -3892,7 +4068,7 @@ save_SampleCoverageARB(GLclampf value, GLboolean invert)
 
 /* GL_SGIS_pixel_texture */
 
-static void
+static void GLAPIENTRY
 save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -3909,141 +4085,1203 @@ save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
 {
    save_PixelTexGenParameteriSGIS(target, (GLint) value);
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
 {
    save_PixelTexGenParameteriSGIS(target, *value);
 }
 
 
-static void
+static void GLAPIENTRY
 save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
 {
    save_PixelTexGenParameteriSGIS(target, (GLint) *value);
 }
 
 
-/* KW: Compile commands
- *
- * Will appear in the list before the vertex buffer containing the
- * command that provoked the error.  I don't see this as a problem.
+/*
+ * GL_NV_vertex_program
  */
-void
-_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
+#if FEATURE_NV_vertex_program
+static void GLAPIENTRY
+save_BindProgramNV(GLenum target, GLuint id)
 {
+   GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_PROGRAM_NV, 2 );
    if (n) {
-      n[1].e = error;
-      n[2].data = (void *) s;
+      n[1].e = target;
+      n[2].ui = id;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->BindProgramNV)( target, id );
+   }
+}
+
+static void GLAPIENTRY
+save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EXECUTE_PROGRAM_NV, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = id;
+      n[3].f = params[0];
+      n[4].f = params[1];
+      n[5].f = params[2];
+      n[6].f = params[3];
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ExecuteProgramNV)(target, id, params);
    }
-   /* execute already done */
 }
 
 
-static GLboolean
-islist(GLcontext *ctx, GLuint list)
+static void GLAPIENTRY
+save_ProgramParameter4fNV(GLenum target, GLuint index,
+                          GLfloat x, GLfloat y,
+                          GLfloat z, GLfloat w)
 {
-   if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
-      return GL_TRUE;
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = index;
+      n[3].f = x;
+      n[4].f = y;
+      n[5].f = z;
+      n[6].f = w;
    }
-   else {
-      return GL_FALSE;
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramParameter4fNV)(target, index, x, y, z, w);
    }
 }
 
 
+static void GLAPIENTRY
+save_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params)
+{
+   save_ProgramParameter4fNV(target, index, params[0], params[1],
+                             params[2], params[3]);
+}
 
-/**********************************************************************/
-/*                     Display list execution                         */
-/**********************************************************************/
 
+static void GLAPIENTRY
+save_ProgramParameter4dNV(GLenum target, GLuint index,
+                          GLdouble x, GLdouble y,
+                          GLdouble z, GLdouble w)
+{
+   save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y,
+                             (GLfloat) z, (GLfloat) w);
+}
 
-/*
- * Execute a display list.  Note that the ListBase offset must have already
- * been added before calling this function.  I.e. the list argument is
- * the absolute list number, not relative to ListBase.
- * Input:  list - display list number
- */
-static void
-execute_list( GLcontext *ctx, GLuint list )
+
+static void GLAPIENTRY
+save_ProgramParameter4dvNV(GLenum target, GLuint index,
+                           const GLdouble *params)
+{
+   save_ProgramParameter4fNV(target, index, (GLfloat) params[0],
+                             (GLfloat) params[1], (GLfloat) params[2],
+                             (GLfloat) params[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameters4dvNV(GLenum target, GLuint index,
+                            GLuint num, const GLdouble *params)
+{
+   GLuint i;
+   for (i = 0; i < num; i++) {
+      save_ProgramParameter4dvNV(target, index + i, params + 4 * i);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameters4fvNV(GLenum target, GLuint index,
+                            GLuint num, const GLfloat *params)
+{
+   GLuint i;
+   for (i = 0; i < num; i++) {
+      save_ProgramParameter4fvNV(target, index + i, params + 4 * i);
+   }
+}
+
+
+static void GLAPIENTRY
+save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
+                   const GLubyte *program)
 {
+   GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   GLboolean done;
+   GLubyte *programCopy;
 
-   if (!islist(ctx,list))
+   programCopy = (GLubyte *) _mesa_malloc(len);
+   if (!programCopy) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
       return;
+   }
+   _mesa_memcpy(programCopy, program, len);
 
-   if (ctx->Driver.BeginCallList)
-      ctx->Driver.BeginCallList( ctx, list );
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_PROGRAM_NV, 4 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = id;
+      n[3].i = len;
+      n[4].data = programCopy;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->LoadProgramNV)(target, id, len, program);
+   }
+}
 
-/*     fprintf(stderr, "execute list %d\n", list); */
-/*     mesa_print_display_list( list );  */
 
-   ctx->CallDepth++;
+static void GLAPIENTRY
+save_RequestResidentProgramsNV(GLsizei num, const GLuint *ids)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
+   if (!idCopy) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
+      return;
+   }
+   _mesa_memcpy(idCopy, ids, num * sizeof(GLuint));
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 2 );
+   if (n) {
+      n[1].i = num;
+      n[2].data = idCopy;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->RequestResidentProgramsNV)(num, ids);
+   }
+}
 
-   n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
 
-   done = GL_FALSE;
-   while (!done) {
-      OpCode opcode = n[0].opcode;
-      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+static void GLAPIENTRY
+save_TrackMatrixNV(GLenum target, GLuint address,
+                   GLenum matrix, GLenum transform)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 4 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = address;
+      n[3].e = matrix;
+      n[4].e = transform;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->TrackMatrixNV)(target, address, matrix, transform);
+   }
+}
+#endif /* FEATURE_NV_vertex_program */
 
-      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
-        ctx->listext.opcode[i].execute(ctx, &n[1]);
-        n += ctx->listext.opcode[i].size;
-      }
-      else {
-        switch (opcode) {
-        case OPCODE_ERROR:
-           _mesa_error( ctx, n[1].e, (const char *) n[2].data );
-           break;
-         case OPCODE_ACCUM:
-           (*ctx->Exec->Accum)( n[1].e, n[2].f );
-           break;
-         case OPCODE_ALPHA_FUNC:
-           (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
-           break;
-         case OPCODE_BIND_TEXTURE:
-            (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
-            break;
-        case OPCODE_BITMAP:
-            {
-               struct gl_pixelstore_attrib save = ctx->Unpack;
-               ctx->Unpack = _mesa_native_packing;
-               (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
-                 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
-               ctx->Unpack = save;  /* restore */
-            }
-           break;
-        case OPCODE_BLEND_COLOR:
-           (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
-           break;
-        case OPCODE_BLEND_EQUATION:
-           (*ctx->Exec->BlendEquation)( n[1].e );
-           break;
-        case OPCODE_BLEND_FUNC:
-           (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
-           break;
-        case OPCODE_BLEND_FUNC_SEPARATE:
-           (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
-           break;
-         case OPCODE_CALL_LIST:
-           /* Generated by glCallList(), don't add ListBase */
-            if (ctx->CallDepth<MAX_LIST_NESTING) {
-               execute_list( ctx, n[1].ui );
-            }
+
+/*
+ * GL_NV_fragment_program
+ */
+#if FEATURE_NV_fragment_program
+static void GLAPIENTRY
+save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
+                                GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = index;
+      n[3].f = x;
+      n[4].f = y;
+      n[5].f = z;
+      n[6].f = w;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramLocalParameter4fARB)(target, index, x, y, z, w);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
+                                 const GLfloat *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = index;
+      n[3].f = params[0];
+      n[4].f = params[1];
+      n[5].f = params[2];
+      n[6].f = params[3];
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramLocalParameter4fvARB)(target, index, params);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
+                                GLdouble x, GLdouble y,
+                                GLdouble z, GLdouble w)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = index;
+      n[3].f = (GLfloat) x;
+      n[4].f = (GLfloat) y;
+      n[5].f = (GLfloat) z;
+      n[6].f = (GLfloat) w;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramLocalParameter4dARB)(target, index, x, y, z, w);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
+                                 const GLdouble *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = index;
+      n[3].f = (GLfloat) params[0];
+      n[4].f = (GLfloat) params[1];
+      n[5].f = (GLfloat) params[2];
+      n[6].f = (GLfloat) params[3];
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramLocalParameter4dvARB)(target, index, params);
+   }
+}
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
+                               GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
+   if (!nameCopy) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
+      return;
+   }
+   _mesa_memcpy(nameCopy, name, len);
+
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6 );
+   if (n) {
+      n[1].ui = id;
+      n[2].i = len;
+      n[3].data = nameCopy;
+      n[4].f = x;
+      n[5].f = y;
+      n[6].f = z;
+      n[7].f = w;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramNamedParameter4fNV)(id, len, name, x, y, z, w);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name,
+                                const float v[])
+{
+   save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name,
+                               GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+   save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
+                                  (GLfloat) z,(GLfloat) w);
+}
+
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name,
+                                const double v[])
+{
+   save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
+                                  (GLfloat) v[1], (GLfloat) v[2],
+                                  (GLfloat) v[3]);
+}
+
+#endif /* FEATURE_NV_fragment_program */
+
+
+
+/* GL_EXT_stencil_two_side */
+static void GLAPIENTRY save_ActiveStencilFaceEXT( GLenum face )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1 );
+   if (n) {
+      n[1].e = face;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ActiveStencilFaceEXT)( face );
+   }
+}
+
+
+/* GL_EXT_depth_bounds_test */
+static void GLAPIENTRY save_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 2 );
+   if (n) {
+      n[1].f = (GLfloat) zmin;
+      n[2].f = (GLfloat) zmax;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->DepthBoundsEXT)( zmin, zmax );
+   }
+}
+
+
+
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+
+static void GLAPIENTRY
+save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
+                      const GLvoid *string)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   GLubyte *programCopy;
+
+   programCopy = (GLubyte *) _mesa_malloc(len);
+   if (!programCopy) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
+      return;
+   }
+   _mesa_memcpy(programCopy, string, len);
+
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_STRING_ARB, 4 );
+   if (n) {
+      n[1].e = target;
+      n[2].e = format;
+      n[3].i = len;
+      n[4].data = programCopy;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramStringARB)(target, format, len, string);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
+                              GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = index;
+      n[3].f = x;
+      n[4].f = y;
+      n[5].f = z;
+      n[6].f = w;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramEnvParameter4fARB)( target, index, x, y, z, w);
+   }
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
+                               const GLfloat *params)
+{
+   save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
+                                 params[2], params[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
+                              GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+   save_ProgramEnvParameter4fARB(target, index,
+                                 (GLfloat) x,
+                                 (GLfloat) y,
+                                 (GLfloat) z,
+                                 (GLfloat) w);
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
+                               const GLdouble *params)
+{
+   save_ProgramEnvParameter4fARB(target, index,
+                                 (GLfloat) params[0],
+                                 (GLfloat) params[1],
+                                 (GLfloat) params[2],
+                                 (GLfloat) params[3]);
+}
+
+#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
+
+
+
+
+static void save_Attr1f( GLenum attr, GLfloat x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F, 2 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+   }
+
+   ctx->ListState.ActiveAttribSize[attr] = 1;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib1fNV)( attr, x );
+   }
+}
+
+static void save_Attr2f( GLenum attr, GLfloat x, GLfloat y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F, 3 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+   }
+
+   ctx->ListState.ActiveAttribSize[attr] = 2;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib2fNV)( attr, x, y );
+   }
+}
+
+static void save_Attr3f( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F, 4 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+      n[4].f = z;
+   }
+
+   ctx->ListState.ActiveAttribSize[attr] = 3;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib3fNV)( attr, x, y, z );
+   }
+}
+
+static void save_Attr4f( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
+                        GLfloat w )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F, 5 );
+   if (n) {
+      n[1].e = attr;
+      n[2].f = x;
+      n[3].f = y;
+      n[4].f = z;
+      n[5].f = w;
+   }
+
+   ctx->ListState.ActiveAttribSize[attr] = 4;
+   ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->VertexAttrib4fNV)( attr, x, y, z, w );
+   }
+}
+
+static void GLAPIENTRY save_EvalCoord1f( GLfloat x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C1, 1 );
+   if (n) {
+      n[1].f = x;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalCoord1f)( x );
+   }
+}
+
+static void GLAPIENTRY save_EvalCoord1fv( const GLfloat *v )
+{
+   save_EvalCoord1f( v[0] );
+}
+
+static void GLAPIENTRY save_EvalCoord2f( GLfloat x, GLfloat y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C2, 2 );
+   if (n) {
+      n[1].f = x;
+      n[2].f = y;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalCoord2f)( x, y );
+   }
+}
+
+static void GLAPIENTRY save_EvalCoord2fv( const GLfloat *v )
+{
+   save_EvalCoord2f( v[0], v[1] );
+}
+
+
+static void GLAPIENTRY save_EvalPoint1( GLint x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P1, 1 );
+   if (n) {
+      n[1].i = x;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalPoint1)( x );
+   }
+}
+
+static void GLAPIENTRY save_EvalPoint2( GLint x, GLint y )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P2, 2 );
+   if (n) {
+      n[1].i = x;
+      n[2].i = y;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EvalPoint2)( x, y );
+   }
+}
+
+static void GLAPIENTRY save_Indexf( GLfloat x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX, 1 );
+   if (n) {
+      n[1].f = x;
+   }
+
+   ctx->ListState.ActiveIndex = 1;
+   ctx->ListState.CurrentIndex = x;
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Indexi)( (GLint) x );
+   }
+}
+
+static void GLAPIENTRY save_Indexfv( const GLfloat *v )
+{
+   save_Indexf( v[0] );
+}
+
+static void GLAPIENTRY save_EdgeFlag( GLboolean x )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_EDGEFLAG, 1 );
+   if (n) {
+      n[1].b = x;
+   }
+
+   ctx->ListState.ActiveEdgeFlag = 1;
+   ctx->ListState.CurrentEdgeFlag = x;
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->EdgeFlag)( x );
+   }
+}
+
+static void GLAPIENTRY save_EdgeFlagv( const GLboolean *v )
+{
+   save_EdgeFlag( v[0] );
+}
+
+static void GLAPIENTRY save_Materialfv( GLenum face, GLenum pname, const GLfloat *param )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   int args, i;
+
+   SAVE_FLUSH_VERTICES( ctx );
+
+   switch (face) {
+   case GL_BACK:
+   case GL_FRONT:
+   case GL_FRONT_AND_BACK:
+      break;
+   default:
+      _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(face)" );
+      return;
+   }
+
+   switch (pname) {
+   case GL_EMISSION:
+   case GL_AMBIENT:
+   case GL_DIFFUSE:
+   case GL_SPECULAR:
+   case GL_AMBIENT_AND_DIFFUSE:
+      args = 4;
+      break;
+   case GL_SHININESS:
+      args = 1;
+      break;
+   case GL_COLOR_INDEXES:
+      args = 3;
+      break;
+   default:
+      _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(pname)" );
+      return;
+   }
+
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_MATERIAL, 6 );
+   if (n) {
+      n[1].e = face;
+      n[2].e = pname;
+      for (i = 0 ; i < args ; i++)
+        n[3+i].f = param[i];
+   }
+
+   {
+      GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, 0 );
+      for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
+        if (bitmask & (1<<i)) {
+           ctx->ListState.ActiveMaterialSize[i] = args;
+           COPY_SZ_4V( ctx->ListState.CurrentMaterial[i], args, param );
+        }
+   }
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Materialfv)( face, pname, param );
+   }
+}
+
+static void GLAPIENTRY save_Begin( GLenum mode )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   GLboolean error = GL_FALSE;
+
+   if (mode < GL_POINTS || mode > GL_POLYGON) {
+      _mesa_compile_error( ctx, GL_INVALID_ENUM, "Begin (mode)");
+      error = GL_TRUE;
+   }
+   else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
+      /* Typically the first begin.  This may raise an error on
+       * playback, depending on whether CallList is issued from inside
+       * a begin/end or not.
+       */
+      ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
+   }
+   else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
+      ctx->Driver.CurrentSavePrimitive = mode;
+   }
+   else {
+      _mesa_compile_error( ctx, GL_INVALID_OPERATION, "recursive begin" );
+      error = GL_TRUE;
+   }
+
+   if (!error) {
+      /* Give the driver an opportunity to hook in an optimized
+       * display list compiler.
+       */
+      if (ctx->Driver.NotifySaveBegin( ctx, mode ))
+        return;
+
+      SAVE_FLUSH_VERTICES( ctx );
+      n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN, 1 );
+      if (n) {
+        n[1].e = mode;
+      }
+   }
+
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Begin)( mode );
+   }
+}
+
+static void GLAPIENTRY save_End( void )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   SAVE_FLUSH_VERTICES( ctx );
+   (void) ALLOC_INSTRUCTION( ctx, OPCODE_END, 0 );
+   ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->End)( );
+   }
+}
+
+static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b,
+                       GLfloat c, GLfloat d )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   SAVE_FLUSH_VERTICES( ctx );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_RECTF, 4 );
+   if (n) {
+      n[1].f = a;
+      n[2].f = b;
+      n[3].f = c;
+      n[4].f = d;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->Rectf)( a, b, c, d );
+   }
+}
+
+/*
+ */
+static void GLAPIENTRY save_Vertex2f( GLfloat x, GLfloat y )
+{
+   save_Attr2f( VERT_ATTRIB_POS, x, y );
+}
+
+static void GLAPIENTRY save_Vertex2fv( const GLfloat *v )
+{
+   save_Attr2f( VERT_ATTRIB_POS, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3f( VERT_ATTRIB_POS, x, y, z );
+}
+
+static void GLAPIENTRY save_Vertex3fv( const GLfloat *v )
+{
+   save_Attr3f( VERT_ATTRIB_POS, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   save_Attr4f( VERT_ATTRIB_POS, x, y, z, w );
+}
+
+static void GLAPIENTRY save_Vertex4fv( const GLfloat *v )
+{
+   save_Attr4f( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_TexCoord1f( GLfloat x )
+{
+   save_Attr1f( VERT_ATTRIB_TEX0, x );
+}
+
+static void GLAPIENTRY save_TexCoord1fv( const GLfloat *v )
+{
+   save_Attr1f( VERT_ATTRIB_TEX0, v[0] );
+}
+
+static void GLAPIENTRY save_TexCoord2f( GLfloat x, GLfloat y )
+{
+   save_Attr2f( VERT_ATTRIB_TEX0, x, y );
+}
+
+static void GLAPIENTRY save_TexCoord2fv( const GLfloat *v )
+{
+   save_Attr2f( VERT_ATTRIB_TEX0, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3f( VERT_ATTRIB_TEX0, x, y, z );
+}
+
+static void GLAPIENTRY save_TexCoord3fv( const GLfloat *v )
+{
+   save_Attr3f( VERT_ATTRIB_TEX0, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   save_Attr4f( VERT_ATTRIB_TEX0, x, y, z, w );
+}
+
+static void GLAPIENTRY save_TexCoord4fv( const GLfloat *v )
+{
+   save_Attr4f( VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3f( VERT_ATTRIB_NORMAL, x, y, z );
+}
+
+static void GLAPIENTRY save_Normal3fv( const GLfloat *v )
+{
+   save_Attr3f( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_FogCoordfEXT( GLfloat x )
+{
+   save_Attr1f( VERT_ATTRIB_FOG, x );
+}
+
+static void GLAPIENTRY save_FogCoordfvEXT( const GLfloat *v )
+{
+   save_Attr1f( VERT_ATTRIB_FOG, v[0] );
+}
+
+static void GLAPIENTRY save_Color3f( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3f( VERT_ATTRIB_COLOR0, x, y, z );
+}
+
+static void GLAPIENTRY save_Color3fv( const GLfloat *v )
+{
+   save_Attr3f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+   save_Attr4f( VERT_ATTRIB_COLOR0, x, y, z, w );
+}
+
+static void GLAPIENTRY save_Color4fv( const GLfloat *v )
+{
+   save_Attr4f( VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
+{
+   save_Attr3f( VERT_ATTRIB_COLOR1, x, y, z );
+}
+
+static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
+{
+   save_Attr3f( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
+}
+
+
+/* Just call the respective ATTR for texcoord
+ */
+static void GLAPIENTRY save_MultiTexCoord1f( GLenum target, GLfloat x  )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr1f( attr, x );
+}
+
+static void GLAPIENTRY save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr1f( attr, v[0] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr2f( attr, x, y );
+}
+
+static void GLAPIENTRY save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr2f( attr, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
+                                   GLfloat z)
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr3f( attr, x, y, z );
+}
+
+static void GLAPIENTRY save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr3f( attr, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
+                                 GLfloat z, GLfloat w )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr4f( attr, x, y, z, w );
+}
+
+static void GLAPIENTRY save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
+{
+   GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+   save_Attr4f( attr, v[0], v[1], v[2], v[3] );
+}
+
+
+static void enum_error( void )
+{
+   GET_CURRENT_CONTEXT( ctx );
+   _mesa_error( ctx, GL_INVALID_ENUM, "VertexAttribfNV" );
+}
+
+/* First level for NV_vertex_program:
+ *
+ * Check for errors at compile time?.
+ */
+static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr1f( index, x );
+   else
+      enum_error(); 
+}
+
+static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr1f( index, v[0] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr2f( index, x, y );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr2f( index, v[0], v[1] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, 
+                                  GLfloat z )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr3f( index, x, y, z );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr3f( index, v[0], v[1], v[2] );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
+                                  GLfloat z, GLfloat w )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr4f( index, x, y, z, w );
+   else
+      enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
+{
+   if (index < VERT_ATTRIB_MAX)
+      save_Attr4f( index, v[0], v[1], v[2], v[3] );
+   else
+      enum_error();
+}
+
+
+
+
+
+/* KW: Compile commands
+ *
+ * Will appear in the list before the vertex buffer containing the
+ * command that provoked the error.  I don't see this as a problem.
+ */
+void
+_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
+{
+   Node *n;
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
+   if (n) {
+      n[1].e = error;
+      n[2].data = (void *) s;
+   }
+   /* execute already done */
+}
+
+
+/*
+ * Compile an error into current display list.
+ */
+void
+_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
+{
+   if (ctx->CompileFlag)
+      _mesa_save_error( ctx, error, s );
+
+   if (ctx->ExecuteFlag)
+      _mesa_error( ctx, error, s );
+}
+
+
+
+static GLboolean
+islist(GLcontext *ctx, GLuint list)
+{
+   if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
+      return GL_TRUE;
+   }
+   else {
+      return GL_FALSE;
+   }
+}
+
+
+
+/**********************************************************************/
+/*                     Display list execution                         */
+/**********************************************************************/
+
+
+/*
+ * Execute a display list.  Note that the ListBase offset must have already
+ * been added before calling this function.  I.e. the list argument is
+ * the absolute list number, not relative to ListBase.
+ * \param list - display list number
+ */
+static void GLAPIENTRY
+execute_list( GLcontext *ctx, GLuint list )
+{
+   Node *n;
+   GLboolean done;
+
+   if (list == 0 || !islist(ctx,list))
+      return;
+
+   if (ctx->Driver.BeginCallList)
+      ctx->Driver.BeginCallList( ctx, list );
+
+   ctx->ListState.CallDepth++;
+
+   n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+
+   done = GL_FALSE;
+   while (!done) {
+      OpCode opcode = n[0].opcode;
+      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+
+      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
+        ctx->listext.opcode[i].execute(ctx, &n[1]);
+        n += ctx->listext.opcode[i].size;
+      }
+      else {
+        switch (opcode) {
+        case OPCODE_ERROR:
+           _mesa_error( ctx, n[1].e, (const char *) n[2].data );
+           break;
+         case OPCODE_ACCUM:
+           (*ctx->Exec->Accum)( n[1].e, n[2].f );
+           break;
+         case OPCODE_ALPHA_FUNC:
+           (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
+           break;
+         case OPCODE_BIND_TEXTURE:
+            (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
+            break;
+        case OPCODE_BITMAP:
+            {
+               struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = _mesa_native_packing;
+               (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
+                 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
+               ctx->Unpack = save;  /* restore */
+            }
+           break;
+        case OPCODE_BLEND_COLOR:
+           (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
+           break;
+        case OPCODE_BLEND_EQUATION:
+           (*ctx->Exec->BlendEquation)( n[1].e );
+           break;
+        case OPCODE_BLEND_FUNC_SEPARATE:
+           (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
+           break;
+         case OPCODE_CALL_LIST:
+           /* Generated by glCallList(), don't add ListBase */
+            if (ctx->ListState.CallDepth<MAX_LIST_NESTING) {
+               execute_list( ctx, n[1].ui );
+            }
             break;
          case OPCODE_CALL_LIST_OFFSET:
            /* Generated by glCallLists() so we must add ListBase */
-            if (ctx->CallDepth<MAX_LIST_NESTING) {
+            if (n[2].b) {
+               /* user specified a bad data type at compile time */
+               _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
+            }
+            else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
                execute_list( ctx, ctx->List.ListBase + n[1].ui );
             }
             break;
@@ -4611,6 +5849,114 @@ execute_list( GLcontext *ctx, GLuint list )
          case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
             (*ctx->Exec->SampleCoverageARB)(n[1].f, n[2].b);
             break;
+        case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
+            (*ctx->Exec->WindowPos3fMESA)( n[1].f, n[2].f, n[3].f );
+           break;
+#if FEATURE_NV_vertex_program
+         case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
+            (*ctx->Exec->BindProgramNV)( n[1].e, n[2].ui );
+            break;
+         case OPCODE_EXECUTE_PROGRAM_NV:
+            {
+               GLfloat v[4];
+               v[0] = n[3].f;
+               v[1] = n[4].f;
+               v[2] = n[5].f;
+               v[3] = n[6].f;
+               (*ctx->Exec->ExecuteProgramNV)(n[1].e, n[2].ui, v);
+            }
+            break;
+         case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
+            (*ctx->Exec->RequestResidentProgramsNV)(n[1].ui,
+                                                    (GLuint *) n[2].data);
+            break;
+         case OPCODE_LOAD_PROGRAM_NV:
+            (*ctx->Exec->LoadProgramNV)(n[1].e, n[2].ui, n[3].i,
+                                        (const GLubyte *) n[4].data);
+            break;
+         case OPCODE_PROGRAM_PARAMETER4F_NV:
+            (*ctx->Exec->ProgramParameter4fNV)(n[1].e, n[2].ui, n[3].f,
+                                               n[4].f, n[5].f, n[6].f);
+            break;
+         case OPCODE_TRACK_MATRIX_NV:
+            (*ctx->Exec->TrackMatrixNV)(n[1].e, n[2].ui, n[3].e, n[4].e);
+            break;
+#endif
+
+#if FEATURE_NV_fragment_program
+         case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
+            (*ctx->Exec->ProgramLocalParameter4fARB)(n[1].e, n[2].ui, n[3].f,
+                                                     n[4].f, n[5].f, n[6].f);
+            break;
+         case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
+            (*ctx->Exec->ProgramNamedParameter4fNV)(n[1].ui, n[2].i,
+                                               (const GLubyte *) n[3].data,
+                                               n[4].f, n[5].f, n[6].f, n[7].f);
+            break;
+#endif
+
+         case OPCODE_ACTIVE_STENCIL_FACE_EXT:
+            (*ctx->Exec->ActiveStencilFaceEXT)(n[1].e);
+            break;
+         case OPCODE_DEPTH_BOUNDS_EXT:
+            (*ctx->Exec->DepthBoundsEXT)(n[1].f, n[2].f);
+            break;
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+         case OPCODE_PROGRAM_STRING_ARB:
+            (*ctx->Exec->ProgramStringARB)(n[1].e, n[2].e, n[3].i, n[4].data);
+            break;
+         case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
+            (*ctx->Exec->ProgramEnvParameter4fARB)(n[1].e, n[2].ui, n[3].f,
+                                                   n[4].f, n[5].f, n[6].f);
+            break;
+#endif
+
+        case OPCODE_ATTR_1F:
+           (*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f);
+           break;
+        case OPCODE_ATTR_2F:
+           (*ctx->Exec->VertexAttrib2fvNV)(n[1].e, &n[2].f);
+           break;
+        case OPCODE_ATTR_3F:
+           (*ctx->Exec->VertexAttrib3fvNV)(n[1].e, &n[2].f);
+           break;
+        case OPCODE_ATTR_4F:
+           (*ctx->Exec->VertexAttrib4fvNV)(n[1].e, &n[2].f);
+           break;
+        case OPCODE_MATERIAL:
+           (*ctx->Exec->Materialfv)(n[1].e, n[2].e, &n[3].f);
+           break;
+        case OPCODE_INDEX:
+           (*ctx->Exec->Indexi)(n[1].i);
+           break;
+        case OPCODE_EDGEFLAG:
+           (*ctx->Exec->EdgeFlag)(n[1].b);
+           break;
+        case OPCODE_BEGIN:
+           (*ctx->Exec->Begin)(n[1].e);
+           break;
+        case OPCODE_END:
+           (*ctx->Exec->End)();
+           break;
+        case OPCODE_RECTF:
+           (*ctx->Exec->Rectf)(n[1].f, n[2].f, n[3].f, n[4].f);
+           break;
+        case OPCODE_EVAL_C1:
+           (*ctx->Exec->EvalCoord1f)(n[1].f);
+           break;
+        case OPCODE_EVAL_C2:
+           (*ctx->Exec->EvalCoord2fv)(&n[1].f);
+           break;
+        case OPCODE_EVAL_P1:
+           (*ctx->Exec->EvalPoint1)(n[1].i);
+           break;
+        case OPCODE_EVAL_P2:
+           (*ctx->Exec->EvalPoint2)(n[1].i, n[2].i);
+           break;
+
+
+
+
         case OPCODE_CONTINUE:
            n = (Node *) n[1].next;
            break;
@@ -4620,8 +5966,8 @@ execute_list( GLcontext *ctx, GLuint list )
         default:
             {
                char msg[1000];
-               sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
-               _mesa_problem( ctx, msg );
+               _mesa_sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
+               _mesa_problem(ctx, msg);
             }
             done = GL_TRUE;
         }
@@ -4632,7 +5978,7 @@ execute_list( GLcontext *ctx, GLuint list )
         }
       }
    }
-   ctx->CallDepth--;
+   ctx->ListState.CallDepth--;
 
    if (ctx->Driver.EndCallList)
       ctx->Driver.EndCallList( ctx );
@@ -4652,7 +5998,7 @@ execute_list( GLcontext *ctx, GLuint list )
 /*
  * Test if a display list number is valid.
  */
-GLboolean
+GLboolean GLAPIENTRY
 _mesa_IsList( GLuint list )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -4665,7 +6011,7 @@ _mesa_IsList( GLuint list )
 /*
  * Delete a sequence of consecutive display lists.
  */
-void
+void GLAPIENTRY
 _mesa_DeleteLists( GLuint list, GLsizei range )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -4688,7 +6034,7 @@ _mesa_DeleteLists( GLuint list, GLsizei range )
  * Return a display list number, n, such that lists n through n+range-1
  * are free.
  */
-GLuint
+GLuint GLAPIENTRY
 _mesa_GenLists(GLsizei range )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -4728,15 +6074,18 @@ _mesa_GenLists(GLsizei range )
 /*
  * Begin a new display list.
  */
-void
+void GLAPIENTRY
 _mesa_NewList( GLuint list, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
+   GLint i;
+
    FLUSH_CURRENT(ctx, 0);      /* must be called before assert */
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE&VERBOSE_API)
-      fprintf(stderr, "glNewList %u %s\n", list, _mesa_lookup_enum_by_nr(mode));
+      _mesa_debug(ctx, "glNewList %u %s\n", list,
+                  _mesa_lookup_enum_by_nr(mode));
 
    if (list==0) {
       _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
@@ -4748,20 +6097,33 @@ _mesa_NewList( GLuint list, GLenum mode )
       return;
    }
 
-   if (ctx->CurrentListPtr) {
+   if (ctx->ListState.CurrentListPtr) {
       /* already compiling a display list */
       _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
       return;
    }
 
-   /* Allocate new display list */
-   ctx->CurrentListNum = list;
-   ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
-   ctx->CurrentListPtr = ctx->CurrentBlock;
-   ctx->CurrentPos = 0;
    ctx->CompileFlag = GL_TRUE;
    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
 
+   /* Allocate new display list */
+   ctx->ListState.CurrentListNum = list;
+   ctx->ListState.CurrentBlock = (Node *) CALLOC( sizeof(Node) * BLOCK_SIZE );
+   ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
+   ctx->ListState.CurrentPos = 0;
+
+   /* Reset acumulated list state:
+    */
+   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+      ctx->ListState.ActiveAttribSize[i] = 0;
+
+   for (i = 0; i < MAT_ATTRIB_MAX; i++)
+      ctx->ListState.ActiveMaterialSize[i] = 0;
+      
+   ctx->ListState.ActiveIndex = 0;
+   ctx->ListState.ActiveEdgeFlag = 0;
+
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
    ctx->Driver.NewList( ctx, list, mode );
 
    ctx->CurrentDispatch = ctx->Save;
@@ -4771,23 +6133,20 @@ _mesa_NewList( GLuint list, GLenum mode )
 
 
 /*
- * End definition of current display list.  Is the current
- * ASSERT_OUTSIDE_BEGIN_END strong enough to really guarentee that
- * we are outside begin/end calls?
+ * End definition of current display list. 
  */
-void
+void GLAPIENTRY
 _mesa_EndList( void )
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_CURRENT(ctx, 0);      /* must be called before assert */
-   ASSERT_OUTSIDE_BEGIN_END(ctx);
-   if (MESA_VERBOSE&VERBOSE_API)
-      fprintf(stderr, "glEndList\n");
+   SAVE_FLUSH_VERTICES(ctx);
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); /* ??? */
+   if (MESA_VERBOSE&VERBOSE_API)
+      _mesa_debug(ctx, "glEndList\n");
 
    /* Check that a list is under construction */
-   if (!ctx->CurrentListPtr) {
+   if (!ctx->ListState.CurrentListPtr) {
       _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
       return;
    }
@@ -4795,16 +6154,16 @@ _mesa_EndList( void )
    (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
 
    /* Destroy old list, if any */
-   _mesa_destroy_list(ctx, ctx->CurrentListNum);
+   _mesa_destroy_list(ctx, ctx->ListState.CurrentListNum);
    /* Install the list */
-   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
+   _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentListPtr);
 
 
    if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
-      mesa_print_display_list(ctx->CurrentListNum);
+      mesa_print_display_list(ctx->ListState.CurrentListNum);
 
-   ctx->CurrentListNum = 0;
-   ctx->CurrentListPtr = NULL;
+   ctx->ListState.CurrentListNum = 0;
+   ctx->ListState.CurrentListPtr = NULL;
    ctx->ExecuteFlag = GL_TRUE;
    ctx->CompileFlag = GL_FALSE;
 
@@ -4812,12 +6171,11 @@ _mesa_EndList( void )
 
    ctx->CurrentDispatch = ctx->Exec;
    _glapi_set_dispatch( ctx->CurrentDispatch );
-
 }
 
 
 
-void
+void GLAPIENTRY
 _mesa_CallList( GLuint list )
 {
    GLboolean save_compile_flag;
@@ -4826,6 +6184,14 @@ _mesa_CallList( GLuint list )
    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
    /* execute the display list, and restore the CompileFlag. */
 
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glCallList %d\n", list);
+
+   if (list == 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
+      return;
+   }
+
 /*     mesa_print_display_list( list ); */
 
    save_compile_flag = ctx->CompileFlag;
@@ -4848,7 +6214,7 @@ _mesa_CallList( GLuint list )
 /*
  * Execute glCallLists:  call multiple display lists.
  */
-void
+void GLAPIENTRY
 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -4856,6 +6222,27 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
    GLint i;
    GLboolean save_compile_flag;
 
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glCallLists %d\n", n);
+
+   switch (type) {
+      case GL_BYTE:
+      case GL_UNSIGNED_BYTE:
+      case GL_SHORT:
+      case GL_UNSIGNED_SHORT:
+      case GL_INT:
+      case GL_UNSIGNED_INT:
+      case GL_FLOAT:
+      case GL_2_BYTES:
+      case GL_3_BYTES:
+      case GL_4_BYTES:
+         /* OK */
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
+         return;
+   }
+
    /* Save the CompileFlag status, turn it off, execute display list,
     * and restore the CompileFlag.
     */
@@ -4881,7 +6268,7 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
 /*
  * Set the offset added to list numbers in glCallLists.
  */
-void
+void GLAPIENTRY
 _mesa_ListBase( GLuint base )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -4893,182 +6280,182 @@ _mesa_ListBase( GLuint base )
 
 /* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
  */
-static void exec_Finish( void )
+static void GLAPIENTRY exec_Finish( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->Finish();
 }
 
-static void exec_Flush( void )
+static void GLAPIENTRY exec_Flush( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->Flush( );
 }
 
-static void exec_GetBooleanv( GLenum pname, GLboolean *params )
+static void GLAPIENTRY exec_GetBooleanv( GLenum pname, GLboolean *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetBooleanv( pname, params );
 }
 
-static void exec_GetClipPlane( GLenum plane, GLdouble *equation )
+static void GLAPIENTRY exec_GetClipPlane( GLenum plane, GLdouble *equation )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetClipPlane( plane, equation );
 }
 
-static void exec_GetDoublev( GLenum pname, GLdouble *params )
+static void GLAPIENTRY exec_GetDoublev( GLenum pname, GLdouble *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetDoublev(  pname, params );
 }
 
-static GLenum exec_GetError( void )
+static GLenum GLAPIENTRY exec_GetError( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    return ctx->Exec->GetError( );
 }
 
-static void exec_GetFloatv( GLenum pname, GLfloat *params )
+static void GLAPIENTRY exec_GetFloatv( GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetFloatv( pname, params );
 }
 
-static void exec_GetIntegerv( GLenum pname, GLint *params )
+static void GLAPIENTRY exec_GetIntegerv( GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetIntegerv( pname, params );
 }
 
-static void exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
+static void GLAPIENTRY exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetLightfv( light, pname, params );
 }
 
-static void exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
+static void GLAPIENTRY exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetLightiv( light, pname, params );
 }
 
-static void exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
+static void GLAPIENTRY exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetMapdv( target, query, v );
 }
 
-static void exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
+static void GLAPIENTRY exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetMapfv( target, query, v );
 }
 
-static void exec_GetMapiv( GLenum target, GLenum query, GLint *v )
+static void GLAPIENTRY exec_GetMapiv( GLenum target, GLenum query, GLint *v )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetMapiv( target, query, v );
 }
 
-static void exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
+static void GLAPIENTRY exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetMaterialfv( face, pname, params );
 }
 
-static void exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
+static void GLAPIENTRY exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetMaterialiv( face, pname, params );
 }
 
-static void exec_GetPixelMapfv( GLenum map, GLfloat *values )
+static void GLAPIENTRY exec_GetPixelMapfv( GLenum map, GLfloat *values )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPixelMapfv( map,  values );
 }
 
-static void exec_GetPixelMapuiv( GLenum map, GLuint *values )
+static void GLAPIENTRY exec_GetPixelMapuiv( GLenum map, GLuint *values )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPixelMapuiv( map, values );
 }
 
-static void exec_GetPixelMapusv( GLenum map, GLushort *values )
+static void GLAPIENTRY exec_GetPixelMapusv( GLenum map, GLushort *values )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPixelMapusv( map, values );
 }
 
-static void exec_GetPolygonStipple( GLubyte *dest )
+static void GLAPIENTRY exec_GetPolygonStipple( GLubyte *dest )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPolygonStipple( dest );
 }
 
-static const GLubyte *exec_GetString( GLenum name )
+static const GLubyte * GLAPIENTRY exec_GetString( GLenum name )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    return ctx->Exec->GetString( name );
 }
 
-static void exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
+static void GLAPIENTRY exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetTexEnvfv( target, pname, params );
 }
 
-static void exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
+static void GLAPIENTRY exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetTexEnviv( target, pname, params );
 }
 
-static void exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
+static void GLAPIENTRY exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetTexGendv( coord, pname, params );
 }
 
-static void exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
+static void GLAPIENTRY exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetTexGenfv( coord, pname, params );
 }
 
-static void exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
+static void GLAPIENTRY exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetTexGeniv( coord, pname, params );
 }
 
-static void exec_GetTexImage( GLenum target, GLint level, GLenum format,
+static void GLAPIENTRY exec_GetTexImage( GLenum target, GLint level, GLenum format,
                    GLenum type, GLvoid *pixels )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5076,7 +6463,7 @@ static void exec_GetTexImage( GLenum target, GLint level, GLenum format,
    ctx->Exec->GetTexImage( target, level, format, type, pixels );
 }
 
-static void exec_GetTexLevelParameterfv( GLenum target, GLint level,
+static void GLAPIENTRY exec_GetTexLevelParameterfv( GLenum target, GLint level,
                               GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5084,7 +6471,7 @@ static void exec_GetTexLevelParameterfv( GLenum target, GLint level,
    ctx->Exec->GetTexLevelParameterfv( target, level, pname, params );
 }
 
-static void exec_GetTexLevelParameteriv( GLenum target, GLint level,
+static void GLAPIENTRY exec_GetTexLevelParameteriv( GLenum target, GLint level,
                               GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5092,7 +6479,7 @@ static void exec_GetTexLevelParameteriv( GLenum target, GLint level,
    ctx->Exec->GetTexLevelParameteriv( target, level, pname, params );
 }
 
-static void exec_GetTexParameterfv( GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetTexParameterfv( GLenum target, GLenum pname,
                                    GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5100,35 +6487,35 @@ static void exec_GetTexParameterfv( GLenum target, GLenum pname,
    ctx->Exec->GetTexParameterfv( target, pname, params );
 }
 
-static void exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
+static void GLAPIENTRY exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetTexParameteriv( target, pname, params );
 }
 
-static GLboolean exec_IsEnabled( GLenum cap )
+static GLboolean GLAPIENTRY exec_IsEnabled( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    return ctx->Exec->IsEnabled( cap );
 }
 
-static void exec_PixelStoref( GLenum pname, GLfloat param )
+static void GLAPIENTRY exec_PixelStoref( GLenum pname, GLfloat param )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->PixelStoref( pname, param );
 }
 
-static void exec_PixelStorei( GLenum pname, GLint param )
+static void GLAPIENTRY exec_PixelStorei( GLenum pname, GLint param )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->PixelStorei( pname, param );
 }
 
-static void exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
+static void GLAPIENTRY exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
                  GLenum format, GLenum type, GLvoid *pixels )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5136,28 +6523,28 @@ static void exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
    ctx->Exec->ReadPixels( x, y, width, height, format, type, pixels );
 }
 
-static GLint exec_RenderMode( GLenum mode )
+static GLint GLAPIENTRY exec_RenderMode( GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    return ctx->Exec->RenderMode( mode );
 }
 
-static void exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
+static void GLAPIENTRY exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->FeedbackBuffer( size, type, buffer );
 }
 
-static void exec_SelectBuffer( GLsizei size, GLuint *buffer )
+static void GLAPIENTRY exec_SelectBuffer( GLsizei size, GLuint *buffer )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->SelectBuffer( size, buffer );
 }
 
-static GLboolean exec_AreTexturesResident(GLsizei n, const GLuint *texName,
+static GLboolean GLAPIENTRY exec_AreTexturesResident(GLsizei n, const GLuint *texName,
                                          GLboolean *residences)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5165,7 +6552,7 @@ static GLboolean exec_AreTexturesResident(GLsizei n, const GLuint *texName,
    return ctx->Exec->AreTexturesResident( n, texName, residences);
 }
 
-static void exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
                              const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5173,56 +6560,56 @@ static void exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->ColorPointer( size, type, stride, ptr);
 }
 
-static void exec_DeleteTextures( GLsizei n, const GLuint *texName)
+static void GLAPIENTRY exec_DeleteTextures( GLsizei n, const GLuint *texName)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->DeleteTextures( n, texName);
 }
 
-static void exec_DisableClientState( GLenum cap )
+static void GLAPIENTRY exec_DisableClientState( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->DisableClientState( cap );
 }
 
-static void exec_EdgeFlagPointer(GLsizei stride, const void *vptr)
+static void GLAPIENTRY exec_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->EdgeFlagPointer( stride, vptr);
 }
 
-static void exec_EnableClientState( GLenum cap )
+static void GLAPIENTRY exec_EnableClientState( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->EnableClientState( cap );
 }
 
-static void exec_GenTextures( GLsizei n, GLuint *texName )
+static void GLAPIENTRY exec_GenTextures( GLsizei n, GLuint *texName )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GenTextures( n, texName );
 }
 
-static void exec_GetPointerv( GLenum pname, GLvoid **params )
+static void GLAPIENTRY exec_GetPointerv( GLenum pname, GLvoid **params )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPointerv( pname, params );
 }
 
-static void exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
+static void GLAPIENTRY exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->IndexPointer( type, stride, ptr);
 }
 
-static void exec_InterleavedArrays(GLenum format, GLsizei stride,
+static void GLAPIENTRY exec_InterleavedArrays(GLenum format, GLsizei stride,
                                   const GLvoid *pointer)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5230,35 +6617,35 @@ static void exec_InterleavedArrays(GLenum format, GLsizei stride,
    ctx->Exec->InterleavedArrays( format, stride, pointer);
 }
 
-static GLboolean exec_IsTexture( GLuint texture )
+static GLboolean GLAPIENTRY exec_IsTexture( GLuint texture )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    return ctx->Exec->IsTexture( texture );
 }
 
-static void exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
+static void GLAPIENTRY exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->NormalPointer( type, stride, ptr );
 }
 
-static void exec_PopClientAttrib(void)
+static void GLAPIENTRY exec_PopClientAttrib(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->PopClientAttrib();
 }
 
-static void exec_PushClientAttrib(GLbitfield mask)
+static void GLAPIENTRY exec_PushClientAttrib(GLbitfield mask)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->PushClientAttrib( mask);
 }
 
-static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
                                 const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5266,7 +6653,7 @@ static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->TexCoordPointer( size,  type,  stride, ptr);
 }
 
-static void exec_GetCompressedTexImageARB(GLenum target, GLint level,
+static void GLAPIENTRY exec_GetCompressedTexImageARB(GLenum target, GLint level,
                                          GLvoid *img)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5274,7 +6661,7 @@ static void exec_GetCompressedTexImageARB(GLenum target, GLint level,
    ctx->Exec->GetCompressedTexImageARB( target, level, img);
 }
 
-static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
                               const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5282,7 +6669,7 @@ static void exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->VertexPointer( size, type, stride, ptr);
 }
 
-static void exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
+static void GLAPIENTRY exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
                                         GLint x, GLint y, GLsizei width)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5290,7 +6677,7 @@ static void exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
    ctx->Exec->CopyConvolutionFilter1D( target, internalFormat, x, y, width);
 }
 
-static void exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
+static void GLAPIENTRY exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
                                         GLint x, GLint y, GLsizei width,
                                         GLsizei height)
 {
@@ -5300,7 +6687,7 @@ static void exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
                                       height);
 }
 
-static void exec_GetColorTable( GLenum target, GLenum format,
+static void GLAPIENTRY exec_GetColorTable( GLenum target, GLenum format,
                                GLenum type, GLvoid *data )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5308,7 +6695,7 @@ static void exec_GetColorTable( GLenum target, GLenum format,
    ctx->Exec->GetColorTable( target, format, type, data );
 }
 
-static void exec_GetColorTableParameterfv( GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetColorTableParameterfv( GLenum target, GLenum pname,
                                           GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5316,7 +6703,7 @@ static void exec_GetColorTableParameterfv( GLenum target, GLenum pname,
    ctx->Exec->GetColorTableParameterfv( target, pname, params );
 }
 
-static void exec_GetColorTableParameteriv( GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetColorTableParameteriv( GLenum target, GLenum pname,
                                           GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5324,7 +6711,7 @@ static void exec_GetColorTableParameteriv( GLenum target, GLenum pname,
    ctx->Exec->GetColorTableParameteriv( target, pname, params );
 }
 
-static void exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
+static void GLAPIENTRY exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
                                      GLvoid *image)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5332,7 +6719,7 @@ static void exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
    ctx->Exec->GetConvolutionFilter( target, format, type, image);
 }
 
-static void exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
                                           GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5340,7 +6727,7 @@ static void exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
    ctx->Exec->GetConvolutionParameterfv( target, pname, params);
 }
 
-static void exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
                                           GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5348,7 +6735,7 @@ static void exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
    ctx->Exec->GetConvolutionParameteriv( target, pname, params);
 }
 
-static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
+static void GLAPIENTRY exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
                              GLenum type, GLvoid *values)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5356,7 +6743,7 @@ static void exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
    ctx->Exec->GetHistogram( target, reset, format, type, values);
 }
 
-static void exec_GetHistogramParameterfv(GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetHistogramParameterfv(GLenum target, GLenum pname,
                                         GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5364,7 +6751,7 @@ static void exec_GetHistogramParameterfv(GLenum target, GLenum pname,
    ctx->Exec->GetHistogramParameterfv( target, pname, params);
 }
 
-static void exec_GetHistogramParameteriv(GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetHistogramParameteriv(GLenum target, GLenum pname,
                                         GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5372,7 +6759,7 @@ static void exec_GetHistogramParameteriv(GLenum target, GLenum pname,
    ctx->Exec->GetHistogramParameteriv( target, pname, params);
 }
 
-static void exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
+static void GLAPIENTRY exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
                           GLenum type, GLvoid *values)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5380,7 +6767,7 @@ static void exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
    ctx->Exec->GetMinmax( target, reset, format, type, values);
 }
 
-static void exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
                                      GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5388,7 +6775,7 @@ static void exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
    ctx->Exec->GetMinmaxParameterfv( target, pname, params);
 }
 
-static void exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
+static void GLAPIENTRY exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
                                      GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5396,7 +6783,7 @@ static void exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
    ctx->Exec->GetMinmaxParameteriv( target, pname, params);
 }
 
-static void exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
+static void GLAPIENTRY exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
                                    GLvoid *row, GLvoid *column, GLvoid *span)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5404,7 +6791,7 @@ static void exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
    ctx->Exec->GetSeparableFilter( target, format, type, row, column, span);
 }
 
-static void exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
+static void GLAPIENTRY exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
                                   GLsizei width, GLsizei height, GLenum format,
                                   GLenum type, const GLvoid *row,
                                   const GLvoid *column)
@@ -5415,21 +6802,21 @@ static void exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
                                 type, row, column);
 }
 
-static void exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
+static void GLAPIENTRY exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPixelTexGenParameterivSGIS( target, value);
 }
 
-static void exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
+static void GLAPIENTRY exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->GetPixelTexGenParameterfvSGIS( target, value);
 }
 
-static void exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
                                 GLsizei count, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5437,7 +6824,7 @@ static void exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->ColorPointerEXT( size, type, stride, count, ptr);
 }
 
-static void exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
+static void GLAPIENTRY exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
                                    const GLboolean *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5445,7 +6832,7 @@ static void exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
    ctx->Exec->EdgeFlagPointerEXT( stride, count, ptr);
 }
 
-static void exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+static void GLAPIENTRY exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
                       const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5453,7 +6840,7 @@ static void exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
    ctx->Exec->IndexPointerEXT( type, stride, count, ptr);
 }
 
-static void exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+static void GLAPIENTRY exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
                        const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5461,7 +6848,7 @@ static void exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
    ctx->Exec->NormalPointerEXT( type, stride, count, ptr);
 }
 
-static void exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
                                    GLsizei count, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5469,7 +6856,7 @@ static void exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->TexCoordPointerEXT( size, type, stride, count, ptr);
 }
 
-static void exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
                        GLsizei count, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5477,21 +6864,21 @@ static void exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
    ctx->Exec->VertexPointerEXT( size, type, stride, count, ptr);
 }
 
-static void exec_LockArraysEXT(GLint first, GLsizei count)
+static void GLAPIENTRY exec_LockArraysEXT(GLint first, GLsizei count)
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->LockArraysEXT( first, count);
 }
 
-static void exec_UnlockArraysEXT( void )
+static void GLAPIENTRY exec_UnlockArraysEXT( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->UnlockArraysEXT( );
 }
 
-static void exec_ResizeBuffersMESA( void )
+static void GLAPIENTRY exec_ResizeBuffersMESA( void )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
@@ -5499,14 +6886,14 @@ static void exec_ResizeBuffersMESA( void )
 }
 
 
-static void exec_ClientActiveTextureARB( GLenum target )
+static void GLAPIENTRY exec_ClientActiveTextureARB( GLenum target )
 {
    GET_CURRENT_CONTEXT(ctx);
    FLUSH_VERTICES(ctx, 0);
    ctx->Exec->ClientActiveTextureARB(target);
 }
 
-static void exec_SecondaryColorPointerEXT(GLint size, GLenum type,
+static void GLAPIENTRY exec_SecondaryColorPointerEXT(GLint size, GLenum type,
                               GLsizei stride, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5514,7 +6901,7 @@ static void exec_SecondaryColorPointerEXT(GLint size, GLenum type,
    ctx->Exec->SecondaryColorPointerEXT( size, type, stride, ptr);
 }
 
-static void exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
+static void GLAPIENTRY exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
                                    const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5522,9 +6909,53 @@ static void exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
    ctx->Exec->FogCoordPointerEXT( type, stride, ptr);
 }
 
+/* GL_EXT_multi_draw_arrays */
+static void GLAPIENTRY exec_MultiDrawArraysEXT(GLenum mode, GLint *first,
+                                    GLsizei *count, GLsizei primcount)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   ctx->Exec->MultiDrawArraysEXT( mode, first, count, primcount );
+}
 
-/*
- * Assign all the pointers in <table> to point to Mesa's display list
+/* GL_EXT_multi_draw_arrays */
+static void GLAPIENTRY exec_MultiDrawElementsEXT(GLenum mode, const GLsizei *count,
+                                      GLenum type, const GLvoid **indices,
+                                      GLsizei primcount)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   ctx->Exec->MultiDrawElementsEXT(mode, count, type, indices, primcount);
+}
+
+/* GL_IBM_multimode_draw_arrays */
+static void GLAPIENTRY exec_MultiModeDrawArraysIBM(const GLenum *mode, const GLint *first,
+                                       const GLsizei *count, GLsizei primcount,
+                                       GLint modestride)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   ctx->Exec->MultiModeDrawArraysIBM(mode, first, count, primcount, modestride);
+}
+
+/* GL_IBM_multimode_draw_arrays */
+static void GLAPIENTRY exec_MultiModeDrawElementsIBM(const GLenum *mode,
+                                         const GLsizei *count,
+                                         GLenum type,
+                                         const GLvoid * const *indices,
+                                         GLsizei primcount, GLint modestride)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   ctx->Exec->MultiModeDrawElementsIBM(mode, count, type, indices, primcount,
+                                      modestride);
+}
+
+
+
+
+/**
+ * Setup the given dispatch table to point to Mesa's display list
  * building functions.
  *
  * This does not include any of the tnl functions - they are
@@ -5536,13 +6967,12 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
 {
    _mesa_init_no_op_table(table, tableSize);
 
-   _mesa_loopback_init_api_table( table, GL_TRUE );
+   _mesa_loopback_init_api_table( table );
 
    /* GL 1.0 */
    table->Accum = save_Accum;
    table->AlphaFunc = save_AlphaFunc;
    table->Bitmap = save_Bitmap;
-   table->BlendFunc = save_BlendFunc;
    table->CallList = _mesa_save_CallList;
    table->CallLists = _mesa_save_CallLists;
    table->Clear = save_Clear;
@@ -5717,6 +7147,7 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
 
    /* GL 1.1 */
    table->AreTexturesResident = exec_AreTexturesResident;
+   table->AreTexturesResidentEXT = exec_AreTexturesResident;
    table->BindTexture = save_BindTexture;
    table->ColorPointer = exec_ColorPointer;
    table->CopyTexImage1D = save_CopyTexImage1D;
@@ -5728,10 +7159,12 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->EdgeFlagPointer = exec_EdgeFlagPointer;
    table->EnableClientState = exec_EnableClientState;
    table->GenTextures = exec_GenTextures;
+   table->GenTexturesEXT = exec_GenTextures;
    table->GetPointerv = exec_GetPointerv;
    table->IndexPointer = exec_IndexPointer;
    table->InterleavedArrays = exec_InterleavedArrays;
    table->IsTexture = exec_IsTexture;
+   table->IsTextureEXT = exec_IsTexture;
    table->NormalPointer = exec_NormalPointer;
    table->PopClientAttrib = exec_PopClientAttrib;
    table->PrioritizeTextures = save_PrioritizeTextures;
@@ -5765,18 +7198,31 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->CopyConvolutionFilter1D = exec_CopyConvolutionFilter1D;
    table->CopyConvolutionFilter2D = exec_CopyConvolutionFilter2D;
    table->GetColorTable = exec_GetColorTable;
+   table->GetColorTableEXT = exec_GetColorTable;
    table->GetColorTableParameterfv = exec_GetColorTableParameterfv;
+   table->GetColorTableParameterfvEXT = exec_GetColorTableParameterfv;
    table->GetColorTableParameteriv = exec_GetColorTableParameteriv;
+   table->GetColorTableParameterivEXT = exec_GetColorTableParameteriv;
    table->GetConvolutionFilter = exec_GetConvolutionFilter;
+   table->GetConvolutionFilterEXT = exec_GetConvolutionFilter;
    table->GetConvolutionParameterfv = exec_GetConvolutionParameterfv;
+   table->GetConvolutionParameterfvEXT = exec_GetConvolutionParameterfv;
    table->GetConvolutionParameteriv = exec_GetConvolutionParameteriv;
+   table->GetConvolutionParameterivEXT = exec_GetConvolutionParameteriv;
    table->GetHistogram = exec_GetHistogram;
+   table->GetHistogramEXT = exec_GetHistogram;
    table->GetHistogramParameterfv = exec_GetHistogramParameterfv;
+   table->GetHistogramParameterfvEXT = exec_GetHistogramParameterfv;
    table->GetHistogramParameteriv = exec_GetHistogramParameteriv;
+   table->GetHistogramParameterivEXT = exec_GetHistogramParameteriv;
    table->GetMinmax = exec_GetMinmax;
+   table->GetMinmaxEXT = exec_GetMinmax;
    table->GetMinmaxParameterfv = exec_GetMinmaxParameterfv;
+   table->GetMinmaxParameterfvEXT = exec_GetMinmaxParameterfv;
    table->GetMinmaxParameteriv = exec_GetMinmaxParameteriv;
+   table->GetMinmaxParameterivEXT = exec_GetMinmaxParameteriv;
    table->GetSeparableFilter = exec_GetSeparableFilter;
+   table->GetSeparableFilterEXT = exec_GetSeparableFilter;
    table->Histogram = save_Histogram;
    table->Minmax = save_Minmax;
    table->ResetHistogram = save_ResetHistogram;
@@ -5839,14 +7285,23 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->LockArraysEXT = exec_LockArraysEXT;
    table->UnlockArraysEXT = exec_UnlockArraysEXT;
 
-   /* GL_ARB_multitexture */
-   table->ActiveTextureARB = save_ActiveTextureARB;
-   table->ClientActiveTextureARB = exec_ClientActiveTextureARB;
+   /* 145. GL_EXT_secondary_color */
+   table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
+
+   /* 148. GL_EXT_multi_draw_arrays */
+   table->MultiDrawArraysEXT = exec_MultiDrawArraysEXT;
+   table->MultiDrawElementsEXT = exec_MultiDrawElementsEXT;
 
-   /* GL_EXT_blend_func_separate */
+   /* 149. GL_EXT_fog_coord */
+   table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
+
+   /* 173. GL_EXT_blend_func_separate */
    table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
 
-   /* GL_MESA_window_pos */
+   /* 196. GL_MESA_resize_buffers */
+   table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
+
+   /* 197. GL_MESA_window_pos */
    table->WindowPos2dMESA = save_WindowPos2dMESA;
    table->WindowPos2dvMESA = save_WindowPos2dvMESA;
    table->WindowPos2fMESA = save_WindowPos2fMESA;
@@ -5872,16 +7327,80 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->WindowPos4sMESA = save_WindowPos4sMESA;
    table->WindowPos4svMESA = save_WindowPos4svMESA;
 
-   /* GL_MESA_resize_buffers */
-   table->ResizeBuffersMESA = exec_ResizeBuffersMESA;
+   /* 200. GL_IBM_multimode_draw_arrays */
+   table->MultiModeDrawArraysIBM = exec_MultiModeDrawArraysIBM;
+   table->MultiModeDrawElementsIBM = exec_MultiModeDrawElementsIBM;
+
+#if FEATURE_NV_vertex_program
+   /* 233. GL_NV_vertex_program */
+   /* The following commands DO NOT go into display lists:
+    * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
+    * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
+    */
+   table->BindProgramNV = save_BindProgramNV;
+   table->DeleteProgramsNV = _mesa_DeletePrograms;
+   table->ExecuteProgramNV = save_ExecuteProgramNV;
+   table->GenProgramsNV = _mesa_GenPrograms;
+   table->AreProgramsResidentNV = _mesa_AreProgramsResidentNV;
+   table->RequestResidentProgramsNV = save_RequestResidentProgramsNV;
+   table->GetProgramParameterfvNV = _mesa_GetProgramParameterfvNV;
+   table->GetProgramParameterdvNV = _mesa_GetProgramParameterdvNV;
+   table->GetProgramivNV = _mesa_GetProgramivNV;
+   table->GetProgramStringNV = _mesa_GetProgramStringNV;
+   table->GetTrackMatrixivNV = _mesa_GetTrackMatrixivNV;
+   table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
+   table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
+   table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
+   table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
+   table->IsProgramNV = _mesa_IsProgram;
+   table->LoadProgramNV = save_LoadProgramNV;
+   table->ProgramParameter4dNV = save_ProgramParameter4dNV;
+   table->ProgramParameter4dvNV = save_ProgramParameter4dvNV;
+   table->ProgramParameter4fNV = save_ProgramParameter4fNV;
+   table->ProgramParameter4fvNV = save_ProgramParameter4fvNV;
+   table->ProgramParameters4dvNV = save_ProgramParameters4dvNV;
+   table->ProgramParameters4fvNV = save_ProgramParameters4fvNV;
+   table->TrackMatrixNV = save_TrackMatrixNV;
+   table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
+#endif
 
-   /* GL_ARB_transpose_matrix */
+   /* 282. GL_NV_fragment_program */
+#if FEATURE_NV_fragment_program
+   table->ProgramNamedParameter4fNV = save_ProgramNamedParameter4fNV;
+   table->ProgramNamedParameter4dNV = save_ProgramNamedParameter4dNV;
+   table->ProgramNamedParameter4fvNV = save_ProgramNamedParameter4fvNV;
+   table->ProgramNamedParameter4dvNV = save_ProgramNamedParameter4dvNV;
+   table->GetProgramNamedParameterfvNV = _mesa_GetProgramNamedParameterfvNV;
+   table->GetProgramNamedParameterdvNV = _mesa_GetProgramNamedParameterdvNV;
+   table->ProgramLocalParameter4dARB = save_ProgramLocalParameter4dARB;
+   table->ProgramLocalParameter4dvARB = save_ProgramLocalParameter4dvARB;
+   table->ProgramLocalParameter4fARB = save_ProgramLocalParameter4fARB;
+   table->ProgramLocalParameter4fvARB = save_ProgramLocalParameter4fvARB;
+   table->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
+   table->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
+#endif
+
+   /* 262. GL_NV_point_sprite */
+   table->PointParameteriNV = save_PointParameteriNV;
+   table->PointParameterivNV = save_PointParameterivNV;
+
+   /* 268. GL_EXT_stencil_two_side */
+   table->ActiveStencilFaceEXT = save_ActiveStencilFaceEXT;
+
+   /* ???. GL_EXT_depth_bounds_test */
+   table->DepthBoundsEXT = save_DepthBoundsEXT;
+
+   /* ARB 1. GL_ARB_multitexture */
+   table->ActiveTextureARB = save_ActiveTextureARB;
+   table->ClientActiveTextureARB = exec_ClientActiveTextureARB;
+
+   /* ARB 3. GL_ARB_transpose_matrix */
    table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
    table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
    table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
    table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
 
-   /* GL_ARB_multisample */
+   /* ARB 5. GL_ARB_multisample */
    table->SampleCoverageARB = save_SampleCoverageARB;
 
    /* ARB 12. GL_ARB_texture_compression */
@@ -5893,11 +7412,59 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB;
    table->GetCompressedTexImageARB = exec_GetCompressedTexImageARB;
 
-   /* GL_EXT_secondary_color */
-   table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
+   /* ARB 14. GL_ARB_point_parameters */
+   /* aliased with EXT_point_parameters functions */
+
+   /* ARB 25. GL_ARB_window_pos */
+   /* aliased with MESA_window_pos functions */
+
+   /* ARB 26. GL_ARB_vertex_program */
+   /* ARB 27. GL_ARB_fragment_program */
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+   /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
+   table->VertexAttribPointerARB = _mesa_VertexAttribPointerARB;
+   table->EnableVertexAttribArrayARB = _mesa_EnableVertexAttribArrayARB;
+   table->DisableVertexAttribArrayARB = _mesa_DisableVertexAttribArrayARB;
+   table->ProgramStringARB = save_ProgramStringARB;
+   table->BindProgramNV = _mesa_BindProgram;
+   table->DeleteProgramsNV = _mesa_DeletePrograms;
+   table->GenProgramsNV = _mesa_GenPrograms;
+   table->IsProgramNV = _mesa_IsProgram;
+   table->GetVertexAttribdvNV = _mesa_GetVertexAttribdvNV;
+   table->GetVertexAttribfvNV = _mesa_GetVertexAttribfvNV;
+   table->GetVertexAttribivNV = _mesa_GetVertexAttribivNV;
+   table->GetVertexAttribPointervNV = _mesa_GetVertexAttribPointervNV;
+   table->ProgramEnvParameter4dARB = save_ProgramEnvParameter4dARB;
+   table->ProgramEnvParameter4dvARB = save_ProgramEnvParameter4dvARB;
+   table->ProgramEnvParameter4fARB = save_ProgramEnvParameter4fARB;
+   table->ProgramEnvParameter4fvARB = save_ProgramEnvParameter4fvARB;
+   table->ProgramLocalParameter4dARB = save_ProgramLocalParameter4dARB;
+   table->ProgramLocalParameter4dvARB = save_ProgramLocalParameter4dvARB;
+   table->ProgramLocalParameter4fARB = save_ProgramLocalParameter4fARB;
+   table->ProgramLocalParameter4fvARB = save_ProgramLocalParameter4fvARB;
+   table->GetProgramEnvParameterdvARB = _mesa_GetProgramEnvParameterdvARB;
+   table->GetProgramEnvParameterfvARB = _mesa_GetProgramEnvParameterfvARB;
+   table->GetProgramLocalParameterdvARB = _mesa_GetProgramLocalParameterdvARB;
+   table->GetProgramLocalParameterfvARB = _mesa_GetProgramLocalParameterfvARB;
+   table->GetProgramivARB = _mesa_GetProgramivARB;
+   table->GetProgramStringARB = _mesa_GetProgramStringARB;
+#endif
 
-   /* GL_EXT_fog_coord */
-   table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
+   /* ARB 28. GL_ARB_vertex_buffer_object */
+#if FEATURE_ARB_vertex_buffer_object
+   /* None of the extension's functions get compiled */
+   table->BindBufferARB = _mesa_BindBufferARB;
+   table->BufferDataARB = _mesa_BufferDataARB;
+   table->BufferSubDataARB = _mesa_BufferSubDataARB;
+   table->DeleteBuffersARB = _mesa_DeleteBuffersARB;
+   table->GenBuffersARB = _mesa_GenBuffersARB;
+   table->GetBufferParameterivARB = _mesa_GetBufferParameterivARB;
+   table->GetBufferPointervARB = _mesa_GetBufferPointervARB;
+   table->GetBufferSubDataARB = _mesa_GetBufferSubDataARB;
+   table->IsBufferARB = _mesa_IsBufferARB;
+   table->MapBufferARB = _mesa_MapBufferARB;
+   table->UnmapBufferARB = _mesa_UnmapBufferARB;
+#endif
 }
 
 
@@ -5915,19 +7482,19 @@ static const char *enum_string( GLenum k )
  * Print the commands in a display list.  For debugging only.
  * TODO: many commands aren't handled yet.
  */
-static void print_list( GLcontext *ctx, FILE *f, GLuint list )
+static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
 {
    Node *n;
    GLboolean done;
 
    if (!glIsList(list)) {
-      fprintf(f,"%u is not a display list ID\n",list);
+      _mesa_printf("%u is not a display list ID\n", list);
       return;
    }
 
    n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
 
-   fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
+   _mesa_printf("START-LIST %u, address %p\n", list, (void*)n );
 
    done = n ? GL_FALSE : GL_TRUE;
    while (!done) {
@@ -5941,149 +7508,162 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
       else {
         switch (opcode) {
          case OPCODE_ACCUM:
-            fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
+            _mesa_printf("accum %s %g\n", enum_string(n[1].e), n[2].f );
            break;
         case OPCODE_BITMAP:
-            fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
+            _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
                       n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
            break;
          case OPCODE_CALL_LIST:
-            fprintf(f,"CallList %d\n", (int) n[1].ui );
+            _mesa_printf("CallList %d\n", (int) n[1].ui );
             break;
          case OPCODE_CALL_LIST_OFFSET:
-            fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
+            _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui,
                     ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
             break;
          case OPCODE_COLOR_TABLE_PARAMETER_FV:
-            fprintf(f,"ColorTableParameterfv %s %s %f %f %f %f\n",
+            _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n",
                     enum_string(n[1].e), enum_string(n[2].e),
                     n[3].f, n[4].f, n[5].f, n[6].f);
             break;
          case OPCODE_COLOR_TABLE_PARAMETER_IV:
-            fprintf(f,"ColorTableParameteriv %s %s %d %d %d %d\n",
+            _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n",
                     enum_string(n[1].e), enum_string(n[2].e),
                     n[3].i, n[4].i, n[5].i, n[6].i);
             break;
         case OPCODE_DISABLE:
-            fprintf(f,"Disable %s\n", enum_string(n[1].e));
+            _mesa_printf("Disable %s\n", enum_string(n[1].e));
            break;
         case OPCODE_ENABLE:
-            fprintf(f,"Enable %s\n", enum_string(n[1].e));
+            _mesa_printf("Enable %s\n", enum_string(n[1].e));
            break;
          case OPCODE_FRUSTUM:
-            fprintf(f,"Frustum %g %g %g %g %g %g\n",
+            _mesa_printf("Frustum %g %g %g %g %g %g\n",
                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
             break;
         case OPCODE_LINE_STIPPLE:
-           fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
+           _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us );
            break;
         case OPCODE_LOAD_IDENTITY:
-            fprintf(f,"LoadIdentity\n");
+            _mesa_printf("LoadIdentity\n");
            break;
         case OPCODE_LOAD_MATRIX:
-            fprintf(f,"LoadMatrix\n");
-            fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
-            fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
-            fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
-            fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
+            _mesa_printf("LoadMatrix\n");
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[1].f, n[5].f,  n[9].f, n[13].f);
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[2].f, n[6].f, n[10].f, n[14].f);
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[3].f, n[7].f, n[11].f, n[15].f);
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[4].f, n[8].f, n[12].f, n[16].f);
            break;
         case OPCODE_MULT_MATRIX:
-            fprintf(f,"MultMatrix (or Rotate)\n");
-            fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
-            fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
-            fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
-            fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
+            _mesa_printf("MultMatrix (or Rotate)\n");
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[1].f, n[5].f,  n[9].f, n[13].f);
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[2].f, n[6].f, n[10].f, n[14].f);
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[3].f, n[7].f, n[11].f, n[15].f);
+            _mesa_printf("  %8f %8f %8f %8f\n",
+                         n[4].f, n[8].f, n[12].f, n[16].f);
            break;
          case OPCODE_ORTHO:
-            fprintf(f,"Ortho %g %g %g %g %g %g\n",
+            _mesa_printf("Ortho %g %g %g %g %g %g\n",
                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
             break;
         case OPCODE_POP_ATTRIB:
-            fprintf(f,"PopAttrib\n");
+            _mesa_printf("PopAttrib\n");
            break;
         case OPCODE_POP_MATRIX:
-            fprintf(f,"PopMatrix\n");
+            _mesa_printf("PopMatrix\n");
            break;
         case OPCODE_POP_NAME:
-            fprintf(f,"PopName\n");
+            _mesa_printf("PopName\n");
            break;
         case OPCODE_PUSH_ATTRIB:
-            fprintf(f,"PushAttrib %x\n", n[1].bf );
+            _mesa_printf("PushAttrib %x\n", n[1].bf );
            break;
         case OPCODE_PUSH_MATRIX:
-            fprintf(f,"PushMatrix\n");
+            _mesa_printf("PushMatrix\n");
            break;
         case OPCODE_PUSH_NAME:
-            fprintf(f,"PushName %d\n", (int) n[1].ui );
+            _mesa_printf("PushName %d\n", (int) n[1].ui );
            break;
         case OPCODE_RASTER_POS:
-            fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
+            _mesa_printf("RasterPos %g %g %g %g\n",
+                         n[1].f, n[2].f,n[3].f,n[4].f);
            break;
          case OPCODE_ROTATE:
-            fprintf(f,"Rotate %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
+            _mesa_printf("Rotate %g %g %g %g\n",
+                         n[1].f, n[2].f, n[3].f, n[4].f );
             break;
          case OPCODE_SCALE:
-            fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
+            _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
             break;
          case OPCODE_TRANSLATE:
-            fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
+            _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
             break;
          case OPCODE_BIND_TEXTURE:
-           fprintf(f,"BindTexture %s %d\n", _mesa_lookup_enum_by_nr(n[1].ui),
-                   n[2].ui);
+           _mesa_printf("BindTexture %s %d\n",
+                         _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
            break;
          case OPCODE_SHADE_MODEL:
-           fprintf(f,"ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui));
+           _mesa_printf("ShadeModel %s\n",
+                         _mesa_lookup_enum_by_nr(n[1].ui));
            break;
         case OPCODE_MAP1:
-           fprintf(f,"Map1 %s %.3f %.3f %d %d\n", 
+           _mesa_printf("Map1 %s %.3f %.3f %d %d\n",
                    _mesa_lookup_enum_by_nr(n[1].ui),
                    n[2].f, n[3].f, n[4].i, n[5].i);
            break;
         case OPCODE_MAP2:
-           fprintf(f,"Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", 
-                   _mesa_lookup_enum_by_nr(n[1].ui),
-                   n[2].f, n[3].f, n[4].f, n[5].f,
-                   n[6].i, n[7].i, n[8].i, n[9].i);
+           _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
+                         _mesa_lookup_enum_by_nr(n[1].ui),
+                         n[2].f, n[3].f, n[4].f, n[5].f,
+                         n[6].i, n[7].i, n[8].i, n[9].i);
            break;
         case OPCODE_MAPGRID1:
-           fprintf(f,"MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f);
+           _mesa_printf("MapGrid1 %d %.3f %.3f\n",
+                         n[1].i, n[2].f, n[3].f);
            break;
         case OPCODE_MAPGRID2:
-           fprintf(f,"MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", 
-                   n[1].i, n[2].f, n[3].f,
-                   n[4].i, n[5].f, n[6].f);
+           _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
+                         n[1].i, n[2].f, n[3].f,
+                         n[4].i, n[5].f, n[6].f);
            break;
         case OPCODE_EVALMESH1:
-           fprintf(f,"EvalMesh1 %d %d\n", n[1].i, n[2].i);
+           _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
            break;
         case OPCODE_EVALMESH2:
-           fprintf(f,"EvalMesh2 %d %d %d %d\n",
-                   n[1].i, n[2].i, n[3].i, n[4].i);
+           _mesa_printf("EvalMesh2 %d %d %d %d\n",
+                         n[1].i, n[2].i, n[3].i, n[4].i);
            break;
 
         /*
          * meta opcodes/commands
          */
          case OPCODE_ERROR:
-            fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
+            _mesa_printf("Error: %s %s\n",
+                         enum_string(n[1].e), (const char *)n[2].data );
             break;
         case OPCODE_CONTINUE:
-            fprintf(f,"DISPLAY-LIST-CONTINUE\n");
+            _mesa_printf("DISPLAY-LIST-CONTINUE\n");
            n = (Node *) n[1].next;
            break;
         case OPCODE_END_OF_LIST:
-            fprintf(f,"END-LIST %u\n", list);
+            _mesa_printf("END-LIST %u\n", list);
            done = GL_TRUE;
            break;
          default:
             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
-               fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
-                       opcode, (void*) n);
+               _mesa_printf("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
+                            opcode, (void*) n);
                return;
             }
             else {
-               fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
+               _mesa_printf("command %d, %u operands\n", opcode, InstSize[opcode]);
             }
         }
         /* increment n to point to next compiled command */
@@ -6104,5 +7684,106 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
 void mesa_print_display_list( GLuint list )
 {
    GET_CURRENT_CONTEXT(ctx);
-   print_list( ctx, stderr, list );
+   print_list( ctx, list );
+}
+
+
+/**********************************************************************/
+/*****                      Initialization                        *****/
+/**********************************************************************/
+
+
+void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
+{
+   vfmt->ArrayElement = _ae_loopback_array_elt;                /* generic helper */
+   vfmt->Begin = save_Begin;
+   vfmt->CallList = _mesa_save_CallList;
+   vfmt->CallLists = _mesa_save_CallLists;
+   vfmt->Color3f = save_Color3f;
+   vfmt->Color3fv = save_Color3fv;
+   vfmt->Color4f = save_Color4f;
+   vfmt->Color4fv = save_Color4fv;
+   vfmt->EdgeFlag = save_EdgeFlag;
+   vfmt->EdgeFlagv = save_EdgeFlagv;
+   vfmt->End = save_End;
+   vfmt->EvalCoord1f = save_EvalCoord1f;
+   vfmt->EvalCoord1fv = save_EvalCoord1fv;
+   vfmt->EvalCoord2f = save_EvalCoord2f;
+   vfmt->EvalCoord2fv = save_EvalCoord2fv;
+   vfmt->EvalPoint1 = save_EvalPoint1;
+   vfmt->EvalPoint2 = save_EvalPoint2;
+   vfmt->FogCoordfEXT = save_FogCoordfEXT;
+   vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
+   vfmt->Indexf = save_Indexf;
+   vfmt->Indexfv = save_Indexfv;
+   vfmt->Materialfv = save_Materialfv;
+   vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
+   vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
+   vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
+   vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
+   vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
+   vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
+   vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
+   vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
+   vfmt->Normal3f = save_Normal3f;
+   vfmt->Normal3fv = save_Normal3fv;
+   vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
+   vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
+   vfmt->TexCoord1f = save_TexCoord1f;
+   vfmt->TexCoord1fv = save_TexCoord1fv;
+   vfmt->TexCoord2f = save_TexCoord2f;
+   vfmt->TexCoord2fv = save_TexCoord2fv;
+   vfmt->TexCoord3f = save_TexCoord3f;
+   vfmt->TexCoord3fv = save_TexCoord3fv;
+   vfmt->TexCoord4f = save_TexCoord4f;
+   vfmt->TexCoord4fv = save_TexCoord4fv;
+   vfmt->Vertex2f = save_Vertex2f;
+   vfmt->Vertex2fv = save_Vertex2fv;
+   vfmt->Vertex3f = save_Vertex3f;
+   vfmt->Vertex3fv = save_Vertex3fv;
+   vfmt->Vertex4f = save_Vertex4f;
+   vfmt->Vertex4fv = save_Vertex4fv;
+   vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
+   vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
+   vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
+   vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
+   vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
+   vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
+   vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
+   vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
+
+   vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
+   vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
+   vfmt->Rectf = save_Rectf;
+
+   /* The driver is required to implement these as
+    * 1) They can probably do a better job.
+    * 2) A lot of new mechanisms would have to be added to this module
+    *     to support it.  That code would probably never get used,
+    *     because of (1).
+    */
+#if 0
+   vfmt->DrawArrays = 0;
+   vfmt->DrawElements = 0;
+   vfmt->DrawRangeElements = 0;
+#endif
+}
+
+
+
+void _mesa_init_display_list( GLcontext * ctx )
+{
+   /* Display list */
+   ctx->ListState.CallDepth = 0;
+   ctx->ExecuteFlag = GL_TRUE;
+   ctx->CompileFlag = GL_FALSE;
+   ctx->ListState.CurrentListPtr = NULL;
+   ctx->ListState.CurrentBlock = NULL;
+   ctx->ListState.CurrentListNum = 0;
+   ctx->ListState.CurrentPos = 0;
+
+   /* Display List group */
+   ctx->List.ListBase = 0;
+
+   _mesa_save_vtxfmt_init( &ctx->ListState.ListVtxfmt );
 }