fixed pointer arithmetic error in glCopyPixels
[mesa.git] / src / mesa / main / dlist.c
index c889b67f8bc5b992f9852889de11b4f8a8080412..56cf706fad6090088caf879705ad29f000de0cb6 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: dlist.c,v 1.72 2001/05/29 15:23:48 brianp Exp $ */
+/* $Id: dlist.c,v 1.84 2001/12/19 02:36:05 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  4.1
  *
  * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
  *
 #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"
@@ -235,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,
@@ -248,6 +243,16 @@ 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_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,
@@ -633,7 +638,16 @@ void _mesa_init_lists( void )
       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;
 }
@@ -1006,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 );
@@ -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;
@@ -1777,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 );
@@ -2090,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);
 }
@@ -2136,8 +2150,8 @@ static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
    if (n) {
       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;
@@ -2182,10 +2196,10 @@ static void save_Map2d( GLenum target,
       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*/
@@ -2251,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);
 }
 
 
@@ -2280,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);
 }
 
 
@@ -2341,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,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 );
@@ -2695,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)
@@ -2705,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)
@@ -2715,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)
@@ -2725,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)
@@ -2735,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)
@@ -2750,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)
@@ -2760,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)
@@ -2770,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)
@@ -2780,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)
@@ -2790,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)
@@ -2800,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)
@@ -2891,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);
 }
 
 
@@ -2914,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);
 }
 
 
@@ -3069,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);
 }
 
@@ -3087,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 );
 }
 
@@ -3134,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;
@@ -3232,7 +3249,7 @@ static void save_TexImage2D( GLenum target,
 
 
 static void save_TexImage3D( GLenum target,
-                             GLint level, GLenum internalFormat,
+                             GLint level, GLint internalFormat,
                              GLsizei width, GLsizei height, GLsizei depth,
                              GLint border,
                              GLenum format, GLenum type,
@@ -3390,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);
 }
 
 
@@ -3433,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)
@@ -3443,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)
@@ -3453,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)
@@ -3463,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)
@@ -3473,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)
@@ -3488,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)
@@ -3498,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)
@@ -3508,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)
@@ -3518,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)
@@ -3528,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)
@@ -3538,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)
@@ -3548,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] )
@@ -3657,7 +3756,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
          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;
@@ -3701,7 +3800,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
          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;
@@ -3746,7 +3845,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
          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;
@@ -3787,7 +3886,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
       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;
@@ -3802,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);
    }
 }
 
@@ -3826,7 +3925,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
       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;
@@ -3867,7 +3966,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
       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;
@@ -3949,6 +4048,119 @@ save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *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
@@ -3967,6 +4179,21 @@ _mesa_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)
 {
@@ -4079,7 +4306,7 @@ 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 );
@@ -4596,9 +4823,6 @@ 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;
@@ -4633,6 +4857,45 @@ 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->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;
@@ -5520,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)
 {
@@ -5853,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;
@@ -5886,16 +6162,49 @@ _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;
 
-   /* GL_ARB_multisample */
+   /* ARB 5. GL_ARB_multisample */
    table->SampleCoverageARB = save_SampleCoverageARB;
 
    /* ARB 12. GL_ARB_texture_compression */
@@ -5907,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;
 }