fixed pointer arithmetic error in glCopyPixels
[mesa.git] / src / mesa / main / dlist.c
index c7848dfc75042ca35179c5e09a8da3426017e8cd..56cf706fad6090088caf879705ad29f000de0cb6 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: dlist.c,v 1.60 2000/12/27 23:01:25 keithw Exp $ */
+/* $Id: dlist.c,v 1.84 2001/12/19 02:36:05 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.3
+ * Version:  4.1
  *
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2001  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"),
 #include "all.h"
 #else
 #include "glheader.h"
-#include "accum.h"
 #include "api_loopback.h"
 #include "attrib.h"
-#include "bitmap.h"
 #include "blend.h"
 #include "buffers.h"
 #include "clip.h"
@@ -40,7 +38,6 @@
 #include "colortab.h"
 #include "context.h"
 #include "convolve.h"
-#include "copypix.h"
 #include "depth.h"
 #include "dlist.h"
 #include "enable.h"
 #include "matrix.h"
 #include "mem.h"
 #include "pixel.h"
-#include "pixeltex.h"
 #include "points.h"
 #include "polygon.h"
-#include "readpix.h"
 #include "state.h"
 #include "texobj.h"
 #include "teximage.h"
 #include "texstate.h"
 #include "mtypes.h"
 #include "varray.h"
+#include "vpstate.h"
 
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
@@ -110,7 +106,7 @@ Functions which cause errors if called while compiling a display list:
 /* How many nodes to allocate at a time:
  * - reduced now that we hold vertices etc. elsewhere.
  */
-#define BLOCK_SIZE 64
+#define BLOCK_SIZE 256
 
 
 /*
@@ -166,17 +162,12 @@ typedef enum {
        OPCODE_DRAW_BUFFER,
        OPCODE_DRAW_PIXELS,
        OPCODE_ENABLE,
-       OPCODE_EVALCOORD1,
-       OPCODE_EVALCOORD2,
        OPCODE_EVALMESH1,
        OPCODE_EVALMESH2,
-       OPCODE_EVALPOINT1,
-       OPCODE_EVALPOINT2,
        OPCODE_FOG,
        OPCODE_FRONT_FACE,
        OPCODE_FRUSTUM,
        OPCODE_HINT,
-       OPCODE_HINT_PGI,
        OPCODE_HISTOGRAM,
        OPCODE_INDEX_MASK,
        OPCODE_INIT_NAMES,
@@ -240,7 +231,6 @@ typedef enum {
        OPCODE_WINDOW_POS,
         /* GL_ARB_multitexture */
         OPCODE_ACTIVE_TEXTURE,
-        OPCODE_CLIENT_ACTIVE_TEXTURE,
         /* GL_SGIX/SGIS_pixel_texture */
         OPCODE_PIXEL_TEXGEN_SGIX,
         OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS,
@@ -251,6 +241,18 @@ typedef enum {
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
         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_PROGRAMS_RESIDENT_NV,
+        OPCODE_LOAD_PROGRAM_NV,
+        OPCODE_PROGRAM_PARAMETER4F_NV,
+        OPCODE_PROGRAM_PARAMETERS4FV_NV,
+        OPCODE_TRACK_MATRIX_NV,
        /* The following three are meta instructions */
        OPCODE_ERROR,           /* raise compiled-in error */
        OPCODE_CONTINUE,
@@ -314,7 +316,7 @@ static Node *make_empty_list( void )
  * Destroy all nodes in a display list.
  * Input:  list - display list number
  */
-void gl_destroy_list( GLcontext *ctx, GLuint list )
+void _mesa_destroy_list( GLcontext *ctx, GLuint list )
 {
    Node *n, *block;
    GLboolean done;
@@ -330,8 +332,8 @@ void gl_destroy_list( GLcontext *ctx, GLuint list )
 
       /* check for extension opcodes first */
 
-      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
-      if (i >= 0 && i < ctx->listext.nr_opcodes) {
+      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
+      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
         ctx->listext.opcode[i].destroy(ctx, &n[1]);
         n += ctx->listext.opcode[i].size;
       }
@@ -504,7 +506,7 @@ static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
 /*****                        Public                              *****/
 /**********************************************************************/
 
-void gl_init_lists( void )
+void _mesa_init_lists( void )
 {
    static int init_flag = 0;
 
@@ -554,17 +556,12 @@ void gl_init_lists( void )
       InstSize[OPCODE_DRAW_BUFFER] = 2;
       InstSize[OPCODE_DRAW_PIXELS] = 6;
       InstSize[OPCODE_ENABLE] = 2;
-      InstSize[OPCODE_EVALCOORD1] = 2;
-      InstSize[OPCODE_EVALCOORD2] = 3;
       InstSize[OPCODE_EVALMESH1] = 4;
       InstSize[OPCODE_EVALMESH2] = 6;
-      InstSize[OPCODE_EVALPOINT1] = 2;
-      InstSize[OPCODE_EVALPOINT2] = 3;
       InstSize[OPCODE_FOG] = 6;
       InstSize[OPCODE_FRONT_FACE] = 2;
       InstSize[OPCODE_FRUSTUM] = 7;
       InstSize[OPCODE_HINT] = 3;
-      InstSize[OPCODE_HINT_PGI] = 3;
       InstSize[OPCODE_HISTOGRAM] = 5;
       InstSize[OPCODE_INDEX_MASK] = 2;
       InstSize[OPCODE_INIT_NAMES] = 1;
@@ -637,9 +634,20 @@ void gl_init_lists( void )
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
+      /* GL_ARB_multisample */
+      InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
       /* GL_ARB_multitexture */
       InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
-      InstSize[OPCODE_CLIENT_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_PROGRAMS_RESIDENT_NV] = 2;
+      InstSize[OPCODE_LOAD_PROGRAM_NV] = 4;
+      InstSize[OPCODE_PROGRAM_PARAMETER4F_NV] = 7;
+      InstSize[OPCODE_PROGRAM_PARAMETERS4FV_NV] = 4;
+      InstSize[OPCODE_TRACK_MATRIX_NV] = 5;
    }
    init_flag = 1;
 }
@@ -660,7 +668,7 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
 
 #ifdef DEBUG
    if (opcode < (int) OPCODE_DRV_0) {
-      assert( (GLint) count == InstSize[opcode] );
+      assert( count == InstSize[opcode] );
    }
 #endif
 
@@ -670,7 +678,7 @@ _mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
       n[0].opcode = OPCODE_CONTINUE;
       newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
       if (!newblock) {
-         gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
+         _mesa_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
          return NULL;
       }
       n[1].next = (Node *) newblock;
@@ -726,7 +734,7 @@ static void save_Accum( GLenum op, GLfloat value )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
-   FLUSH_VERTICES(ctx, 0);
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
    if (n) {
       n[1].e = op;
@@ -869,11 +877,13 @@ static void save_BlendColor( GLfloat red, GLfloat green,
 }
 
 
-static void save_CallList( GLuint list )
+void _mesa_save_CallList( GLuint list )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_CURRENT(ctx, 0);
+
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
    if (n) {
       n[1].ui = list;
@@ -884,11 +894,12 @@ static void save_CallList( GLuint list )
 }
 
 
-static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
+void _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);
 
    for (i=0;i<n;i++) {
       GLuint list = translate_id( i, type, lists );
@@ -1009,10 +1020,10 @@ static void save_ClipPlane( GLenum plane, const GLdouble *equ )
    n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
    if (n) {
       n[1].e = plane;
-      n[2].f = equ[0];
-      n[3].f = equ[1];
-      n[4].f = equ[2];
-      n[5].f = equ[3];
+      n[2].f = (GLfloat) equ[0];
+      n[3].f = (GLfloat) equ[1];
+      n[4].f = (GLfloat) equ[2];
+      n[5].f = (GLfloat) equ[3];
    }
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->ClipPlane)( plane, equ );
@@ -1045,6 +1056,8 @@ static void 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) {
       n[1].e = face;
@@ -1063,7 +1076,8 @@ static void save_ColorTable( GLenum target, GLenum internalFormat,
    GET_CURRENT_CONTEXT(ctx);
    if (target == GL_PROXY_TEXTURE_1D ||
        target == GL_PROXY_TEXTURE_2D ||
-       target == GL_PROXY_TEXTURE_3D) {
+       target == GL_PROXY_TEXTURE_3D ||
+       target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
       /* execute immediately */
       (*ctx->Exec->ColorTable)( target, internalFormat, width,
                                 format, type, table );
@@ -1186,7 +1200,7 @@ save_CopyColorSubTable(GLenum target, GLsizei start,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5 );
    if (n) {
       n[1].e = target;
       n[2].i = start;
@@ -1208,7 +1222,7 @@ save_CopyColorTable(GLenum target, GLenum internalformat,
    Node *n;
 
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 6 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 5 );
    if (n) {
       n[1].e = target;
       n[2].e = internalformat;
@@ -1350,7 +1364,7 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6 );
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -1372,8 +1386,9 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 }
 
 
-static void save_CopyPixels( GLint x, GLint y,
-                             GLsizei width, GLsizei height, GLenum type )
+static void 
+save_CopyPixels( GLint x, GLint y,
+                GLsizei width, GLsizei height, GLenum type )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -1776,12 +1791,12 @@ static void save_Frustum( GLdouble left, GLdouble right,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
    if (n) {
-      n[1].f = left;
-      n[2].f = right;
-      n[3].f = bottom;
-      n[4].f = top;
-      n[5].f = nearval;
-      n[6].f = farval;
+      n[1].f = (GLfloat) left;
+      n[2].f = (GLfloat) right;
+      n[3].f = (GLfloat) bottom;
+      n[4].f = (GLfloat) top;
+      n[5].f = (GLfloat) nearval;
+      n[6].f = (GLfloat) farval;
    }
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
@@ -1805,23 +1820,6 @@ static void save_Hint( GLenum target, GLenum mode )
 }
 
 
-/* GL_PGI_misc_hints*/
-static void save_HintPGI( GLenum target, GLint mode )
-{
-   GET_CURRENT_CONTEXT(ctx);
-   Node *n;
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT_PGI, 2 );
-   if (n) {
-      n[1].e = target;
-      n[2].i = mode;
-   }
-   if (ctx->ExecuteFlag) {
-      (*ctx->Exec->HintPGI)( target, mode );
-   }
-}
-
-
 static void
 save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
 {
@@ -2106,7 +2104,7 @@ static void save_LoadMatrixd( const GLdouble *m )
    GLfloat f[16];
    GLint i;
    for (i = 0; i < 16; i++) {
-      f[i] = m[i];
+      f[i] = (GLfloat) m[i];
    }
    save_LoadMatrixf(f);
 }
@@ -2150,10 +2148,10 @@ static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points );
+      GLfloat *pnts = _mesa_copy_map_points1d( target, stride, order, points );
       n[1].e = target;
-      n[2].f = u1;
-      n[3].f = u2;
+      n[2].f = (GLfloat) u1;
+      n[3].f = (GLfloat) u2;
       n[4].i = _mesa_evaluator_components(target);  /* stride */
       n[5].i = order;
       n[6].data = (void *) pnts;
@@ -2171,7 +2169,7 @@ static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
+      GLfloat *pnts = _mesa_copy_map_points1f( target, stride, order, points );
       n[1].e = target;
       n[2].f = u1;
       n[3].f = u2;
@@ -2195,13 +2193,13 @@ static void save_Map2d( GLenum target,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder,
+      GLfloat *pnts = _mesa_copy_map_points2d( target, ustride, uorder,
                                             vstride, vorder, points );
       n[1].e = target;
-      n[2].f = u1;
-      n[3].f = u2;
-      n[4].f = v1;
-      n[5].f = v2;
+      n[2].f = (GLfloat) u1;
+      n[3].f = (GLfloat) u2;
+      n[4].f = (GLfloat) v1;
+      n[5].f = (GLfloat) v2;
       /* XXX verify these strides are correct */
       n[6].i = _mesa_evaluator_components(target) * vorder;  /*ustride*/
       n[7].i = _mesa_evaluator_components(target);           /*vstride*/
@@ -2227,7 +2225,7 @@ static void save_Map2f( GLenum target,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
    if (n) {
-      GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
+      GLfloat *pnts = _mesa_copy_map_points2f( target, ustride, uorder,
                                             vstride, vorder, points );
       n[1].e = target;
       n[2].f = u1;
@@ -2267,7 +2265,7 @@ static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
 
 static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
 {
-   save_MapGrid1f(un, u1, u2);
+   save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
 }
 
 
@@ -2296,7 +2294,8 @@ static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
 static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
                             GLint vn, GLdouble v1, GLdouble v2 )
 {
-   save_MapGrid2f(un, u1, u2, vn, v1, v2);
+   save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, 
+                 vn, (GLfloat) v1, (GLfloat) v2);
 }
 
 
@@ -2357,7 +2356,7 @@ static void save_MultMatrixd( const GLdouble *m )
    GLfloat f[16];
    GLint i;
    for (i = 0; i < 16; i++) {
-      f[i] = m[i];
+      f[i] = (GLfloat) m[i];
    }
    save_MultMatrixf(f);
 }
@@ -2367,7 +2366,7 @@ static void save_NewList( GLuint list, GLenum mode )
 {
    GET_CURRENT_CONTEXT(ctx);
    /* It's an error to call this function while building a display list */
-   gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
+   _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
    (void) list;
    (void) mode;
 }
@@ -2383,12 +2382,12 @@ static void save_Ortho( GLdouble left, GLdouble right,
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
    n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
    if (n) {
-      n[1].f = left;
-      n[2].f = right;
-      n[3].f = bottom;
-      n[4].f = top;
-      n[5].f = nearval;
-      n[6].f = farval;
+      n[1].f = (GLfloat) left;
+      n[2].f = (GLfloat) right;
+      n[3].f = (GLfloat) bottom;
+      n[4].f = (GLfloat) top;
+      n[5].f = (GLfloat) nearval;
+      n[6].f = (GLfloat) farval;
    }
    if (ctx->ExecuteFlag) {
       (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
@@ -2396,7 +2395,8 @@ static void save_Ortho( GLdouble left, GLdouble right,
 }
 
 
-static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
+static void
+save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2414,7 +2414,8 @@ static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
 }
 
 
-static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
+static void
+save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
 {
    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
    GLint i;
@@ -2432,7 +2433,8 @@ static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
 }
 
 
-static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
+static void
+save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
 {
    GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
    GLint i;
@@ -2450,7 +2452,8 @@ static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
 }
 
 
-static void save_PixelTransferf( GLenum pname, GLfloat param )
+static void
+save_PixelTransferf( GLenum pname, GLfloat param )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2466,13 +2469,15 @@ static void save_PixelTransferf( GLenum pname, GLfloat param )
 }
 
 
-static void save_PixelTransferi( GLenum pname, GLint param )
+static void
+save_PixelTransferi( GLenum pname, GLint param )
 {
    save_PixelTransferf( pname, (GLfloat) param );
 }
 
 
-static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
+static void
+save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2488,7 +2493,8 @@ static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
 }
 
 
-static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
+static void
+save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -2583,7 +2589,7 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units )
 static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
 {
    GET_CURRENT_CONTEXT(ctx);
-   save_PolygonOffset(factor, ctx->Visual.DepthMaxF * bias);
+   save_PolygonOffset(factor, ctx->DepthMaxF * bias);
 }
 
 
@@ -2602,6 +2608,7 @@ static void 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)();
@@ -2646,6 +2653,7 @@ static void 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;
@@ -2687,6 +2695,7 @@ static void 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;
@@ -2701,7 +2710,7 @@ static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 
 static void save_RasterPos2d(GLdouble x, GLdouble y)
 {
-   save_RasterPos4f(x, y, 0.0F, 1.0F);
+   save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
 static void save_RasterPos2f(GLfloat x, GLfloat y)
@@ -2711,7 +2720,7 @@ static void save_RasterPos2f(GLfloat x, GLfloat y)
 
 static void save_RasterPos2i(GLint x, GLint y)
 {
-   save_RasterPos4f(x, y, 0.0F, 1.0F);
+   save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
 static void save_RasterPos2s(GLshort x, GLshort y)
@@ -2721,7 +2730,7 @@ static void save_RasterPos2s(GLshort x, GLshort y)
 
 static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
 {
-   save_RasterPos4f(x, y, z, 1.0F);
+   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
 static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
@@ -2731,7 +2740,7 @@ static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
 
 static void save_RasterPos3i(GLint x, GLint y, GLint z)
 {
-   save_RasterPos4f(x, y, z, 1.0F);
+   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
 static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
@@ -2741,12 +2750,12 @@ static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
 
 static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
-   save_RasterPos4f(x, y, z, w);
+   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
 {
-   save_RasterPos4f(x, y, z, w);
+   save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
@@ -2756,7 +2765,7 @@ static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
 
 static void save_RasterPos2dv(const GLdouble *v)
 {
-   save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
 static void save_RasterPos2fv(const GLfloat *v)
@@ -2766,7 +2775,7 @@ static void save_RasterPos2fv(const GLfloat *v)
 
 static void save_RasterPos2iv(const GLint *v)
 {
-   save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
 static void save_RasterPos2sv(const GLshort *v)
@@ -2776,7 +2785,7 @@ static void save_RasterPos2sv(const GLshort *v)
 
 static void save_RasterPos3dv(const GLdouble *v)
 {
-   save_RasterPos4f(v[0], v[1], v[2], 1.0F);
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
 static void save_RasterPos3fv(const GLfloat *v)
@@ -2786,7 +2795,7 @@ static void save_RasterPos3fv(const GLfloat *v)
 
 static void save_RasterPos3iv(const GLint *v)
 {
-   save_RasterPos4f(v[0], v[1], v[2], 1.0F);
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
 static void save_RasterPos3sv(const GLshort *v)
@@ -2796,7 +2805,8 @@ static void save_RasterPos3sv(const GLshort *v)
 
 static void save_RasterPos4dv(const GLdouble *v)
 {
-   save_RasterPos4f(v[0], v[1], v[2], v[3]);
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
+                   (GLfloat) v[2], (GLfloat) v[3]);
 }
 
 static void save_RasterPos4fv(const GLfloat *v)
@@ -2806,7 +2816,8 @@ static void save_RasterPos4fv(const GLfloat *v)
 
 static void save_RasterPos4iv(const GLint *v)
 {
-   save_RasterPos4f(v[0], v[1], v[2], v[3]);
+   save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 
+                   (GLfloat) v[2], (GLfloat) v[3]);
 }
 
 static void save_RasterPos4sv(const GLshort *v)
@@ -2897,7 +2908,7 @@ static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
 
 static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
 {
-   save_Rotatef(angle, x, y, z);
+   save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
 }
 
 
@@ -2920,7 +2931,7 @@ static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
 
 static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
 {
-   save_Scalef(x, y, z);
+   save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
 }
 
 
@@ -3075,10 +3086,10 @@ static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
 static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
 {
    GLfloat p[4];
-   p[0] = params[0];
-   p[1] = params[1];
-   p[2] = params[2];
-   p[3] = params[3];
+   p[0] = (GLfloat) params[0];
+   p[1] = (GLfloat) params[1];
+   p[2] = (GLfloat) params[2];
+   p[3] = (GLfloat) params[3];
    save_TexGenfv(coord, pname, p);
 }
 
@@ -3093,10 +3104,10 @@ static void save_TexGend(GLenum coord, GLenum pname, GLdouble param )
 static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
 {
    GLfloat p[4];
-   p[0] = params[0];
-   p[1] = params[1];
-   p[2] = params[2];
-   p[3] = params[3];
+   p[0] = (GLfloat) params[0];
+   p[1] = (GLfloat) params[1];
+   p[2] = (GLfloat) params[2];
+   p[3] = (GLfloat) params[3];
    save_TexGenfv( coord, pname, p );
 }
 
@@ -3140,7 +3151,7 @@ static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
 }
 
 
-static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
+static void save_TexParameteri( GLenum target, GLenum pname, GLint param )
 {
    GLfloat fparam[4];
    fparam[0] = (GLfloat) param;
@@ -3259,7 +3270,7 @@ static void save_TexImage3D( GLenum target,
       if (n) {
          n[1].e = target;
          n[2].i = level;
-         n[3].i = internalFormat;
+         n[3].i = (GLint) internalFormat;
          n[4].i = (GLint) width;
          n[5].i = (GLint) height;
          n[6].i = (GLint) depth;
@@ -3396,7 +3407,7 @@ static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
 
 static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
 {
-   save_Translatef(x, y, z);
+   save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
 }
 
 
@@ -3424,6 +3435,7 @@ static void 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;
@@ -3438,7 +3450,7 @@ static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
 
 static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
 {
-   save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
+   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
 static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
@@ -3448,7 +3460,7 @@ static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
 
 static void save_WindowPos2iMESA(GLint x, GLint y)
 {
-   save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
+   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
 }
 
 static void save_WindowPos2sMESA(GLshort x, GLshort y)
@@ -3458,7 +3470,7 @@ static void save_WindowPos2sMESA(GLshort x, GLshort y)
 
 static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
 {
-   save_WindowPos4fMESA(x, y, z, 1.0F);
+   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
 static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
@@ -3468,7 +3480,7 @@ static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
 
 static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
 {
-   save_WindowPos4fMESA(x, y, z, 1.0F);
+   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
 }
 
 static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
@@ -3478,12 +3490,12 @@ static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
 
 static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
 {
-   save_WindowPos4fMESA(x, y, z, w);
+   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
 {
-   save_WindowPos4fMESA(x, y, z, w);
+   save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
 }
 
 static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
@@ -3493,7 +3505,7 @@ static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
 
 static void save_WindowPos2dvMESA(const GLdouble *v)
 {
-   save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
 static void save_WindowPos2fvMESA(const GLfloat *v)
@@ -3503,7 +3515,7 @@ static void save_WindowPos2fvMESA(const GLfloat *v)
 
 static void save_WindowPos2ivMESA(const GLint *v)
 {
-   save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
 }
 
 static void save_WindowPos2svMESA(const GLshort *v)
@@ -3513,7 +3525,7 @@ static void save_WindowPos2svMESA(const GLshort *v)
 
 static void save_WindowPos3dvMESA(const GLdouble *v)
 {
-   save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
 static void save_WindowPos3fvMESA(const GLfloat *v)
@@ -3523,7 +3535,7 @@ static void save_WindowPos3fvMESA(const GLfloat *v)
 
 static void save_WindowPos3ivMESA(const GLint *v)
 {
-   save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
 }
 
 static void save_WindowPos3svMESA(const GLshort *v)
@@ -3533,7 +3545,8 @@ static void save_WindowPos3svMESA(const GLshort *v)
 
 static void save_WindowPos4dvMESA(const GLdouble *v)
 {
-   save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 
+                       (GLfloat) v[2], (GLfloat) v[3]);
 }
 
 static void save_WindowPos4fvMESA(const GLfloat *v)
@@ -3543,7 +3556,8 @@ static void save_WindowPos4fvMESA(const GLfloat *v)
 
 static void save_WindowPos4ivMESA(const GLint *v)
 {
-   save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
+   save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 
+                       (GLfloat) v[2], (GLfloat) v[3]);
 }
 
 static void save_WindowPos4svMESA(const GLshort *v)
@@ -3553,39 +3567,119 @@ static void save_WindowPos4svMESA(const GLshort *v)
 
 
 
-/* GL_ARB_multitexture */
-static void save_ActiveTextureARB( GLenum target )
+/*
+ * GL_ARB_window_pos
+ */
+
+static void save_WindowPos3fARB( GLfloat x, GLfloat y, GLfloat z )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
+   FLUSH_CURRENT(ctx, 0);
+   n = ALLOC_INSTRUCTION( ctx,  OPCODE_WINDOW_POS_ARB, 3 );
    if (n) {
-      n[1].e = target;
+      n[1].f = x;
+      n[2].f = y;
+      n[3].f = z;
    }
    if (ctx->ExecuteFlag) {
-      (*ctx->Exec->ActiveTextureARB)( target );
+      (*ctx->Exec->WindowPos3fMESA)( x, y, z );
    }
 }
 
+static void save_WindowPos2dARB(GLdouble x, GLdouble y)
+{
+   save_WindowPos3fARB((GLfloat) x, (GLfloat) y, 0.0F);
+}
+
+static void save_WindowPos2fARB(GLfloat x, GLfloat y)
+{
+   save_WindowPos3fARB(x, y, 0.0F);
+}
+
+static void save_WindowPos2iARB(GLint x, GLint y)
+{
+   save_WindowPos3fARB((GLfloat) x, (GLfloat) y, 0.0F);
+}
+
+static void save_WindowPos2sARB(GLshort x, GLshort y)
+{
+   save_WindowPos3fARB(x, y, 0.0F);
+}
+
+static void save_WindowPos3dARB(GLdouble x, GLdouble y, GLdouble z)
+{
+   save_WindowPos3fARB((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+static void save_WindowPos3iARB(GLint x, GLint y, GLint z)
+{
+   save_WindowPos3fARB((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+static void save_WindowPos3sARB(GLshort x, GLshort y, GLshort z)
+{
+   save_WindowPos3fARB(x, y, z);
+}
+
+static void save_WindowPos2dvARB(const GLdouble *v)
+{
+   save_WindowPos3fARB((GLfloat) v[0], (GLfloat) v[1], 0.0F);
+}
+
+static void save_WindowPos2fvARB(const GLfloat *v)
+{
+   save_WindowPos3fARB(v[0], v[1], 0.0F);
+}
+
+static void save_WindowPos2ivARB(const GLint *v)
+{
+   save_WindowPos3fARB((GLfloat) v[0], (GLfloat) v[1], 0.0F);
+}
+
+static void save_WindowPos2svARB(const GLshort *v)
+{
+   save_WindowPos3fARB(v[0], v[1], 0.0F);
+}
+
+static void save_WindowPos3dvARB(const GLdouble *v)
+{
+   save_WindowPos3fARB((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+static void save_WindowPos3fvARB(const GLfloat *v)
+{
+   save_WindowPos3fARB(v[0], v[1], v[2]);
+}
+
+static void save_WindowPos3ivARB(const GLint *v)
+{
+   save_WindowPos3fARB((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+static void save_WindowPos3svARB(const GLshort *v)
+{
+   save_WindowPos3fARB(v[0], v[1], v[2]);
+}
+
 
 /* GL_ARB_multitexture */
-static void save_ClientActiveTextureARB( GLenum target )
+static void save_ActiveTextureARB( GLenum target )
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
    if (n) {
       n[1].e = target;
    }
    if (ctx->ExecuteFlag) {
-      (*ctx->Exec->ClientActiveTextureARB)( target );
+      (*ctx->Exec->ActiveTextureARB)( target );
    }
 }
 
 
-
 /* GL_ARB_transpose_matrix */
 
 static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
@@ -3604,7 +3698,8 @@ static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
 }
 
 
-static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
+static void
+save_MultTransposeMatrixdARB( const GLdouble m[16] )
 {
    GLfloat tm[16];
    _math_transposefd(tm, m);
@@ -3612,7 +3707,8 @@ static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
 }
 
 
-static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
+static void
+save_MultTransposeMatrixfARB( const GLfloat m[16] )
 {
    GLfloat tm[16];
    _math_transposef(tm, m);
@@ -3620,7 +3716,8 @@ static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
 }
 
 
-static void save_PixelTexGenSGIX(GLenum mode)
+static void
+save_PixelTexGenSGIX(GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3655,11 +3752,11 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
       /* make copy of image */
       image = MALLOC(imageSize);
       if (!image) {
-         gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
+      n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7 );
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3699,11 +3796,11 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
       /* make copy of image */
       image = MALLOC(imageSize);
       if (!image) {
-         gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
+      n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8 );
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3744,11 +3841,11 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
       /* make copy of image */
       image = MALLOC(imageSize);
       if (!image) {
-         gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
+      n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9 );
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3785,11 +3882,11 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
    /* make copy of image */
    image = MALLOC(imageSize);
    if (!image) {
-      gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7 );
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3804,7 +3901,7 @@ 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);
    }
 }
 
@@ -3824,11 +3921,11 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
    /* make copy of image */
    image = MALLOC(imageSize);
    if (!image) {
-      gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9 );
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3865,11 +3962,11 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
    /* make copy of image */
    image = MALLOC(imageSize);
    if (!image) {
-      gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11 );
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3893,9 +3990,28 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
 }
 
 
+/* GL_ARB_multisample */
+static void
+save_SampleCoverageARB(GLclampf value, GLboolean invert)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
+   if (n) {
+      n[1].f = value;
+      n[2].b = invert;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->SampleCoverageARB)( value, invert );
+   }
+}
+
+
 /* GL_SGIS_pixel_texture */
 
-static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
+static void
+save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
 {
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
@@ -3911,30 +4027,147 @@ static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
 }
 
 
-static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
+static void
+save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
 {
    save_PixelTexGenParameteriSGIS(target, (GLint) value);
 }
 
 
-static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
+static void
+save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
 {
    save_PixelTexGenParameteriSGIS(target, *value);
 }
 
 
-static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
+static void
+save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
 {
    save_PixelTexGenParameteriSGIS(target, (GLint) *value);
 }
 
 
+/*
+ * GL_NV_vertex_program
+ */
+static void
+save_BindProgramNV(GLenum target, GLuint id)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_PROGRAM_NV, 2 );
+   if (n) {
+      n[1].e = target;
+      n[2].ui = id;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->BindProgramNV)( target, id );
+   }
+}
+
+static void
+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);
+   }
+}
+
+
+static void
+save_ProgramParameter4fNV(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_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;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->ProgramParameter4fNV)(target, index, x, y, z, w);
+   }
+}
+
+
+static void
+save_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params)
+{
+   save_ProgramParameter4fNV(target, index, params[0], params[1],
+                             params[2], params[3]);
+}
+
+
+static void
+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);
+}
+
+
+static void
+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
+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);
+   }
+}
+
+
+
+
 /* 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 gl_save_error( GLcontext *ctx, GLenum error, const char *s )
+void
+_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
 {
    Node *n;
    n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
@@ -3946,6 +4179,21 @@ void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
 }
 
 
+/*
+ * 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)
 {
@@ -3970,7 +4218,8 @@ islist(GLcontext *ctx, GLuint list)
  * the absolute list number, not relative to ListBase.
  * Input:  list - display list number
  */
-static void execute_list( GLcontext *ctx, GLuint list )
+static void
+execute_list( GLcontext *ctx, GLuint list )
 {
    Node *n;
    GLboolean done;
@@ -3981,6 +4230,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
    if (ctx->Driver.BeginCallList)
       ctx->Driver.BeginCallList( ctx, list );
 
+/*     fprintf(stderr, "execute list %d\n", list); */
 /*     mesa_print_display_list( list );  */
 
    ctx->CallDepth++;
@@ -3992,14 +4242,14 @@ static void execute_list( GLcontext *ctx, GLuint list )
       OpCode opcode = n[0].opcode;
       int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
 
-      if (i >= 0 && i < ctx->listext.nr_opcodes) {
+      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:
-           gl_error( ctx, n[1].e, (const char *) n[2].data );
+           _mesa_error( ctx, n[1].e, (const char *) n[2].data );
            break;
          case OPCODE_ACCUM:
            (*ctx->Exec->Accum)( n[1].e, n[2].f );
@@ -4056,7 +4306,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
            (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
            break;
         case OPCODE_CLEAR_INDEX:
-           (*ctx->Exec->ClearIndex)( n[1].ui );
+           (*ctx->Exec->ClearIndex)( (GLfloat) n[1].ui );
            break;
         case OPCODE_CLEAR_STENCIL:
            (*ctx->Exec->ClearStencil)( n[1].i );
@@ -4246,9 +4496,6 @@ static void execute_list( GLcontext *ctx, GLuint list )
         case OPCODE_HINT:
            (*ctx->Exec->Hint)( n[1].e, n[2].e );
            break;
-        case OPCODE_HINT_PGI:
-           (*ctx->Exec->HintPGI)( n[1].e, n[2].i );
-           break;
         case OPCODE_HISTOGRAM:
            (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b );
            break;
@@ -4576,9 +4823,6 @@ static void execute_list( GLcontext *ctx, GLuint list )
          case OPCODE_ACTIVE_TEXTURE:  /* GL_ARB_multitexture */
             (*ctx->Exec->ActiveTextureARB)( n[1].e );
             break;
-         case OPCODE_CLIENT_ACTIVE_TEXTURE:  /* GL_ARB_multitexture */
-            (*ctx->Exec->ClientActiveTextureARB)( n[1].e );
-            break;
          case OPCODE_PIXEL_TEXGEN_SGIX:  /* GL_SGIX_pixel_texture */
             (*ctx->Exec->PixelTexGenSGIX)( n[1].e );
             break;
@@ -4610,6 +4854,48 @@ static void execute_list( GLcontext *ctx, GLuint list )
                                         n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
                                         n[9].e, n[10].i, n[11].data);
             break;
+         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->WindowPos3fARB)( n[1].f, n[2].f, n[3].f );
+           break;
+         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_PROGRAMS_RESIDENT_NV:
+            /*
+            (*ctx->Exec->RequestResidentProgramsNV)();
+            */
+            break;
+         case OPCODE_LOAD_PROGRAM_NV:
+            /*
+            (*ctx->Exec->LoadProgramNV)();
+            */
+            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_PROGRAM_PARAMETERS4FV_NV:
+            /*
+            (*ctx->Exec->ProgramParameters4fvNV)();
+            */
+            break;
+         case OPCODE_TRACK_MATRIX_NV:
+            (*ctx->Exec->TrackMatrixNV)(n[1].e, n[2].ui, n[3].e, n[4].e);
+            break;
+
         case OPCODE_CONTINUE:
            n = (Node *) n[1].next;
            break;
@@ -4620,7 +4906,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
             {
                char msg[1000];
                sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
-               gl_problem( ctx, msg );
+               _mesa_problem( ctx, msg );
             }
             done = GL_TRUE;
         }
@@ -4673,11 +4959,11 @@ _mesa_DeleteLists( GLuint list, GLsizei range )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (range<0) {
-      gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
+      _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
       return;
    }
    for (i=list;i<list+range;i++) {
-      gl_destroy_list( ctx, i );
+      _mesa_destroy_list( ctx, i );
    }
 }
 
@@ -4696,7 +4982,7 @@ _mesa_GenLists(GLsizei range )
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
 
    if (range<0) {
-      gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
+      _mesa_error( ctx, GL_INVALID_VALUE, "glGenLists" );
       return 0;
    }
    if (range==0) {
@@ -4735,21 +5021,21 @@ _mesa_NewList( GLuint list, GLenum mode )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE&VERBOSE_API)
-      fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
+      fprintf(stderr, "glNewList %u %s\n", list, _mesa_lookup_enum_by_nr(mode));
 
    if (list==0) {
-      gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
+      _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
       return;
    }
 
    if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
-      gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
+      _mesa_error( ctx, GL_INVALID_ENUM, "glNewList" );
       return;
    }
 
    if (ctx->CurrentListPtr) {
       /* already compiling a display list */
-      gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
       return;
    }
 
@@ -4770,7 +5056,7 @@ _mesa_NewList( GLuint list, GLenum mode )
 
 
 /*
- * End definition of current display list.  Is the current 
+ * 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?
  */
@@ -4787,14 +5073,14 @@ _mesa_EndList( void )
 
    /* Check that a list is under construction */
    if (!ctx->CurrentListPtr) {
-      gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
       return;
    }
 
    (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
 
    /* Destroy old list, if any */
-   gl_destroy_list(ctx, ctx->CurrentListNum);
+   _mesa_destroy_list(ctx, ctx->CurrentListNum);
    /* Install the list */
    _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
 
@@ -4819,15 +5105,13 @@ _mesa_EndList( void )
 void
 _mesa_CallList( GLuint list )
 {
+   GLboolean save_compile_flag;
    GET_CURRENT_CONTEXT(ctx);
+   FLUSH_CURRENT(ctx, 0);
    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
    /* execute the display list, and restore the CompileFlag. */
-   GLboolean save_compile_flag;
 
-   if (MESA_VERBOSE&VERBOSE_API) {
-      fprintf(stderr, "glCallList %u\n", list);
-      mesa_print_display_list( list );
-   }
+/*     mesa_print_display_list( list ); */
 
    save_compile_flag = ctx->CompileFlag;
    if (save_compile_flag) {
@@ -5093,7 +5377,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 exec_GetTexParameterfv( GLenum target, GLenum pname,
                                    GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5166,7 +5450,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 exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
                              const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5223,7 +5507,7 @@ static void exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
    ctx->Exec->IndexPointer( type, stride, ptr);
 }
 
-static void exec_InterleavedArrays(GLenum format, GLsizei stride, 
+static void exec_InterleavedArrays(GLenum format, GLsizei stride,
                                   const GLvoid *pointer)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5259,7 +5543,7 @@ static void exec_PushClientAttrib(GLbitfield mask)
    ctx->Exec->PushClientAttrib( mask);
 }
 
-static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, 
+static void exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
                                 const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5267,7 +5551,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 exec_GetCompressedTexImageARB(GLenum target, GLint level,
                                          GLvoid *img)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5275,7 +5559,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 exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
                               const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5283,7 +5567,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 exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
                                         GLint x, GLint y, GLsizei width)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5309,7 +5593,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 exec_GetColorTableParameterfv( GLenum target, GLenum pname,
                                           GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5317,7 +5601,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 exec_GetColorTableParameteriv( GLenum target, GLenum pname,
                                           GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5333,7 +5617,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 exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
                                           GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5349,7 +5633,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 exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
                              GLenum type, GLvoid *values)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5357,7 +5641,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 exec_GetHistogramParameterfv(GLenum target, GLenum pname,
                                         GLfloat *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5365,7 +5649,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 exec_GetHistogramParameteriv(GLenum target, GLenum pname,
                                         GLint *params)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5373,7 +5657,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 exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
                           GLenum type, GLvoid *values)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5397,7 +5681,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 exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
                                    GLvoid *row, GLvoid *column, GLvoid *span)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5499,6 +5783,14 @@ static void exec_ResizeBuffersMESA( void )
    ctx->Exec->ResizeBuffersMESA( );
 }
 
+
+static void exec_ClientActiveTextureARB( GLenum target )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   ctx->Exec->ClientActiveTextureARB(target);
+}
+
 static void exec_SecondaryColorPointerEXT(GLint size, GLenum type,
                               GLsizei stride, const GLvoid *ptr)
 {
@@ -5507,7 +5799,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 exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
                                    const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -5529,15 +5821,15 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
 {
    _mesa_init_no_op_table(table, tableSize);
 
-   _mesa_loopback_init_api_table( table, GL_FALSE );
+   _mesa_loopback_init_api_table( table, GL_TRUE );
 
    /* GL 1.0 */
    table->Accum = save_Accum;
    table->AlphaFunc = save_AlphaFunc;
    table->Bitmap = save_Bitmap;
    table->BlendFunc = save_BlendFunc;
-   table->CallList = save_CallList;
-   table->CallLists = save_CallLists;
+   table->CallList = _mesa_save_CallList;
+   table->CallLists = _mesa_save_CallLists;
    table->Clear = save_Clear;
    table->ClearAccum = save_ClearAccum;
    table->ClearColor = save_ClearColor;
@@ -5819,9 +6111,6 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->PointParameterfEXT = save_PointParameterfEXT;
    table->PointParameterfvEXT = save_PointParameterfvEXT;
 
-   /* 77. GL_PGI_misc_hints */
-   table->HintPGI = save_HintPGI;
-
    /* 78. GL_EXT_paletted_texture */
 #if 0
    table->ColorTableEXT = save_ColorTable;
@@ -5835,14 +6124,19 @@ _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 = save_ClientActiveTextureARB;
+   /* 145. GL_EXT_secondary_color */
+   table->SecondaryColorPointerEXT = exec_SecondaryColorPointerEXT;
+
+   /* 149. GL_EXT_fog_coord */
+   table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
 
-   /* GL_EXT_blend_func_separate */
+   /* 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;
@@ -5868,15 +6162,51 @@ _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;
+   /* 233. GL_NV_vertex_program */
+   /* XXX Need to implement vertex program in display lists !!! */
+   /* The following commands DO NOT go into display lists:
+    * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
+    * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
+    */
+   table->BindProgramNV = save_BindProgramNV;
+   table->DeleteProgramsNV = _mesa_DeleteProgramsNV;
+   table->ExecuteProgramNV = save_ExecuteProgramNV;
+   table->GenProgramsNV = _mesa_GenProgramsNV;
+   table->AreProgramsResidentNV = _mesa_AreProgramsResidentNV;
+   table->RequestResidentProgramsNV = _mesa_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_IsProgramNV;
+   table->LoadProgramNV = _mesa_LoadProgramNV;
+   table->ProgramParameter4dNV = save_ProgramParameter4dNV;
+   table->ProgramParameter4dvNV = save_ProgramParameter4dvNV;
+   table->ProgramParameter4fNV = save_ProgramParameter4fNV;
+   table->ProgramParameter4fvNV = save_ProgramParameter4fvNV;
+   table->ProgramParameters4dvNV = _mesa_ProgramParameters4dvNV;
+   table->ProgramParameters4fvNV = _mesa_ProgramParameters4fvNV;
+   table->TrackMatrixNV = save_TrackMatrixNV;
+   table->VertexAttribPointerNV = _mesa_VertexAttribPointerNV;
+
+   /* ARB 1. GL_ARB_multitexture */
+   table->ActiveTextureARB = save_ActiveTextureARB;
+   table->ClientActiveTextureARB = exec_ClientActiveTextureARB;
 
-   /* GL_ARB_transpose_matrix */
+   /* ARB 3. GL_ARB_transpose_matrix */
    table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
    table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
    table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
    table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
 
+   /* ARB 5. GL_ARB_multisample */
+   table->SampleCoverageARB = save_SampleCoverageARB;
+
    /* ARB 12. GL_ARB_texture_compression */
    table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
    table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
@@ -5886,11 +6216,23 @@ _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;
-
-   /* GL_EXT_fog_coord */
-   table->FogCoordPointerEXT = exec_FogCoordPointerEXT;
+   /* ARB ??. GL_ARB_window_pos */
+   table->WindowPos2dARB = save_WindowPos2dARB;
+   table->WindowPos2dvARB = save_WindowPos2dvARB;
+   table->WindowPos2fARB = save_WindowPos2fARB;
+   table->WindowPos2fvARB = save_WindowPos2fvARB;
+   table->WindowPos2iARB = save_WindowPos2iARB;
+   table->WindowPos2ivARB = save_WindowPos2ivARB;
+   table->WindowPos2sARB = save_WindowPos2sARB;
+   table->WindowPos2svARB = save_WindowPos2svARB;
+   table->WindowPos3dARB = save_WindowPos3dARB;
+   table->WindowPos3dvARB = save_WindowPos3dvARB;
+   table->WindowPos3fARB = save_WindowPos3fARB;
+   table->WindowPos3fvARB = save_WindowPos3fvARB;
+   table->WindowPos3iARB = save_WindowPos3iARB;
+   table->WindowPos3ivARB = save_WindowPos3ivARB;
+   table->WindowPos3sARB = save_WindowPos3sARB;
+   table->WindowPos3svARB = save_WindowPos3svARB;
 }
 
 
@@ -5900,7 +6242,7 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
  ***/
 static const char *enum_string( GLenum k )
 {
-   return gl_lookup_enum_by_nr( k );
+   return _mesa_lookup_enum_by_nr( k );
 }
 
 
@@ -5925,12 +6267,13 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
    done = n ? GL_FALSE : GL_TRUE;
    while (!done) {
       OpCode opcode = n[0].opcode;
-      int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+      GLint i = (GLint) n[0].opcode - (GLint) OPCODE_DRV_0;
 
-      if (i >= 0 && i < ctx->listext.nr_opcodes) {
+      if (i >= 0 && i < (GLint) ctx->listext.nr_opcodes) {
         ctx->listext.opcode[i].print(ctx, &n[1]);
         n += ctx->listext.opcode[i].size;
-      } else {
+      }
+      else {
         switch (opcode) {
          case OPCODE_ACCUM:
             fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
@@ -6021,11 +6364,37 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
             fprintf(f,"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", gl_lookup_enum_by_nr(n[1].ui),
+           fprintf(f,"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", gl_lookup_enum_by_nr(n[1].ui));
+           fprintf(f,"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_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);
+           break;
+        case OPCODE_MAPGRID1:
+           fprintf(f,"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);
+           break;
+        case OPCODE_EVALMESH1:
+           fprintf(f,"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);
            break;
 
         /*