head	3.24;
access;
symbols
	merge-1:3.20.2.3
	autoconf:3.20.0.4
	experimental-1:3.20.0.2
	mesa-3-1-with-kw3:3.15
	mesa-3-1-prior-to-kw3:3.14;
locks; strict;
comment	@ * @;


3.24
date	99.08.01.00.06.57;	author brianp;	state Exp;
branches;
next	3.23;

3.23
date	99.07.12.14.59.19;	author brianp;	state Exp;
branches;
next	3.22;

3.22
date	99.07.12.12.05.23;	author keithw;	state Exp;
branches;
next	3.21;

3.21
date	99.06.18.20.03.37;	author brianp;	state Exp;
branches;
next	3.20;

3.20
date	99.04.07.22.53.48;	author brianp;	state Exp;
branches
	3.20.2.1;
next	3.19;

3.19
date	99.03.31.20.18.38;	author keithw;	state Exp;
branches;
next	3.18;

3.18
date	99.03.20.18.56.47;	author brianp;	state Exp;
branches;
next	3.17;

3.17
date	99.03.17.12.08.22;	author keithw;	state Exp;
branches;
next	3.16;

3.16
date	99.03.02.13.05.04;	author brianp;	state Exp;
branches;
next	3.15;

3.15
date	99.02.25.14.12.30;	author keithw;	state Exp;
branches;
next	3.14;

3.14
date	99.02.24.22.48.05;	author jens;	state Exp;
branches;
next	3.13;

3.13
date	99.02.14.03.46.34;	author brianp;	state Exp;
branches;
next	3.12;

3.12
date	98.11.18.04.43.03;	author brianp;	state Exp;
branches;
next	3.11;

3.11
date	98.11.03.01.40.37;	author brianp;	state Exp;
branches;
next	3.10;

3.10
date	98.10.20.02.27.56;	author brianp;	state Exp;
branches;
next	3.9;

3.9
date	98.10.05.00.40.15;	author brianp;	state Exp;
branches;
next	3.8;

3.8
date	98.08.21.02.48.14;	author brianp;	state Exp;
branches;
next	3.7;

3.7
date	98.08.21.02.42.21;	author brianp;	state Exp;
branches;
next	3.6;

3.6
date	98.06.07.22.18.52;	author brianp;	state Exp;
branches;
next	3.5;

3.5
date	98.03.28.03.58.52;	author brianp;	state Exp;
branches;
next	3.4;

3.4
date	98.03.27.03.39.14;	author brianp;	state Exp;
branches;
next	3.3;

3.3
date	98.03.19.01.26.39;	author brianp;	state Exp;
branches;
next	3.2;

3.2
date	98.02.20.04.50.09;	author brianp;	state Exp;
branches;
next	3.1;

3.1
date	98.02.08.20.23.09;	author brianp;	state Exp;
branches;
next	3.0;

3.0
date	98.01.31.20.50.39;	author brianp;	state Exp;
branches;
next	;

3.20.2.1
date	99.05.21.21.29.25;	author keithw;	state Exp;
branches;
next	3.20.2.2;

3.20.2.2
date	99.06.06.22.35.53;	author keithw;	state Exp;
branches;
next	3.20.2.3;

3.20.2.3
date	99.06.19.15.04.13;	author keithw;	state Exp;
branches;
next	;


desc
@display list functions
@


3.24
log
@glBitmap clean-up
@
text
@/* $Id: dlist.c,v 3.23 1999/07/12 14:59:19 brianp Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  3.1
 * 
 * Copyright (C) 1999  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"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */


#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "accum.h"
#include "api.h"
#include "alpha.h"
#include "attrib.h"
#include "bitmap.h"
#include "bbox.h"
#include "blend.h"
#include "clip.h"
#include "colortab.h"
#include "context.h"
#include "copypix.h"
#include "depth.h"
#include "drawpix.h"
#include "enable.h"
#include "enums.h"
#include "eval.h"
#include "feedback.h"
#include "fog.h"
#include "get.h"
#include "hash.h"
#include "image.h"
#include "light.h"
#include "lines.h"
#include "dlist.h"
#include "logic.h"
#include "macros.h"
#include "masking.h"
#include "matrix.h"
#include "misc.h"
#include "pipeline.h"
#include "pixel.h"
#include "points.h"
#include "polygon.h"
#include "rastpos.h"
#include "readpix.h"
#include "rect.h"
#include "scissor.h"
#include "stencil.h"
#include "texobj.h"
#include "teximage.h"
#include "texstate.h"
#include "types.h"
#include "varray.h"
#include "vb.h"
#include "vbfill.h"
#include "vbxform.h"
#include "winpos.h"
#include "xform.h"
#ifdef XFree86Server
#undef MISC_H
#include "GL/xf86glx.h"
#endif
#endif



/*
Functions which aren't compiled but executed immediately:
	glIsList
	glGenLists
	glDeleteLists
	glEndList
	glFeedbackBuffer
	glSelectBuffer
	glRenderMode
	glReadPixels
	glPixelStore
	glFlush
	glFinish
	glIsEnabled
	glGet*

Functions which cause errors if called while compiling a display list:
	glNewList
*/



/*
 * Display list instructions are stored as sequences of "nodes".  Nodes
 * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
 * are linked together with a pointer.
 */


/* How many nodes to allocate at a time: 
 * - reduced now that we hold vertices etc. elsewhere.
 */
#define BLOCK_SIZE 64


/*
 * Display list opcodes.
 *
 * The fact that these identifiers are assigned consecutive
 * integer values starting at 0 is very important, see InstSize array usage)
 *
 * KW: Commented out opcodes now handled by vertex-cassettes.
 */
typedef enum {
	OPCODE_ACCUM,
	OPCODE_ALPHA_FUNC,
        OPCODE_BIND_TEXTURE,
	OPCODE_BITMAP,
	OPCODE_BLEND_COLOR,
	OPCODE_BLEND_EQUATION,
	OPCODE_BLEND_FUNC,
	OPCODE_BLEND_FUNC_SEPARATE,
        OPCODE_CALL_LIST,
        OPCODE_CALL_LIST_OFFSET,
	OPCODE_CLEAR,
	OPCODE_CLEAR_ACCUM,
	OPCODE_CLEAR_COLOR,
	OPCODE_CLEAR_DEPTH,
	OPCODE_CLEAR_INDEX,
	OPCODE_CLEAR_STENCIL,
        OPCODE_CLIP_PLANE,
	OPCODE_COLOR_MASK,
	OPCODE_COLOR_MATERIAL,
	OPCODE_COLOR_TABLE,
	OPCODE_COLOR_SUB_TABLE,
	OPCODE_COPY_PIXELS,
        OPCODE_COPY_TEX_IMAGE1D,
        OPCODE_COPY_TEX_IMAGE2D,
        OPCODE_COPY_TEX_IMAGE3D,
        OPCODE_COPY_TEX_SUB_IMAGE1D,
        OPCODE_COPY_TEX_SUB_IMAGE2D,
        OPCODE_COPY_TEX_SUB_IMAGE3D,
	OPCODE_CULL_FACE,
	OPCODE_DEPTH_FUNC,
	OPCODE_DEPTH_MASK,
	OPCODE_DEPTH_RANGE,
	OPCODE_DISABLE,
	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_INDEX_MASK,
	OPCODE_INIT_NAMES,
	OPCODE_LIGHT,
	OPCODE_LIGHT_MODEL,
	OPCODE_LINE_STIPPLE,
	OPCODE_LINE_WIDTH,
	OPCODE_LIST_BASE,
	OPCODE_LOAD_IDENTITY,
	OPCODE_LOAD_MATRIX,
	OPCODE_LOAD_NAME,
	OPCODE_LOGIC_OP,
	OPCODE_MAP1,
	OPCODE_MAP2,
	OPCODE_MAPGRID1,
	OPCODE_MAPGRID2,
	OPCODE_MATRIX_MODE,
	OPCODE_MULT_MATRIX,
	OPCODE_ORTHO,
	OPCODE_PASSTHROUGH,
	OPCODE_PIXEL_MAP,
	OPCODE_PIXEL_TRANSFER,
	OPCODE_PIXEL_ZOOM,
	OPCODE_POINT_SIZE,
        OPCODE_POINT_PARAMETERS,
	OPCODE_POLYGON_MODE,
        OPCODE_POLYGON_STIPPLE,
	OPCODE_POLYGON_OFFSET,
	OPCODE_POP_ATTRIB,
	OPCODE_POP_MATRIX,
	OPCODE_POP_NAME,
	OPCODE_PRIORITIZE_TEXTURE,
	OPCODE_PUSH_ATTRIB,
	OPCODE_PUSH_MATRIX,
	OPCODE_PUSH_NAME,
	OPCODE_RASTER_POS,
	OPCODE_RECTF,
	OPCODE_READ_BUFFER,
        OPCODE_SCALE,
	OPCODE_SCISSOR,
	OPCODE_SELECT_TEXTURE_SGIS,
	OPCODE_SELECT_TEXTURE_COORD_SET,
	OPCODE_SHADE_MODEL,
	OPCODE_STENCIL_FUNC,
	OPCODE_STENCIL_MASK,
	OPCODE_STENCIL_OP,
        OPCODE_TEXENV,
        OPCODE_TEXGEN,
        OPCODE_TEXPARAMETER,
	OPCODE_TEX_IMAGE1D,
	OPCODE_TEX_IMAGE2D,
	OPCODE_TEX_IMAGE3D,
	OPCODE_TEX_SUB_IMAGE1D,
	OPCODE_TEX_SUB_IMAGE2D,
	OPCODE_TEX_SUB_IMAGE3D,
        OPCODE_TRANSLATE,
	OPCODE_VIEWPORT,
	OPCODE_WINDOW_POS,
        /* GL_ARB_multitexture */
        OPCODE_ACTIVE_TEXTURE,
        OPCODE_CLIENT_ACTIVE_TEXTURE,
	/* The following three are meta instructions */
	OPCODE_ERROR,	        /* raise compiled-in error */
	OPCODE_VERTEX_CASSETTE,	/* render prebuilt vertex buffer */
	OPCODE_CONTINUE,
	OPCODE_END_OF_LIST
} OpCode;


/*
 * Each instruction in the display list is stored as a sequence of
 * contiguous nodes in memory.
 * Each node is the union of a variety of datatypes.
 */
union node {
	OpCode		opcode;
	GLboolean	b;
	GLbitfield	bf;
	GLubyte		ub;
	GLshort		s;
	GLushort	us;
	GLint		i;
	GLuint		ui;
	GLenum		e;
	GLfloat		f;
	GLvoid		*data;
	void		*next;	/* If prev node's opcode==OPCODE_CONTINUE */
};



/* Number of nodes of storage needed for each instruction: */
static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];



/**********************************************************************/
/*****                           Private                          *****/
/**********************************************************************/


/*
 * Allocate space for a display list instruction.
 * Input:  opcode - type of instruction
 *         argcount - number of arguments following the instruction
 * Return: pointer to first node in the instruction
 */
static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
{
   Node *n, *newblock;
   GLuint count = InstSize[opcode];

   assert( (GLint) count == argcount+1 );

   if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
      /* This block is full.  Allocate a new block and chain to it */
      n = ctx->CurrentBlock + ctx->CurrentPos;
      n[0].opcode = OPCODE_CONTINUE;
      newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
      if (!newblock) {
         gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
         return NULL;
      }
      n[1].next = (Node *) newblock;
      ctx->CurrentBlock = newblock;
      ctx->CurrentPos = 0;
   }

   n = ctx->CurrentBlock + ctx->CurrentPos;
   ctx->CurrentPos += count;

   n[0].opcode = opcode;

   return n;
}



/*
 * Make an empty display list.  This is used by glGenLists() to
 * reserver display list IDs.
 */
static Node *make_empty_list( void )
{
   Node *n = (Node *) malloc( sizeof(Node) );
   n[0].opcode = OPCODE_END_OF_LIST;
   return n;
}



/*
 * Destroy all nodes in a display list.
 * Input:  list - display list number
 */
void gl_destroy_list( GLcontext *ctx, GLuint list )
{
   Node *n, *block;
   GLboolean done;

   if (list==0)
      return;

   block = (Node *) HashLookup(ctx->Shared->DisplayList, list);
   n = block;

   done = block ? GL_FALSE : GL_TRUE;
   while (!done) {
      switch (n[0].opcode) {
	 /* special cases first */
         case OPCODE_VERTEX_CASSETTE: 
	    if ( ! -- ((struct immediate *) n[1].data)->ref_count )
	       gl_immediate_free( (struct immediate *) n[1].data );
	    n += InstSize[n[0].opcode];
	    break;
	 case OPCODE_MAP1:
	    gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data );
	    n += InstSize[n[0].opcode];
	    break;
	 case OPCODE_MAP2:
	    gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data );
	    n += InstSize[n[0].opcode];
	    break;
	 case OPCODE_DRAW_PIXELS:
	    gl_free_image( (struct gl_image *) n[1].data );
	    n += InstSize[n[0].opcode];
	    break;
	 case OPCODE_BITMAP:
	    gl_free_image( (struct gl_image *) n[7].data );
	    n += InstSize[n[0].opcode];
	    break;
         case OPCODE_COLOR_TABLE:
            gl_free_image( (struct gl_image *) n[3].data );
            n += InstSize[n[0].opcode];
            break;
         case OPCODE_COLOR_SUB_TABLE:
            gl_free_image( (struct gl_image *) n[3].data );
            n += InstSize[n[0].opcode];
            break;
         case OPCODE_POLYGON_STIPPLE:
            free( n[1].data );
	    n += InstSize[n[0].opcode];
            break;
	 case OPCODE_TEX_IMAGE1D:
            gl_free_image( (struct gl_image *) n[8].data );
            n += InstSize[n[0].opcode];
	    break;
	 case OPCODE_TEX_IMAGE2D:
            gl_free_image( (struct gl_image *) n[9].data );
            n += InstSize[n[0].opcode];
	    break;
         case OPCODE_TEX_SUB_IMAGE1D:
            {
               struct gl_image *image;
               image = (struct gl_image *) n[7].data;
               gl_free_image( image );
            }
            break;
         case OPCODE_TEX_SUB_IMAGE2D:
            {
               struct gl_image *image;
               image = (struct gl_image *) n[9].data;
               gl_free_image( image );
            }
            break;
	 case OPCODE_CONTINUE:
	    n = (Node *) n[1].next;
	    free( block );
	    block = n;
	    break;
	 case OPCODE_END_OF_LIST:
	    free( block );
	    done = GL_TRUE;
	    break;
	 default:
	    /* Most frequent case */
	    n += InstSize[n[0].opcode];
	    break;
      }
   }

   HashRemove(ctx->Shared->DisplayList, list);
}



/*
 * Translate the nth element of list from type to GLuint.
 */
static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
{
   GLbyte *bptr;
   GLubyte *ubptr;
   GLshort *sptr;
   GLushort *usptr;
   GLint *iptr;
   GLuint *uiptr;
   GLfloat *fptr;

   switch (type) {
      case GL_BYTE:
         bptr = (GLbyte *) list;
         return (GLuint) *(bptr+n);
      case GL_UNSIGNED_BYTE:
         ubptr = (GLubyte *) list;
         return (GLuint) *(ubptr+n);
      case GL_SHORT:
         sptr = (GLshort *) list;
         return (GLuint) *(sptr+n);
      case GL_UNSIGNED_SHORT:
         usptr = (GLushort *) list;
         return (GLuint) *(usptr+n);
      case GL_INT:
         iptr = (GLint *) list;
         return (GLuint) *(iptr+n);
      case GL_UNSIGNED_INT:
         uiptr = (GLuint *) list;
         return (GLuint) *(uiptr+n);
      case GL_FLOAT:
         fptr = (GLfloat *) list;
         return (GLuint) *(fptr+n);
      case GL_2_BYTES:
         ubptr = ((GLubyte *) list) + 2*n;
         return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
      case GL_3_BYTES:
         ubptr = ((GLubyte *) list) + 3*n;
         return (GLuint) *ubptr * 65536
              + (GLuint) *(ubptr+1) * 256
              + (GLuint) *(ubptr+2);
      case GL_4_BYTES:
         ubptr = ((GLubyte *) list) + 4*n;
         return (GLuint) *ubptr * 16777216
              + (GLuint) *(ubptr+1) * 65536
              + (GLuint) *(ubptr+2) * 256
              + (GLuint) *(ubptr+3);
      default:
         return 0;
   }
}




/**********************************************************************/
/*****                        Public                              *****/
/**********************************************************************/

void gl_init_lists( void )
{
   static int init_flag = 0;

   if (init_flag==0) {
      InstSize[OPCODE_ACCUM] = 3;
      InstSize[OPCODE_ALPHA_FUNC] = 3;
      InstSize[OPCODE_BIND_TEXTURE] = 3;
      InstSize[OPCODE_BITMAP] = 8;
      InstSize[OPCODE_BLEND_COLOR] = 5;
      InstSize[OPCODE_BLEND_EQUATION] = 2;
      InstSize[OPCODE_BLEND_FUNC] = 3;
      InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
      InstSize[OPCODE_CALL_LIST] = 2;
      InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
      InstSize[OPCODE_CLEAR] = 2;
      InstSize[OPCODE_CLEAR_ACCUM] = 5;
      InstSize[OPCODE_CLEAR_COLOR] = 5;
      InstSize[OPCODE_CLEAR_DEPTH] = 2;
      InstSize[OPCODE_CLEAR_INDEX] = 2;
      InstSize[OPCODE_CLEAR_STENCIL] = 2;
      InstSize[OPCODE_CLIP_PLANE] = 6;
      InstSize[OPCODE_COLOR_MASK] = 5;
      InstSize[OPCODE_COLOR_MATERIAL] = 3;
      InstSize[OPCODE_COLOR_TABLE] = 4;
      InstSize[OPCODE_COLOR_SUB_TABLE] = 4;
      InstSize[OPCODE_COPY_PIXELS] = 6;
      InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
      InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
      InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
      InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
      InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
      InstSize[OPCODE_CULL_FACE] = 2;
      InstSize[OPCODE_DEPTH_FUNC] = 2;
      InstSize[OPCODE_DEPTH_MASK] = 2;
      InstSize[OPCODE_DEPTH_RANGE] = 3;
      InstSize[OPCODE_DISABLE] = 2;
      InstSize[OPCODE_DRAW_BUFFER] = 2;
      InstSize[OPCODE_DRAW_PIXELS] = 2;
      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_INDEX_MASK] = 2;
      InstSize[OPCODE_INIT_NAMES] = 1;
      InstSize[OPCODE_LIGHT] = 7;
      InstSize[OPCODE_LIGHT_MODEL] = 6;
      InstSize[OPCODE_LINE_STIPPLE] = 3;
      InstSize[OPCODE_LINE_WIDTH] = 2;
      InstSize[OPCODE_LIST_BASE] = 2;
      InstSize[OPCODE_LOAD_IDENTITY] = 1;
      InstSize[OPCODE_LOAD_MATRIX] = 17;
      InstSize[OPCODE_LOAD_NAME] = 2;
      InstSize[OPCODE_LOGIC_OP] = 2;
      InstSize[OPCODE_MAP1] = 7;
      InstSize[OPCODE_MAP2] = 11;
      InstSize[OPCODE_MAPGRID1] = 4;
      InstSize[OPCODE_MAPGRID2] = 7;
      InstSize[OPCODE_MATRIX_MODE] = 2;
      InstSize[OPCODE_MULT_MATRIX] = 17;
      InstSize[OPCODE_ORTHO] = 7;
      InstSize[OPCODE_PASSTHROUGH] = 2;
      InstSize[OPCODE_PIXEL_MAP] = 4;
      InstSize[OPCODE_PIXEL_TRANSFER] = 3;
      InstSize[OPCODE_PIXEL_ZOOM] = 3;
      InstSize[OPCODE_POINT_SIZE] = 2;
      InstSize[OPCODE_POINT_PARAMETERS] = 5;
      InstSize[OPCODE_POLYGON_MODE] = 3;
      InstSize[OPCODE_POLYGON_STIPPLE] = 2;
      InstSize[OPCODE_POLYGON_OFFSET] = 3;
      InstSize[OPCODE_POP_ATTRIB] = 1;
      InstSize[OPCODE_POP_MATRIX] = 1;
      InstSize[OPCODE_POP_NAME] = 1;
      InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
      InstSize[OPCODE_PUSH_ATTRIB] = 2;
      InstSize[OPCODE_PUSH_MATRIX] = 1;
      InstSize[OPCODE_PUSH_NAME] = 2;
      InstSize[OPCODE_RASTER_POS] = 5;
      InstSize[OPCODE_RECTF] = 5;
      InstSize[OPCODE_READ_BUFFER] = 2;
      InstSize[OPCODE_SCALE] = 4;
      InstSize[OPCODE_SCISSOR] = 5;
      InstSize[OPCODE_STENCIL_FUNC] = 4;
      InstSize[OPCODE_STENCIL_MASK] = 2;
      InstSize[OPCODE_STENCIL_OP] = 4;
      InstSize[OPCODE_SHADE_MODEL] = 2;
      InstSize[OPCODE_TEXENV] = 7;
      InstSize[OPCODE_TEXGEN] = 7;
      InstSize[OPCODE_TEXPARAMETER] = 7;
      InstSize[OPCODE_TEX_IMAGE1D] = 9;
      InstSize[OPCODE_TEX_IMAGE2D] = 10;
      InstSize[OPCODE_TEX_IMAGE3D] = 11;
      InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
      InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
      InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
      InstSize[OPCODE_TRANSLATE] = 4;
      InstSize[OPCODE_VIEWPORT] = 5;
      InstSize[OPCODE_WINDOW_POS] = 5;
      InstSize[OPCODE_CONTINUE] = 2;
      InstSize[OPCODE_ERROR] = 3;
      InstSize[OPCODE_VERTEX_CASSETTE] = 2;
      InstSize[OPCODE_END_OF_LIST] = 1;
      /* GL_ARB_multitexture */
      InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
      InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
   }
   init_flag = 1;
}


/*
 * Display List compilation functions
 */



static void save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
   if (n) {
      n[1].e = op;
      n[2].f = value;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Accum)( ctx, op, value );
   }
}


static void save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
   if (n) {
      n[1].e = func;
      n[2].f = (GLfloat) ref;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.AlphaFunc)( ctx, func, ref );
   }
}

static void save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
   if (n) {
      n[1].e = target;
      n[2].ui = texture;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.BindTexture)( ctx, target, texture );
   }
}


static void save_Bitmap( GLcontext *ctx,
                         GLsizei width, GLsizei height,
                         GLfloat xorig, GLfloat yorig,
                         GLfloat xmove, GLfloat ymove,
                         const GLubyte *bitmap,
                         const struct gl_pixelstore_attrib *packing )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
   if (n) {
      struct gl_image *image = gl_unpack_bitmap( ctx, width, height,
                                                 bitmap, packing );
      if (image) {
         image->RefCount = 1;
      }
      n[1].i = (GLint) width;
      n[2].i = (GLint) height;
      n[3].f = xorig;
      n[4].f = yorig;
      n[5].f = xmove;
      n[6].f = ymove;
      n[7].data = (void *) image;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Bitmap)( ctx, width, height,
                           xorig, yorig, xmove, ymove, bitmap, packing );
   }
}


static void save_BlendEquation( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.BlendEquation)( ctx, mode );
   }
}


static void save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
   if (n) {
      n[1].e = sfactor;
      n[2].e = dfactor;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor );
   }
}


static void save_BlendFuncSeparate( GLcontext *ctx,
                                GLenum sfactorRGB, GLenum dfactorRGB,
                                GLenum sfactorA, GLenum dfactorA)
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
   if (n) {
      n[1].e = sfactorRGB;
      n[2].e = dfactorRGB;
      n[3].e = sfactorA;
      n[4].e = dfactorA;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB,
                                      sfactorA, dfactorA);
   }
}


static void save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green,
                         GLfloat blue, GLfloat alpha )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
   if (n) {
      n[1].f = red;
      n[2].f = green;
      n[3].f = blue;
      n[4].f = alpha;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.BlendColor)( ctx, red, green, blue, alpha );
   }
}


static void save_CallList( GLcontext *ctx, GLuint list )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
   if (n) {
      n[1].ui = list;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CallList)( ctx, list );
   }
}


static void save_CallLists( GLcontext *ctx,
                        GLsizei n, GLenum type, const GLvoid *lists )
{
   GLint i;
   FLUSH_VB(ctx, "dlist");

   for (i=0;i<n;i++) {
      GLuint list = translate_id( i, type, lists );
      Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
      if (n) {
         n[1].ui = list;
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CallLists)( ctx, n, type, lists );
   }
}


static void save_Clear( GLcontext *ctx, GLbitfield mask )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
   if (n) {
      n[1].bf = mask;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Clear)( ctx, mask );
   }
}


static void save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
			 GLfloat blue, GLfloat alpha )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
   if (n) {
      n[1].f = red;
      n[2].f = green;
      n[3].f = blue;
      n[4].f = alpha;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha );
   }
}


static void save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
			 GLclampf blue, GLclampf alpha )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
   if (n) {
      n[1].f = red;
      n[2].f = green;
      n[3].f = blue;
      n[4].f = alpha;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha );
   }
}


static void save_ClearDepth( GLcontext *ctx, GLclampd depth )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
   if (n) {
      n[1].f = (GLfloat) depth;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClearDepth)( ctx, depth );
   }
}


static void save_ClearIndex( GLcontext *ctx, GLfloat c )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
   if (n) {
      n[1].f = c;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClearIndex)( ctx, c );
   }
}


static void save_ClearStencil( GLcontext *ctx, GLint s )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
   if (n) {
      n[1].i = s;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClearStencil)( ctx, s );
   }
}


static void save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   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];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClipPlane)( ctx, plane, equ );
   }
}



static void save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
                        GLboolean blue, GLboolean alpha )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
   if (n) {
      n[1].b = red;
      n[2].b = green;
      n[3].b = blue;
      n[4].b = alpha;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha );
   }
}


static void save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
   if (n) {
      n[1].e = face;
      n[2].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ColorMaterial)( ctx, face, mode );
   }
}


static void save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
                         struct gl_image *table )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
   if (n) {
      n[1].e = target;
      n[2].e = internalFormat;
      n[3].data = (GLvoid *) table;
      if (table) {
         /* must retain this image */
         table->RefCount = 1;
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table );
   }
}


static void save_ColorSubTable( GLcontext *ctx, GLenum target,
                            GLsizei start, struct gl_image *data )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
   if (n) {
      n[1].e = target;
      n[2].i = start;
      n[3].data = (GLvoid *) data;
      if (data) {
         /* must retain this image */
         data->RefCount = 1;
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ColorSubTable)( ctx, target, start, data );
   }
}



static void save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
			 GLsizei width, GLsizei height, GLenum type )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
   if (n) {
      n[1].i = x;
      n[2].i = y;
      n[3].i = (GLint) width;
      n[4].i = (GLint) height;
      n[5].e = type;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type );
   }
}



static void save_CopyTexImage1D( GLcontext *ctx,
                             GLenum target, GLint level,
                             GLenum internalformat,
                             GLint x, GLint y, GLsizei width,
                             GLint border )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].e = internalformat;
      n[4].i = x;
      n[5].i = y;
      n[6].i = width;
      n[7].i = border;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat,
                            x, y, width, border );
   }
}


static void save_CopyTexImage2D( GLcontext *ctx,
                             GLenum target, GLint level,
                             GLenum internalformat,
                             GLint x, GLint y, GLsizei width,
                             GLsizei height, GLint border )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].e = internalformat;
      n[4].i = x;
      n[5].i = y;
      n[6].i = width;
      n[7].i = height;
      n[8].i = border;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat,
                            x, y, width, height, border );
   }
}



static void save_CopyTexSubImage1D( GLcontext *ctx,
                                GLenum target, GLint level,
                                GLint xoffset, GLint x, GLint y,
                                GLsizei width )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = xoffset;
      n[4].i = x;
      n[5].i = y;
      n[6].i = width;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width );
   }
}


static void save_CopyTexSubImage2D( GLcontext *ctx,
                                GLenum target, GLint level,
                                GLint xoffset, GLint yoffset,
                                GLint x, GLint y,
                                GLsizei width, GLint height )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = xoffset;
      n[4].i = yoffset;
      n[5].i = x;
      n[6].i = y;
      n[7].i = width;
      n[8].i = height;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset,
                               x, y, width, height );
   }
}


static void save_CopyTexSubImage3DEXT( GLcontext *ctx,
                                   GLenum target, GLint level,
                                   GLint xoffset, GLint yoffset, GLint zoffset,
                                   GLint x, GLint y,
                                   GLsizei width, GLint height )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = xoffset;
      n[4].i = yoffset;
      n[5].i = zoffset;
      n[6].i = x;
      n[7].i = y;
      n[8].i = width;
      n[9].i = height;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CopyTexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
                               x, y, width, height );
   }
}


static void save_CullFace( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.CullFace)( ctx, mode );
   }
}


static void save_DepthFunc( GLcontext *ctx, GLenum func )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
   if (n) {
      n[1].e = func;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.DepthFunc)( ctx, func );
   }
}


static void save_DepthMask( GLcontext *ctx, GLboolean mask )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
   if (n) {
      n[1].b = mask;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.DepthMask)( ctx, mask );
   }
}


static void save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
   if (n) {
      n[1].f = (GLfloat) nearval;
      n[2].f = (GLfloat) farval;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.DepthRange)( ctx, nearval, farval );
   }
}


static void save_Disable( GLcontext *ctx, GLenum cap )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
   if (n) {
      n[1].e = cap;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Disable)( ctx, cap );
   }
}


static void save_DrawBuffer( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.DrawBuffer)( ctx, mode );
   }
}


static void save_DrawPixels( GLcontext *ctx, struct gl_image *image )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 1 );
   if (n) {
      n[1].data = (GLvoid *) image;
   }
   if (image) {
      image->RefCount = 1;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.DrawPixels)( ctx, image );
   }
}



static void save_Enable( GLcontext *ctx, GLenum cap )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
   if (n) {
      n[1].e = cap;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Enable)( ctx, cap );
   }
}



static void save_EvalMesh1( GLcontext *ctx,
                        GLenum mode, GLint i1, GLint i2 )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
   if (n) {
      n[1].e = mode;
      n[2].i = i1;
      n[3].i = i2;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 );
   }
}


static void save_EvalMesh2( GLcontext *ctx, 
                        GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
   if (n) {
      n[1].e = mode;
      n[2].i = i1;
      n[3].i = i2;
      n[4].i = j1;
      n[5].i = j2;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 );
   }
}




static void save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_FOG, 5 );
   if (n) {
      n[1].e = pname;
      n[2].f = params[0];
      n[3].f = params[1];
      n[4].f = params[2];
      n[5].f = params[3];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Fogfv)( ctx, pname, params );
   }
}


static void save_FrontFace( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.FrontFace)( ctx, mode );
   }
}


static void save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
                      GLdouble bottom, GLdouble top,
                      GLdouble nearval, GLdouble farval )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   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;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval );
   }
}


static GLboolean save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_HINT, 2 );
   if (n) {
      n[1].e = target;
      n[2].e = mode;
   }
   if (ctx->ExecuteFlag) {
      return (*ctx->Exec.Hint)( ctx, target, mode );
   }
   return GL_TRUE;		/* not queried */
}



static void save_IndexMask( GLcontext *ctx, GLuint mask )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
   if (n) {
      n[1].ui = mask;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.IndexMask)( ctx, mask );
   }
}


static void save_InitNames( GLcontext *ctx )
{
   FLUSH_VB(ctx, "dlist");
   (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.InitNames)( ctx );
   }
}


static void save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
                      const GLfloat *params, GLint numparams )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
   if (OPCODE_LIGHT) {
      GLint i;
      n[1].e = light;
      n[2].e = pname;
      for (i=0;i<numparams;i++) {
	 n[3+i].f = params[i];
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams );
   }
}


static void save_LightModelfv( GLcontext *ctx,
                           GLenum pname, const GLfloat *params )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
   if (n) {
      n[1].e = pname;
      n[2].f = params[0];
      n[3].f = params[1];
      n[4].f = params[2];
      n[5].f = params[3];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LightModelfv)( ctx, pname, params );
   }
}


static void save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
   if (n) {
      n[1].i = factor;
      n[2].us = pattern;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LineStipple)( ctx, factor, pattern );
   }
}


static void save_LineWidth( GLcontext *ctx, GLfloat width )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
   if (n) {
      n[1].f = width;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LineWidth)( ctx, width );
   }
}


static void save_ListBase( GLcontext *ctx, GLuint base )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
   if (n) {
      n[1].ui = base;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ListBase)( ctx, base );
   }
}


static void save_LoadIdentity( GLcontext *ctx )
{
   FLUSH_VB(ctx, "dlist");
   (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LoadIdentity)( ctx );
   }
}


static void save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
   if (n) {
      GLuint i;
      for (i=0;i<16;i++) {
	 n[1+i].f = m[i];
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LoadMatrixf)( ctx, m );
   }
}


static void save_LoadName( GLcontext *ctx, GLuint name )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
   if (n) {
      n[1].ui = name;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LoadName)( ctx, name );
   }
}


static void save_LogicOp( GLcontext *ctx, GLenum opcode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
   if (n) {
      n[1].e = opcode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.LogicOp)( ctx, opcode );
   }
}


static void save_Map1f( GLcontext *ctx,
                   GLenum target, GLfloat u1, GLfloat u2, GLint stride,
		   GLint order, const GLfloat *points, GLboolean retain )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
   if (n) {
      n[1].e = target;
      n[2].f = u1;
      n[3].f = u2;
      n[4].i = stride;
      n[5].i = order;
      n[6].data = (void *) points;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE );
   }
   (void) retain;
}


static void save_Map2f( GLcontext *ctx, GLenum target,
                    GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
                    GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
                    const GLfloat *points, GLboolean retain )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
   if (n) {
      n[1].e = target;
      n[2].f = u1;
      n[3].f = u2;
      n[4].f = v1;
      n[5].f = v2;
      n[6].i = ustride;
      n[7].i = vstride;
      n[8].i = uorder;
      n[9].i = vorder;
      n[10].data = (void *) points;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Map2f)( ctx, target,
                        u1, u2, ustride, uorder,
                        v1, v2, vstride, vorder, points, GL_TRUE );
   }
   (void) retain;
}


static void save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
   if (n) {
      n[1].i = un;
      n[2].f = u1;
      n[3].f = u2;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 );
   }
}


static void save_MapGrid2f( GLcontext *ctx, 
                        GLint un, GLfloat u1, GLfloat u2,
		        GLint vn, GLfloat v1, GLfloat v2 )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
   if (n) {
      n[1].i = un;
      n[2].f = u1;
      n[3].f = u2;
      n[4].i = vn;
      n[5].f = v1;
      n[6].f = v2;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 );
   }
}


static void save_MatrixMode( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.MatrixMode)( ctx, mode );
   }
}


static void save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
   if (n) {
      GLuint i;
      for (i=0;i<16;i++) {
	 n[1+i].f = m[i];
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.MultMatrixf)( ctx, m );
   }
}


static void save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
{
   /* It's an error to call this function while building a display list */
   gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
   (void) list;
   (void) mode;
}



static void save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
                    GLdouble bottom, GLdouble top,
                    GLdouble nearval, GLdouble farval )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   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;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval );
   }
}


static void save_PixelMapfv( GLcontext *ctx,
                         GLenum map, GLint mapsize, const GLfloat *values )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
   if (n) {
      n[1].e = map;
      n[2].i = mapsize;
      n[3].data  = (void *) malloc( mapsize * sizeof(GLfloat) );
      MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values );
   }
}


static void save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
   if (n) {
      n[1].e = pname;
      n[2].f = param;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PixelTransferf)( ctx, pname, param );
   }
}


static void save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
   if (n) {
      n[1].f = xfactor;
      n[2].f = yfactor;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor );
   }
}


static void save_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
                                  const GLfloat *params)
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
   if (n) {
      n[1].e = pname;
      n[2].f = params[0];
      n[3].f = params[1];
      n[4].f = params[2];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PointParameterfvEXT)( ctx, pname, params );
   }
}


static void save_PointSize( GLcontext *ctx, GLfloat size )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
   if (n) {
      n[1].f = size;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PointSize)( ctx, size );
   }
}


static void save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
   if (n) {
      n[1].e = face;
      n[2].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PolygonMode)( ctx, face, mode );
   }
}


/*
 * Polygon stipple must have been upacked already!
 */
static void save_PolygonStipple( GLcontext *ctx, const GLuint *pattern )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
   if (n) {
      void *data;
      n[1].data = malloc( 32 * 4 );
      data = n[1].data;   /* This needed for Acorn compiler */
      MEMCPY( data, pattern, 32 * 4 );
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PolygonStipple)( ctx, pattern );
   }
}


static void save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
   if (n) {
      n[1].f = factor;
      n[2].f = units;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PolygonOffset)( ctx, factor, units );
   }
}


static void save_PopAttrib( GLcontext *ctx )
{
   FLUSH_VB(ctx, "dlist");
   (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PopAttrib)( ctx );
   }
}


static void save_PopMatrix( GLcontext *ctx )
{
   FLUSH_VB(ctx, "dlist");
   (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PopMatrix)( ctx );
   }
}


static void save_PopName( GLcontext *ctx )
{
   FLUSH_VB(ctx, "dlist");
   (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PopName)( ctx );
   }
}


static void save_PrioritizeTextures( GLcontext *ctx,
                                 GLsizei num, const GLuint *textures,
                                 const GLclampf *priorities )
{
   GLint i;
   FLUSH_VB(ctx, "dlist");

   for (i=0;i<num;i++) {
      Node *n;
      n = alloc_instruction( ctx,  OPCODE_PRIORITIZE_TEXTURE, 2 );
      if (n) {
         n[1].ui = textures[i];
         n[2].f = priorities[i];
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities );
   }
}


static void save_PushAttrib( GLcontext *ctx, GLbitfield mask )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
   if (n) {
      n[1].bf = mask;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PushAttrib)( ctx, mask );
   }
}


static void save_PushMatrix( GLcontext *ctx )
{
   FLUSH_VB(ctx, "dlist");
   (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PushMatrix)( ctx );
   }
}


static void save_PushName( GLcontext *ctx, GLuint name )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
   if (n) {
      n[1].ui = name;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PushName)( ctx, name );
   }
}


static void save_RasterPos4f( GLcontext *ctx,
                          GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
      n[3].f = z;
      n[4].f = w;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w );
   }
}


static void save_PassThrough( GLcontext *ctx, GLfloat token )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
   if (n) {
      n[1].f = token;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.PassThrough)( ctx, token );
   }
}


static void save_ReadBuffer( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ReadBuffer)( ctx, mode );
   }
}


static void save_Rectf( GLcontext *ctx,
                    GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
   if (n) {
      n[1].f = x1;
      n[2].f = y1;
      n[3].f = x2;
      n[4].f = y2;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 );
   }
}


static void save_Rotatef( GLcontext *ctx, GLfloat angle,
                      GLfloat x, GLfloat y, GLfloat z )
{
   GLfloat m[16];
   gl_rotation_matrix( angle, x, y, z, m );
   save_MultMatrixf( ctx, m );  /* save and maybe execute */
}


static void save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
      n[3].f = z;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Scalef)( ctx, x, y, z );
   }
}


static void save_Scissor( GLcontext *ctx,
                      GLint x, GLint y, GLsizei width, GLsizei height )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
   if (n) {
      n[1].i = x;
      n[2].i = y;
      n[3].i = width;
      n[4].i = height;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Scissor)( ctx, x, y, width, height );
   }
}


static void save_ShadeModel( GLcontext *ctx, GLenum mode )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ShadeModel)( ctx, mode );
   }
}


static void save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
   if (n) {
      n[1].e = func;
      n[2].i = ref;
      n[3].ui = mask;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.StencilFunc)( ctx, func, ref, mask );
   }
}


static void save_StencilMask( GLcontext *ctx, GLuint mask )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
   if (n) {
      n[1].ui = mask;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.StencilMask)( ctx, mask );
   }
}


static void save_StencilOp( GLcontext *ctx,
                        GLenum fail, GLenum zfail, GLenum zpass )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
   if (n) {
      n[1].e = fail;
      n[2].e = zfail;
      n[3].e = zpass;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass );
   }
}




static void save_TexEnvfv( GLcontext *ctx,
                       GLenum target, GLenum pname, const GLfloat *params )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
   if (n) {
      n[1].e = target;
      n[2].e = pname;
      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.TexEnvfv)( ctx, target, pname, params );
   }
}


static void save_TexGenfv( GLcontext *ctx,
                       GLenum coord, GLenum pname, const GLfloat *params )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
   if (n) {
      n[1].e = coord;
      n[2].e = pname;
      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.TexGenfv)( ctx, coord, pname, params );
   }
}


static void save_TexParameterfv( GLcontext *ctx, GLenum target,
                             GLenum pname, const GLfloat *params )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
   if (n) {
      n[1].e = target;
      n[2].e = pname;
      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.TexParameterfv)( ctx, target, pname, params );
   }
}


static void save_TexImage1D( GLcontext *ctx, GLenum target,
                         GLint level, GLint components,
			 GLsizei width, GLint border,
                         GLenum format, GLenum type,
			 struct gl_image *teximage )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = components;
      n[4].i = (GLint) width;
      n[5].i = border;
      n[6].e = format;
      n[7].e = type;
      n[8].data = teximage;
      if (teximage) {
         /* this prevents gl_TexImage2D() from freeing the image */
         teximage->RefCount = 1;
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
                        border, format, type, teximage );
   }
}


static void save_TexImage2D( GLcontext *ctx, GLenum target,
                         GLint level, GLint components,
			 GLsizei width, GLsizei height, GLint border,
                         GLenum format, GLenum type,
			 struct gl_image *teximage )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = components;
      n[4].i = (GLint) width;
      n[5].i = (GLint) height;
      n[6].i = border;
      n[7].e = format;
      n[8].e = type;
      n[9].data = teximage;
      if (teximage) {
         /* this prevents gl_TexImage2D() from freeing the image */
         teximage->RefCount = 1;
      }
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
                        height, border, format, type, teximage );
   }
}


static void save_TexImage3DEXT( GLcontext *ctx, GLenum target,
                            GLint level, GLint components,
                            GLsizei width, GLsizei height, GLsizei depth,
                            GLint border,
                            GLenum format, GLenum type,
                            struct gl_image *teximage )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = components;
      n[4].i = (GLint) width;
      n[5].i = (GLint) height;
      n[6].i = (GLint) depth; 
      n[7].i = border;
      n[8].e = format;
      n[9].e = type;
      n[10].data = teximage;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexImage3DEXT)( ctx, target, level, components, width,
                           height, depth, border, format, type, teximage );
   }
}


static void save_TexSubImage1D( GLcontext *ctx,
                            GLenum target, GLint level, GLint xoffset,
                            GLsizei width, GLenum format, GLenum type,
                            struct gl_image *image )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = xoffset;
      n[4].i = (GLint) width;
      n[5].e = format;
      n[6].e = type;
      n[7].data = image;
      if (image)
         image->RefCount = 1;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width,
                           format, type, image );
   }
}


static void save_TexSubImage2D( GLcontext *ctx,
                            GLenum target, GLint level,
                            GLint xoffset, GLint yoffset,
                            GLsizei width, GLsizei height,
                            GLenum format, GLenum type,
                            struct gl_image *image )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = xoffset;
      n[4].i = yoffset;
      n[5].i = (GLint) width;
      n[6].i = (GLint) height;
      n[7].e = format;
      n[8].e = type;
      n[9].data = image;
      if (image)
         image->RefCount = 1;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset,
                           width, height, format, type, image );
   }
}


static void save_TexSubImage3DEXT( GLcontext *ctx,
                               GLenum target, GLint level,
                               GLint xoffset, GLint yoffset,GLint zoffset,
                               GLsizei width, GLsizei height, GLsizei depth,
                               GLenum format, GLenum type,
                               struct gl_image *image )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
   if (n) {
      n[1].e = target;
      n[2].i = level;
      n[3].i = xoffset;
      n[4].i = yoffset;
      n[5].i = zoffset;
      n[6].i = (GLint) width;
      n[7].i = (GLint) height;
      n[8].i = (GLint) depth;
      n[9].e = format;
      n[10].e = type;
      n[11].data = image;
      if (image)
         image->RefCount = 1;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
                              width, height, depth, format, type, image );
   }
}


static void save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx,  OPCODE_TRANSLATE, 3 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
      n[3].f = z;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Translatef)( ctx, x, y, z );
   }
}



static void save_Viewport( GLcontext *ctx,
                       GLint x, GLint y, GLsizei width, GLsizei height )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx,  OPCODE_VIEWPORT, 4 );
   if (n) {
      n[1].i = x;
      n[2].i = y;
      n[3].i = (GLint) width;
      n[4].i = (GLint) height;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Viewport)( ctx, x, y, width, height );
   }
}


static void save_WindowPos4fMESA( GLcontext *ctx,
                              GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx,  OPCODE_WINDOW_POS, 4 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
      n[3].f = z;
      n[4].f = w;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.WindowPos4fMESA)( ctx, x, y, z, w );
   }
}






/* GL_ARB_multitexture */
static void save_ActiveTexture( GLcontext *ctx, GLenum target )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
   if (n) {
      n[1].e = target;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ActiveTexture)( ctx, target );
   }
}


/* GL_ARB_multitexture */
static void save_ClientActiveTexture( GLcontext *ctx, GLenum target )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
   if (n) {
      n[1].e = target;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.ClientActiveTexture)( ctx, target );
   }
}





void gl_compile_cassette( GLcontext *ctx )
{
   Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 1 );
   struct immediate *new_im = gl_immediate_alloc(ctx);
   struct immediate *im = ctx->input;
   
   if (!n || !new_im) {
      if (n) free(n);
      if (new_im) gl_immediate_free(new_im);
      return;
   }

   /* Do some easy optimizations of the cassette.  If current value of
    * clip volume hint is GL_FASTEST, we are not clipping anyway, so
    * don't calculate the bounds.  But - they will not be calculated
    * later even if the hint is changed, so this is a slightly odd
    * behaviour.
    */
   if (ctx->Hint.ClipVolumeClipping != GL_FASTEST &&
       im->v.Obj.size < 4 && 
       im->Count > 15)
   {
      im->Bounds = (GLfloat (*)[3]) malloc(6 * sizeof(GLfloat));
      (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj );
   }


   n[1].data = (void *)im;   
   SET_IMMEDIATE( ctx, new_im );
}

/* 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 )
{
   Node *n;
   n = alloc_instruction( ctx, OPCODE_ERROR, 2 );
   if (n) {
      n[1].e = error;
      n[2].data = (void *) s;
   }
   /* execute already done */
}

/**********************************************************************/
/*                     Display list execution                         */
/**********************************************************************/


/*
 * Execute a display list.  Note that the ListBase offset must have already
 * been added before calling this function.  I.e. the list argument is
 * the absolute list number, not relative to ListBase.
 * Input:  list - display list number
 */
static void execute_list( GLcontext *ctx, GLuint list )
{
   Node *n;
   GLboolean done;
   OpCode opcode;

   if (!gl_IsList(ctx,list))
      return;

/*    mesa_print_display_list( list ); */

   ctx->CallDepth++;

   n = (Node *) HashLookup(ctx->Shared->DisplayList, list);

   done = GL_FALSE;
   while (!done) {
      opcode = n[0].opcode;

      switch (opcode) {
         case OPCODE_ERROR:
 	    gl_error( ctx, n[1].e, (const char *) n[2].data ); 
            break;
         case OPCODE_VERTEX_CASSETTE:
	    if (ctx->NewState)
	       gl_update_state(ctx);
	    if (!ctx->CVA.elt.pipeline_valid)
	       gl_build_immediate_pipeline( ctx );
	    gl_fixup_cassette( ctx, (struct immediate *) n[1].data ); 
	    gl_execute_cassette( ctx, (struct immediate *) n[1].data ); 
            break;
         case OPCODE_ACCUM:
	    gl_Accum( ctx, n[1].e, n[2].f );
	    break;
         case OPCODE_ALPHA_FUNC:
	    gl_AlphaFunc( ctx, n[1].e, n[2].f );
	    break;
         case OPCODE_BIND_TEXTURE:
            gl_BindTexture( ctx, n[1].e, n[2].ui );
            break;
	 case OPCODE_BITMAP:
            {
               static struct gl_pixelstore_attrib defaultPacking = {
                  1,            /* Alignment */
                  0,            /* RowLength */
                  0,            /* SkipPixels */
                  0,            /* SkipRows */
                  0,            /* ImageHeight */
                  0,            /* SkipImages */
                  GL_FALSE,     /* SwapBytes */
                  GL_FALSE      /* LsbFirst */
               };
               const struct gl_image *image = (struct gl_image *) n[7].data;
               const GLubyte *bitmap = image ? image->Data : NULL;
               gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
                          n[3].f, n[4].f, n[5].f, n[6].f,
                          bitmap, &defaultPacking );
            }
	    break;
	 case OPCODE_BLEND_COLOR:
	    gl_BlendColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
	    break;
	 case OPCODE_BLEND_EQUATION:
	    gl_BlendEquation( ctx, n[1].e );
	    break;
	 case OPCODE_BLEND_FUNC:
	    gl_BlendFunc( ctx, n[1].e, n[2].e );
	    break;
	 case OPCODE_BLEND_FUNC_SEPARATE:
	    gl_BlendFuncSeparate( ctx, n[1].e, n[2].e, n[3].e, n[4].e );
	    break;
         case OPCODE_CALL_LIST:
	    /* Generated by glCallList(), don't add ListBase */
            if (ctx->CallDepth<MAX_LIST_NESTING) {
               execute_list( ctx, n[1].ui );
            }
            break;
         case OPCODE_CALL_LIST_OFFSET:
	    /* Generated by glCallLists() so we must add ListBase */
            if (ctx->CallDepth<MAX_LIST_NESTING) {
               execute_list( ctx, ctx->List.ListBase + n[1].ui );
            }
            break;
	 case OPCODE_CLEAR:
	    gl_Clear( ctx, n[1].bf );
	    break;
	 case OPCODE_CLEAR_COLOR:
	    gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
	    break;
	 case OPCODE_CLEAR_ACCUM:
	    gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
	    break;
	 case OPCODE_CLEAR_DEPTH:
	    gl_ClearDepth( ctx, (GLclampd) n[1].f );
	    break;
	 case OPCODE_CLEAR_INDEX:
	    gl_ClearIndex( ctx, n[1].ui );
	    break;
	 case OPCODE_CLEAR_STENCIL:
	    gl_ClearStencil( ctx, n[1].i );
	    break;
         case OPCODE_CLIP_PLANE:
            {
               GLfloat equ[4];
               equ[0] = n[2].f;
               equ[1] = n[3].f;
               equ[2] = n[4].f;
               equ[3] = n[5].f;
               gl_ClipPlane( ctx, n[1].e, equ );
            }
            break;
	 case OPCODE_COLOR_MASK:
	    gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b );
	    break;
	 case OPCODE_COLOR_MATERIAL:
	    gl_ColorMaterial( ctx, n[1].e, n[2].e );
	    break;
         case OPCODE_COLOR_TABLE:
            gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data);
            break;
         case OPCODE_COLOR_SUB_TABLE:
            gl_ColorSubTable( ctx, n[1].e, n[2].i,
                              (struct gl_image *) n[3].data);
            break;
	 case OPCODE_COPY_PIXELS:
	    gl_CopyPixels( ctx, n[1].i, n[2].i,
			   (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
	    break;
         case OPCODE_COPY_TEX_IMAGE1D:
	    gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
                               n[5].i, n[6].i, n[7].i );
            break;
         case OPCODE_COPY_TEX_IMAGE2D:
	    gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
                               n[5].i, n[6].i, n[7].i, n[8].i );
            break;
         case OPCODE_COPY_TEX_SUB_IMAGE1D:
	    gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
                                  n[5].i, n[6].i );
            break;
         case OPCODE_COPY_TEX_SUB_IMAGE2D:
	    gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
                                  n[5].i, n[6].i, n[7].i, n[8].i );
            break;
         case OPCODE_COPY_TEX_SUB_IMAGE3D:
            gl_CopyTexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
                                     n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
            break;
	 case OPCODE_CULL_FACE:
	    gl_CullFace( ctx, n[1].e );
	    break;
	 case OPCODE_DEPTH_FUNC:
	    gl_DepthFunc( ctx, n[1].e );
	    break;
	 case OPCODE_DEPTH_MASK:
	    gl_DepthMask( ctx, n[1].b );
	    break;
	 case OPCODE_DEPTH_RANGE:
	    gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f );
	    break;
	 case OPCODE_DISABLE:
	    gl_Disable( ctx, n[1].e );
	    break;
	 case OPCODE_DRAW_BUFFER:
	    gl_DrawBuffer( ctx, n[1].e );
	    break;
	 case OPCODE_DRAW_PIXELS:
	    gl_DrawPixels( ctx, (struct gl_image *) n[1].data );
	    break;
	 case OPCODE_ENABLE:
	    gl_Enable( ctx, n[1].e );
	    break;
	 case OPCODE_EVALMESH1:
	    gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i );
	    break;
	 case OPCODE_EVALMESH2:
	    gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
	    break;
	 case OPCODE_FOG:
	    {
	       GLfloat p[4];
	       p[0] = n[2].f;
	       p[1] = n[3].f;
	       p[2] = n[4].f;
	       p[3] = n[5].f;
	       gl_Fogfv( ctx, n[1].e, p );
	    }
	    break;
	 case OPCODE_FRONT_FACE:
	    gl_FrontFace( ctx, n[1].e );
	    break;
         case OPCODE_FRUSTUM:
            gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
            break;
	 case OPCODE_HINT:
	    gl_Hint( ctx, n[1].e, n[2].e );
	    break;
	 case OPCODE_INDEX_MASK:
	    gl_IndexMask( ctx, n[1].ui );
	    break;
	 case OPCODE_INIT_NAMES:
	    gl_InitNames( ctx );
	    break;
         case OPCODE_LIGHT:
	    {
	       GLfloat p[4];
	       p[0] = n[3].f;
	       p[1] = n[4].f;
	       p[2] = n[5].f;
	       p[3] = n[6].f;
	       gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 );
	    }
	    break;
         case OPCODE_LIGHT_MODEL:
	    {
	       GLfloat p[4];
	       p[0] = n[2].f;
	       p[1] = n[3].f;
	       p[2] = n[4].f;
	       p[3] = n[5].f;
	       gl_LightModelfv( ctx, n[1].e, p );
	    }
	    break;
	 case OPCODE_LINE_STIPPLE:
	    gl_LineStipple( ctx, n[1].i, n[2].us );
	    break;
	 case OPCODE_LINE_WIDTH:
	    gl_LineWidth( ctx, n[1].f );
	    break;
	 case OPCODE_LIST_BASE:
	    gl_ListBase( ctx, n[1].ui );
	    break;
	 case OPCODE_LOAD_IDENTITY:
            gl_LoadIdentity( ctx );
            break;
	 case OPCODE_LOAD_MATRIX:
	    if (sizeof(Node)==sizeof(GLfloat)) {
	       gl_LoadMatrixf( ctx, &n[1].f );
	    }
	    else {
	       GLfloat m[16];
	       GLuint i;
	       for (i=0;i<16;i++) {
		  m[i] = n[1+i].f;
	       }
	       gl_LoadMatrixf( ctx, m );
	    }
	    break;
	 case OPCODE_LOAD_NAME:
	    gl_LoadName( ctx, n[1].ui );
	    break;
	 case OPCODE_LOGIC_OP:
	    gl_LogicOp( ctx, n[1].e );
	    break;
	 case OPCODE_MAP1:
	    gl_Map1f( ctx, n[1].e, n[2].f, n[3].f,
                      n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE );
	    break;
	 case OPCODE_MAP2:
	    gl_Map2f( ctx, n[1].e,
                      n[2].f, n[3].f,  /* u1, u2 */
		      n[6].i, n[8].i,  /* ustride, uorder */
		      n[4].f, n[5].f,  /* v1, v2 */
		      n[7].i, n[9].i,  /* vstride, vorder */
		      (GLfloat *) n[10].data,
                      GL_TRUE);
	    break;
	 case OPCODE_MAPGRID1:
	    gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f );
	    break;
	 case OPCODE_MAPGRID2:
	    gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
	    break;
         case OPCODE_MATRIX_MODE:
            gl_MatrixMode( ctx, n[1].e );
            break;
	 case OPCODE_MULT_MATRIX:
	    if (sizeof(Node)==sizeof(GLfloat)) {
	       gl_MultMatrixf( ctx, &n[1].f );
	    }
	    else {
	       GLfloat m[16];
	       GLuint i;
	       for (i=0;i<16;i++) {
		  m[i] = n[1+i].f;
	       }
	       gl_MultMatrixf( ctx, m );
	    }
	    break;
         case OPCODE_ORTHO:
            gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
            break;
	 case OPCODE_PASSTHROUGH:
	    gl_PassThrough( ctx, n[1].f );
	    break;
	 case OPCODE_PIXEL_MAP:
	    gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data );
	    break;
	 case OPCODE_PIXEL_TRANSFER:
	    gl_PixelTransferf( ctx, n[1].e, n[2].f );
	    break;
	 case OPCODE_PIXEL_ZOOM:
	    gl_PixelZoom( ctx, n[1].f, n[2].f );
	    break;
	 case OPCODE_POINT_SIZE:
	    gl_PointSize( ctx, n[1].f );
	    break;
	 case OPCODE_POINT_PARAMETERS:
	    {
		GLfloat params[3];
		params[0] = n[2].f;
		params[1] = n[3].f;
		params[2] = n[4].f;
		gl_PointParameterfvEXT( ctx, n[1].e, params ); 
	    }
	    break;
	 case OPCODE_POLYGON_MODE:
	    gl_PolygonMode( ctx, n[1].e, n[2].e );
	    break;
	 case OPCODE_POLYGON_STIPPLE:
	    gl_PolygonStipple( ctx, (GLuint *) n[1].data );
	    break;
	 case OPCODE_POLYGON_OFFSET:
	    gl_PolygonOffset( ctx, n[1].f, n[2].f );
	    break;
	 case OPCODE_POP_ATTRIB:
	    gl_PopAttrib( ctx );
	    break;
	 case OPCODE_POP_MATRIX:
	    gl_PopMatrix( ctx );
	    break;
	 case OPCODE_POP_NAME:
	    gl_PopName( ctx );
	    break;
	 case OPCODE_PRIORITIZE_TEXTURE:
            gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f );
	    break;
	 case OPCODE_PUSH_ATTRIB:
	    gl_PushAttrib( ctx, n[1].bf );
	    break;
	 case OPCODE_PUSH_MATRIX:
	    gl_PushMatrix( ctx );
	    break;
	 case OPCODE_PUSH_NAME:
	    gl_PushName( ctx, n[1].ui );
	    break;
	 case OPCODE_RASTER_POS:
            gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
	    break;
	 case OPCODE_READ_BUFFER:
	    gl_ReadBuffer( ctx, n[1].e );
	    break;
         case OPCODE_RECTF:
            gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
            break;
         case OPCODE_SCALE:
            gl_Scalef( ctx, n[1].f, n[2].f, n[3].f );
            break;
	 case OPCODE_SCISSOR:
	    gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i );
	    break;
	 case OPCODE_SHADE_MODEL:
	    gl_ShadeModel( ctx, n[1].e );
	    break;
	 case OPCODE_STENCIL_FUNC:
	    gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui );
	    break;
	 case OPCODE_STENCIL_MASK:
	    gl_StencilMask( ctx, n[1].ui );
	    break;
	 case OPCODE_STENCIL_OP:
	    gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e );
	    break;
         case OPCODE_TEXENV:
            {
               GLfloat params[4];
               params[0] = n[3].f;
               params[1] = n[4].f;
               params[2] = n[5].f;
               params[3] = n[6].f;
               gl_TexEnvfv( ctx, n[1].e, n[2].e, params );
            }
            break;
         case OPCODE_TEXGEN:
            {
               GLfloat params[4];
               params[0] = n[3].f;
               params[1] = n[4].f;
               params[2] = n[5].f;
               params[3] = n[6].f;
               gl_TexGenfv( ctx, n[1].e, n[2].e, params );
            }
            break;
         case OPCODE_TEXPARAMETER:
            {
               GLfloat params[4];
               params[0] = n[3].f;
               params[1] = n[4].f;
               params[2] = n[5].f;
               params[3] = n[6].f;
               gl_TexParameterfv( ctx, n[1].e, n[2].e, params );
            }
            break;
	 case OPCODE_TEX_IMAGE1D:
	    gl_TexImage1D( ctx,
                           n[1].e, /* target */
                           n[2].i, /* level */
                           n[3].i, /* components */
                           n[4].i, /* width */
                           n[5].e, /* border */
                           n[6].e, /* format */
                           n[7].e, /* type */
                           (struct gl_image *) n[8].data );
	    break;
	 case OPCODE_TEX_IMAGE2D:
	    gl_TexImage2D( ctx,
                           n[1].e, /* target */
                           n[2].i, /* level */
                           n[3].i, /* components */
                           n[4].i, /* width */
                           n[5].i, /* height */
                           n[6].e, /* border */
                           n[7].e, /* format */
                           n[8].e, /* type */
                           (struct gl_image *) n[9].data );
	    break;
         case OPCODE_TEX_IMAGE3D:
            gl_TexImage3DEXT( ctx,
                              n[1].e, /* target */
                              n[2].i, /* level */
                              n[3].i, /* components */
                              n[4].i, /* width */
                              n[5].i, /* height */
                              n[6].i, /* depth  */
                              n[7].e, /* border */
                              n[8].e, /* format */
                              n[9].e, /* type */
                              (struct gl_image *) n[10].data );
            break;
         case OPCODE_TEX_SUB_IMAGE1D:
            gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
                              n[6].e, (struct gl_image *) n[7].data );
            break;
         case OPCODE_TEX_SUB_IMAGE2D:
            gl_TexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
                              n[6].i, n[7].e, n[8].e,
                              (struct gl_image *) n[9].data );
            break;
         case OPCODE_TEX_SUB_IMAGE3D:
            gl_TexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i,
                                 n[6].i, n[7].i, n[8].i, n[9].e, n[10].e,
                                 (struct gl_image *) n[11].data );
            break;
         case OPCODE_TRANSLATE:
            gl_Translatef( ctx, n[1].f, n[2].f, n[3].f );
            break;
	 case OPCODE_VIEWPORT:
	    gl_Viewport( ctx,
                         n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
	    break;
	 case OPCODE_WINDOW_POS:
            gl_WindowPos4fMESA( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
	    break;
         case OPCODE_ACTIVE_TEXTURE:  /* GL_ARB_multitexture */
            gl_ActiveTexture( ctx, n[1].e );
            break;
         case OPCODE_CLIENT_ACTIVE_TEXTURE:  /* GL_ARB_multitexture */
            gl_ClientActiveTexture( ctx, n[1].e );
            break;
	 case OPCODE_CONTINUE:
	    n = (Node *) n[1].next;
	    break;
	 case OPCODE_END_OF_LIST:
	    done = GL_TRUE;
	    break;
	 default:
            {
               char msg[1000];
               sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
               gl_problem( ctx, msg );
            }
            done = GL_TRUE;
      }

      /* increment n to point to next compiled command */
      if (opcode!=OPCODE_CONTINUE) {
	 n += InstSize[opcode];
      }

   }
   ctx->CallDepth--;
}





/**********************************************************************/
/*                           GL functions                             */
/**********************************************************************/




/*
 * Test if a display list number is valid.
 */
GLboolean gl_IsList( GLcontext *ctx, GLuint list )
{
   if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) {
      return GL_TRUE;
   }
   else {
      return GL_FALSE;
   }
}



/*
 * Delete a sequence of consecutive display lists.
 */
void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range )
{
   GLuint i;

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists");
   if (range<0) {
      gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
      return;
   }
   for (i=list;i<list+range;i++) {
      gl_destroy_list( ctx, i );
   }
}



/*
 * Return a display list number, n, such that lists n through n+range-1
 * are free.
 */
GLuint gl_GenLists( GLcontext *ctx, GLsizei range )
{
   GLuint base;

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0);
   if (range<0) {
      gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
      return 0;
   }
   if (range==0) {
      return 0;
   }

   base = HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
   if (base) {
      /* reserve the list IDs by with empty/dummy lists */
      GLint i;
      for (i=0; i<range; i++) {
         HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
      }
   }
   return base;
}



/*
 * Begin a new display list.
 */
void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
{
   struct immediate *IM;
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");

   if (MESA_VERBOSE&VERBOSE_API)
      fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));

   if (list==0) {
      gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
      return;
   }

   if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
      gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
      return;
   }

   if (ctx->CurrentListPtr) {
      /* already compiling a display list */
      gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
      return;
   }

   /* Allocate new display list */
   ctx->CurrentListNum = list;
   ctx->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
   ctx->CurrentListPtr = ctx->CurrentBlock;
   ctx->CurrentPos = 0;

   IM = gl_immediate_alloc( ctx );
   SET_IMMEDIATE( ctx, IM );
   gl_reset_input( ctx );

   ctx->CompileFlag = GL_TRUE;
   ctx->CompileCVAFlag = GL_FALSE;
   ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
   ctx->API = ctx->Save;  /* Switch the API function pointers */
}



/*
 * End definition of current display list.
 */
void gl_EndList( GLcontext *ctx )
{
   if (MESA_VERBOSE&VERBOSE_API)
      fprintf(stderr, "glEndList\n");

   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );

   /* Check that a list is under construction */
   if (!ctx->CurrentListPtr) {
      gl_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);
   /* Install the list */
   HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);

   ctx->CurrentListNum = 0;
   ctx->CurrentListPtr = NULL;
   ctx->ExecuteFlag = GL_TRUE;
   ctx->CompileFlag = GL_FALSE;
   /* ctx->CompileCVAFlag = ...; */

   /* KW: Put back the old input pointer.
    */
   free( ctx->input );
   SET_IMMEDIATE( ctx, ctx->VB->IM );

   ctx->API = ctx->Exec;   /* Switch the API function pointers */
}



void gl_CallList( GLcontext *ctx, GLuint list )
{
   /* 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);


   save_compile_flag = ctx->CompileFlag;   
   ctx->CompileFlag = GL_FALSE;
   
   FLUSH_VB( ctx, "call list" );

/*    mesa_print_display_list( list ); */

   execute_list( ctx, list );
   ctx->CompileFlag = save_compile_flag;

   /* also restore API function pointers to point to "save" versions */
   if (save_compile_flag)
           ctx->API = ctx->Save;


/*    RESET_IMMEDIATE( ctx );       */
}



/*
 * Execute glCallLists:  call multiple display lists.
 */
void gl_CallLists( GLcontext *ctx,
                   GLsizei n, GLenum type, const GLvoid *lists )
{
   GLuint list;
   GLint i;
   GLboolean save_compile_flag;

   /* Save the CompileFlag status, turn it off, execute display list,
    * and restore the CompileFlag.
    */
   save_compile_flag = ctx->CompileFlag;
   ctx->CompileFlag = GL_FALSE;

   FLUSH_VB( ctx, "call lists" );

   for (i=0;i<n;i++) {
      list = translate_id( i, type, lists );
      execute_list( ctx, ctx->List.ListBase + list );
   }

   ctx->CompileFlag = save_compile_flag;

   /* also restore API function pointers to point to "save" versions */
   if (save_compile_flag)
           ctx->API = ctx->Save;


/*    RESET_IMMEDIATE( ctx ); */
}



/*
 * Set the offset added to list numbers in glCallLists.
 */
void gl_ListBase( GLcontext *ctx, GLuint base )
{
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase");
   ctx->List.ListBase = base;
}






/*
 * Assign all the pointers in 'table' to point to Mesa's display list
 * building functions.
 */
void gl_init_dlist_pointers( struct gl_api_table *table )
{
   table->Accum = save_Accum;
   table->AlphaFunc = save_AlphaFunc;
   table->AreTexturesResident = gl_AreTexturesResident;
   table->BindTexture = save_BindTexture;
   table->Bitmap = save_Bitmap;
   table->BlendColor = save_BlendColor;
   table->BlendEquation = save_BlendEquation;
   table->BlendFunc = save_BlendFunc;
   table->BlendFuncSeparate = save_BlendFuncSeparate;
   table->CallList = save_CallList;
   table->CallLists = save_CallLists;
   table->Clear = save_Clear;
   table->ClearAccum = save_ClearAccum;
   table->ClearColor = save_ClearColor;
   table->ClearDepth = save_ClearDepth;
   table->ClearIndex = save_ClearIndex;
   table->ClearStencil = save_ClearStencil;
   table->ClipPlane = save_ClipPlane;
   table->ColorMask = save_ColorMask;
   table->ColorMaterial = save_ColorMaterial;
   table->ColorTable = save_ColorTable;
   table->ColorSubTable = save_ColorSubTable;
   table->CopyPixels = save_CopyPixels;
   table->CopyTexImage1D = save_CopyTexImage1D;
   table->CopyTexImage2D = save_CopyTexImage2D;
   table->CopyTexSubImage1D = save_CopyTexSubImage1D;
   table->CopyTexSubImage2D = save_CopyTexSubImage2D;
   table->CopyTexSubImage3DEXT = save_CopyTexSubImage3DEXT;
   table->CullFace = save_CullFace;
   table->DeleteLists = gl_DeleteLists;   /* NOT SAVED */
   table->DeleteTextures = gl_DeleteTextures;  /* NOT SAVED */
   table->DepthFunc = save_DepthFunc;
   table->DepthMask = save_DepthMask;
   table->DepthRange = save_DepthRange;
   table->Disable = save_Disable;
   table->DisableClientState = gl_DisableClientState;  /* NOT SAVED */
   table->DrawBuffer = save_DrawBuffer;
   table->DrawPixels = save_DrawPixels;
   table->Enable = save_Enable;
   table->Error = gl_save_error;
   table->EnableClientState = gl_EnableClientState;   /* NOT SAVED */
   table->EndList = gl_EndList;   /* NOT SAVED */
   table->EvalMesh1 = save_EvalMesh1;
   table->EvalMesh2 = save_EvalMesh2;
   table->FeedbackBuffer = gl_FeedbackBuffer;   /* NOT SAVED */
   table->Finish = gl_Finish;   /* NOT SAVED */
   table->Flush = gl_Flush;   /* NOT SAVED */
   table->Fogfv = save_Fogfv;
   table->FrontFace = save_FrontFace;
   table->Frustum = save_Frustum;
   table->GenLists = gl_GenLists;   /* NOT SAVED */
   table->GenTextures = gl_GenTextures;   /* NOT SAVED */

   /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
   table->GetBooleanv = gl_GetBooleanv;
   table->GetClipPlane = gl_GetClipPlane;
   table->GetColorTable = gl_GetColorTable;
   table->GetColorTableParameteriv = gl_GetColorTableParameteriv;
   table->GetDoublev = gl_GetDoublev;
   table->GetError = gl_GetError;
   table->GetFloatv = gl_GetFloatv;
   table->GetIntegerv = gl_GetIntegerv;
   table->GetString = gl_GetString;
   table->GetLightfv = gl_GetLightfv;
   table->GetLightiv = gl_GetLightiv;
   table->GetMapdv = gl_GetMapdv;
   table->GetMapfv = gl_GetMapfv;
   table->GetMapiv = gl_GetMapiv;
   table->GetMaterialfv = gl_GetMaterialfv;
   table->GetMaterialiv = gl_GetMaterialiv;
   table->GetPixelMapfv = gl_GetPixelMapfv;
   table->GetPixelMapuiv = gl_GetPixelMapuiv;
   table->GetPixelMapusv = gl_GetPixelMapusv;
   table->GetPointerv = gl_GetPointerv;
   table->GetPolygonStipple = gl_GetPolygonStipple;
   table->GetTexEnvfv = gl_GetTexEnvfv;
   table->GetTexEnviv = gl_GetTexEnviv;
   table->GetTexGendv = gl_GetTexGendv;
   table->GetTexGenfv = gl_GetTexGenfv;
   table->GetTexGeniv = gl_GetTexGeniv;
   table->GetTexImage = gl_GetTexImage;
   table->GetTexLevelParameterfv = gl_GetTexLevelParameterfv;
   table->GetTexLevelParameteriv = gl_GetTexLevelParameteriv;
   table->GetTexParameterfv = gl_GetTexParameterfv;
   table->GetTexParameteriv = gl_GetTexParameteriv;

   table->Hint = save_Hint;
   table->IndexMask = save_IndexMask;
   table->InitNames = save_InitNames;
   table->IsEnabled = gl_IsEnabled;   /* NOT SAVED */
   table->IsTexture = gl_IsTexture;   /* NOT SAVED */
   table->IsList = gl_IsList;   /* NOT SAVED */
   table->LightModelfv = save_LightModelfv;
   table->Lightfv = save_Lightfv;
   table->LineStipple = save_LineStipple;
   table->LineWidth = save_LineWidth;
   table->ListBase = save_ListBase;
   table->LoadIdentity = save_LoadIdentity;
   table->LoadMatrixf = save_LoadMatrixf;
   table->LoadName = save_LoadName;
   table->LogicOp = save_LogicOp;
   table->Map1f = save_Map1f;
   table->Map2f = save_Map2f;
   table->MapGrid1f = save_MapGrid1f;
   table->MapGrid2f = save_MapGrid2f;
   table->MatrixMode = save_MatrixMode;
   table->MultMatrixf = save_MultMatrixf;
   table->NewList = save_NewList;
   table->Ortho = save_Ortho;
   table->PointParameterfvEXT = save_PointParameterfvEXT;
   table->PassThrough = save_PassThrough;
   table->PixelMapfv = save_PixelMapfv;
   table->PixelStorei = gl_PixelStorei;   /* NOT SAVED */
   table->PixelTransferf = save_PixelTransferf;
   table->PixelZoom = save_PixelZoom;
   table->PointSize = save_PointSize;
   table->PolygonMode = save_PolygonMode;
   table->PolygonOffset = save_PolygonOffset;
   table->PolygonStipple = save_PolygonStipple;
   table->PopAttrib = save_PopAttrib;
   table->PopClientAttrib = gl_PopClientAttrib;  /* NOT SAVED */
   table->PopMatrix = save_PopMatrix;
   table->PopName = save_PopName;
   table->PrioritizeTextures = save_PrioritizeTextures;
   table->PushAttrib = save_PushAttrib;
   table->PushClientAttrib = gl_PushClientAttrib;  /* NOT SAVED */
   table->PushMatrix = save_PushMatrix;
   table->PushName = save_PushName;
   table->RasterPos4f = save_RasterPos4f;
   table->ReadBuffer = save_ReadBuffer;
   table->ReadPixels = gl_ReadPixels;   /* NOT SAVED */
   table->Rectf = save_Rectf;
   table->RenderMode = gl_RenderMode;   /* NOT SAVED */
   table->Rotatef = save_Rotatef;
   table->Scalef = save_Scalef;
   table->Scissor = save_Scissor;
   table->SelectBuffer = gl_SelectBuffer;   /* NOT SAVED */
   table->ShadeModel = save_ShadeModel;
   table->StencilFunc = save_StencilFunc;
   table->StencilMask = save_StencilMask;
   table->StencilOp = save_StencilOp;
   table->TexEnvfv = save_TexEnvfv;
   table->TexGenfv = save_TexGenfv;
   table->TexImage1D = save_TexImage1D;
   table->TexImage2D = save_TexImage2D;
   table->TexImage3DEXT = save_TexImage3DEXT;
   table->TexSubImage1D = save_TexSubImage1D;
   table->TexSubImage2D = save_TexSubImage2D;
   table->TexSubImage3DEXT = save_TexSubImage3DEXT;
   table->TexParameterfv = save_TexParameterfv;
   table->Translatef = save_Translatef;
   table->Viewport = save_Viewport;

   /* GL_MESA_window_pos extension */
   table->WindowPos4fMESA = save_WindowPos4fMESA;

   /* GL_MESA_resize_buffers extension */
   table->ResizeBuffersMESA = gl_ResizeBuffersMESA;

   /* GL_ARB_multitexture */
   table->ActiveTexture = save_ActiveTexture;
   table->ClientActiveTexture = save_ClientActiveTexture;
}



/***
 *** Debugging code
 ***/
static const char *enum_string( GLenum k )
{
   return gl_lookup_enum_by_nr( k );
}


/*
 * Print the commands in a display list.  For debugging only.
 * TODO: many commands aren't handled yet.
 */
static void print_list( GLcontext *ctx, FILE *f, GLuint list )
{
   Node *n;
   GLboolean done;
   OpCode opcode;

   if (!glIsList(list)) {
      fprintf(f,"%u is not a display list ID\n",list);
      return;
   }

   n = (Node *) HashLookup(ctx->Shared->DisplayList, list);

   fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );

   done = n ? GL_FALSE : GL_TRUE;
   while (!done) {
      opcode = n[0].opcode;

      switch (opcode) {
         case OPCODE_ACCUM:
            fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
	    break;
	 case OPCODE_BITMAP:
            fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
		       n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
	    break;
         case OPCODE_CALL_LIST:
            fprintf(f,"CallList %d\n", (int) n[1].ui );
            break;
         case OPCODE_CALL_LIST_OFFSET:
            fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
                    ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
            break;
	 case OPCODE_DISABLE:
            fprintf(f,"Disable %s\n", enum_string(n[1].e));
	    break;
	 case OPCODE_ENABLE:
            fprintf(f,"Enable %s\n", enum_string(n[1].e));
	    break;
         case OPCODE_FRUSTUM:
            fprintf(f,"Frustum %g %g %g %g %g %g\n",
                    n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
            break;
	 case OPCODE_LINE_STIPPLE:
	    fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
	    break;
	 case OPCODE_LOAD_IDENTITY:
            fprintf(f,"LoadIdentity\n");
	    break;
	 case OPCODE_LOAD_MATRIX:
            fprintf(f,"LoadMatrix\n");
            fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
            fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
            fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
            fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
	    break;
	 case OPCODE_MULT_MATRIX:
            fprintf(f,"MultMatrix (or Rotate)\n");
            fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
            fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
            fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
            fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
	    break;
         case OPCODE_ORTHO:
            fprintf(f,"Ortho %g %g %g %g %g %g\n",
                    n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
            break;
	 case OPCODE_POP_ATTRIB:
            fprintf(f,"PopAttrib\n");
	    break;
	 case OPCODE_POP_MATRIX:
            fprintf(f,"PopMatrix\n");
	    break;
	 case OPCODE_POP_NAME:
            fprintf(f,"PopName\n");
	    break;
	 case OPCODE_PUSH_ATTRIB:
            fprintf(f,"PushAttrib %x\n", n[1].bf );
	    break;
	 case OPCODE_PUSH_MATRIX:
            fprintf(f,"PushMatrix\n");
	    break;
	 case OPCODE_PUSH_NAME:
            fprintf(f,"PushName %d\n", (int) n[1].ui );
	    break;
	 case OPCODE_RASTER_POS:
            fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
	    break;
         case OPCODE_RECTF:
            fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
            break;
         case OPCODE_SCALE:
            fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
            break;
         case OPCODE_TRANSLATE:
            fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
            break;

	 /*
	  * meta opcodes/commands
	  */
         case OPCODE_ERROR:
            fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
            break;
	 case OPCODE_VERTEX_CASSETTE:
            fprintf(f,"VERTEX-CASSETTE, id %u, %u elements\n", 
		    ((struct immediate *) n[1].data)->id,
		    ((struct immediate *) n[1].data)->Count - VB_START );
	    break;
	 case OPCODE_CONTINUE:
            fprintf(f,"DISPLAY-LIST-CONTINUE\n");
	    n = (Node *) n[1].next;
	    break;
	 case OPCODE_END_OF_LIST:
            fprintf(f,"END-LIST %u\n", list);
	    done = GL_TRUE;
	    break;
         default:
            if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
               fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
                       opcode, (void*) n);
               return;
            }
            else {
               fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
            }
      }

      /* increment n to point to next compiled command */
      if (opcode!=OPCODE_CONTINUE) {
	 n += InstSize[opcode];
      }
   }
}








/*
 * Clients may call this function to help debug display list problems.
 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
 * changed, or break in the future without notice.
 */
void mesa_print_display_list( GLuint list )
{
   GET_CONTEXT;
   print_list( CC, stdout, list );
}
@


3.23
log
@silenced IRIX compiler warnings
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.22 1999/07/12 12:05:23 keithw Exp $ */
d655 5
a659 4
                     GLsizei width, GLsizei height,
		     GLfloat xorig, GLfloat yorig,
		     GLfloat xmove, GLfloat ymove,
		     struct gl_image *bitmap )
d665 5
d676 1
a676 4
      n[7].data = (void *) bitmap;
   }
   if (bitmap) {
      bitmap->RefCount = 1;
d680 1
a680 1
                    xorig, yorig, xmove, ymove, bitmap );
d2472 17
a2488 4
	    gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
		       n[3].f, n[4].f,
		       n[5].f, n[6].f,
		       (struct gl_image *) n[7].data );
@


3.22
log
@merge from experimental branch upto merge-1 tag
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.21 1999/06/18 20:03:37 brianp Exp $ */
d64 1
d2992 1
a2992 1
      fprintf(stderr, "glNewList %d %s\n", list, gl_lookup_enum_by_nr(mode));
d3076 1
a3076 1
      fprintf(stderr, "glCallList %d\n", list);
@


3.21
log
@changed hint mode to GLenum
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.20 1999/04/07 22:53:48 brianp Exp $ */
a574 2
      InstSize[OPCODE_SELECT_TEXTURE_SGIS] = 2;
      InstSize[OPCODE_SELECT_TEXTURE_COORD_SET] = 2;
a2333 28
/* GL_SGIS_multitexture */
static void save_SelectTextureSGIS( GLcontext *ctx, GLenum target )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_SGIS, 1 );
   if (n) {
      n[1].e = target;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.SelectTextureSGIS)( ctx, target );
   }
}


/* GL_SGIS_multitexture */
static void save_SelectTextureCoordSet( GLcontext *ctx, GLenum target )
{
   Node *n;
   FLUSH_VB(ctx, "dlist");
   n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_COORD_SET, 1 );
   if (n) {
      n[1].e = target;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.SelectTextureCoordSet)( ctx, target );
   }
}
d2451 4
d2456 1
a2456 3
	    gl_execute_cassette( ctx, 
				 (struct immediate *) n[1].data,
				 PIPE_IMMEDIATE ); 
a2768 6
         case OPCODE_SELECT_TEXTURE_SGIS:
            gl_SelectTextureSGIS( ctx, n[1].e );
            break;
         case OPCODE_SELECT_TEXTURE_COORD_SET:
            gl_SelectTextureCoordSet( ctx, n[1].e );
            break;
d2990 3
d2997 1
d3002 1
d3011 2
a3012 1
   ctx->CurrentListPtr = ctx->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
d3020 2
a3021 14

   if (ctx->CompileCVAFlag) {
      gl_flush_cva( ctx );
      ctx->CompileCVAFlag = GL_FALSE;
   }

   if (mode==GL_COMPILE) {
      ctx->ExecuteFlag = GL_FALSE;
   }
   else {
      /* Compile and execute */
      ctx->ExecuteFlag = GL_TRUE;
   }

d3032 3
d3073 5
a3172 1
   table->ColorPointer = gl_ColorPointer;
a3190 1
   table->EdgeFlagPointer = gl_EdgeFlagPointer;
a3240 1
   table->IndexPointer = gl_IndexPointer;
a3260 1
   table->NormalPointer = gl_NormalPointer;  /* NOT SAVED */
a3293 1
   table->TexCoordPointer = gl_TexCoordPointer;  /* NOT SAVED */
a3303 1
   table->VertexPointer = gl_VertexPointer;  /* NOT SAVED */
a3310 6

   /* GL_SGIS_multitexture */
   table->MultiTexCoordPointer = gl_MultiTexCoordPointer;   /* NOT SAVED */
   table->InterleavedTextureCoordSets = gl_InterleavedTextureCoordSets;  /* NOT SAVED */
   table->SelectTextureSGIS = save_SelectTextureSGIS;
   table->SelectTextureCoordSet = save_SelectTextureCoordSet;
@


3.20
log
@silenced printf type warnings on IRIX
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.19 1999/03/31 20:18:38 keithw Exp $ */
d1326 1
a1326 1
static GLboolean save_Hint( GLcontext *ctx, GLenum target, GLint mode )
d1333 1
a1333 1
      n[2].i = mode;
@


3.20.2.1
log
@Quake3 inspired optimizations
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.20 1999/04/07 22:53:48 brianp Exp $ */
a2480 2
	    if (!ctx->CVA.elt.pipeline_valid)
	       gl_build_immediate_pipeline( ctx );
d2482 3
a2484 1
	    gl_execute_cassette( ctx, (struct immediate *) n[1].data ); 
@


3.20.2.2
log
@some trial assembly, made newer code active by default
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.20.2.1 1999/05/21 21:29:25 keithw Exp $ */
d3205 1
d3330 1
d3341 1
@


3.20.2.3
log
@Removed SGIS multitexture, added FX/X86 assm directory
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.20.2.2 1999/06/06 22:35:53 keithw Exp $ */
d575 2
d2336 28
d2797 6
d3223 1
d3274 1
d3295 1
d3346 6
@


3.19
log
@Compiled vertex arrays
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.18 1999/03/20 18:56:47 brianp Exp $ */
d3383 1
a3383 1
      fprintf(f,"%d is not a display list ID\n",list);
d3389 1
a3389 1
   fprintf( f, "START-LIST %d, address %p\n", list, (void*)n );
d3407 1
a3407 1
            fprintf(f,"CallList %d + offset %d = %d\n", (int) n[1].ui,
d3482 1
a3482 1
            fprintf(f,"VERTEX-CASSETTE, id %d, %d elements\n", 
d3491 1
a3491 1
            fprintf(f,"END-LIST %d\n", list);
d3501 1
a3501 1
               fprintf(f,"command %d, %d operands\n",opcode,InstSize[opcode]);
@


3.18
log
@fixed IRIX compiler warnings
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.17 1999/03/17 12:08:22 keithw Exp $ */
a27 1

d40 1
d49 1
d53 1
d68 1
d76 1
d351 1
a351 1
	       gl_free_immediate( (struct immediate *) n[1].data );
d611 1
a611 1
void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
d626 1
a626 1
void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
d640 1
a640 1
void gl_save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
d655 1
a655 1
void gl_save_Bitmap( GLcontext *ctx,
d683 1
a683 1
void gl_save_BlendEquation( GLcontext *ctx, GLenum mode )
d697 1
a697 1
void gl_save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
d712 1
a712 1
void gl_save_BlendFuncSeparate( GLcontext *ctx,
d732 1
a732 1
void gl_save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green,
d750 1
a750 1
void gl_save_CallList( GLcontext *ctx, GLuint list )
d764 1
a764 1
void gl_save_CallLists( GLcontext *ctx,
d783 1
a783 1
void gl_save_Clear( GLcontext *ctx, GLbitfield mask )
d797 1
a797 1
void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
d815 1
a815 1
void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
d833 1
a833 1
void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth )
d847 1
a847 1
void gl_save_ClearIndex( GLcontext *ctx, GLfloat c )
d861 1
a861 1
void gl_save_ClearStencil( GLcontext *ctx, GLint s )
d875 1
a875 1
void gl_save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
d894 1
a894 1
void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
d912 1
a912 1
void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
d927 1
a927 1
void gl_save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
d948 1
a948 1
void gl_save_ColorSubTable( GLcontext *ctx, GLenum target,
d970 1
a970 1
void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
d990 1
a990 1
void gl_save_CopyTexImage1D( GLcontext *ctx,
d1015 1
a1015 1
void gl_save_CopyTexImage2D( GLcontext *ctx,
d1042 1
a1042 1
void gl_save_CopyTexSubImage1D( GLcontext *ctx,
d1064 1
a1064 1
void gl_save_CopyTexSubImage2D( GLcontext *ctx,
d1090 1
a1090 1
void gl_save_CopyTexSubImage3DEXT( GLcontext *ctx,
d1117 1
a1117 1
void gl_save_CullFace( GLcontext *ctx, GLenum mode )
d1131 1
a1131 1
void gl_save_DepthFunc( GLcontext *ctx, GLenum func )
d1145 1
a1145 1
void gl_save_DepthMask( GLcontext *ctx, GLboolean mask )
d1159 1
a1159 1
void gl_save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
d1174 1
a1174 1
void gl_save_Disable( GLcontext *ctx, GLenum cap )
d1188 1
a1188 1
void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode )
d1202 1
a1202 1
void gl_save_DrawPixels( GLcontext *ctx, struct gl_image *image )
d1220 1
a1220 1
void gl_save_Enable( GLcontext *ctx, GLenum cap )
d1235 1
a1235 1
void gl_save_EvalMesh1( GLcontext *ctx,
d1252 1
a1252 1
void gl_save_EvalMesh2( GLcontext *ctx, 
d1273 1
a1273 1
void gl_save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
d1291 1
a1291 1
void gl_save_FrontFace( GLcontext *ctx, GLenum mode )
d1305 1
a1305 1
void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
d1326 1
a1326 1
void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
d1333 1
a1333 1
      n[2].e = mode;
d1336 1
a1336 1
      (*ctx->Exec.Hint)( ctx, target, mode );
d1338 1
d1343 1
a1343 1
void gl_save_IndexMask( GLcontext *ctx, GLuint mask )
d1357 1
a1357 1
void gl_save_InitNames( GLcontext *ctx )
d1367 1
a1367 1
void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
d1387 1
a1387 1
void gl_save_LightModelfv( GLcontext *ctx,
d1406 1
a1406 1
void gl_save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
d1421 1
a1421 1
void gl_save_LineWidth( GLcontext *ctx, GLfloat width )
d1435 1
a1435 1
void gl_save_ListBase( GLcontext *ctx, GLuint base )
d1449 1
a1449 1
void gl_save_LoadIdentity( GLcontext *ctx )
d1459 1
a1459 1
void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
d1476 1
a1476 1
void gl_save_LoadName( GLcontext *ctx, GLuint name )
d1490 1
a1490 1
void gl_save_LogicOp( GLcontext *ctx, GLenum opcode )
d1504 1
a1504 1
void gl_save_Map1f( GLcontext *ctx,
d1526 1
a1526 1
void gl_save_Map2f( GLcontext *ctx, GLenum target,
d1555 1
a1555 1
void gl_save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
d1571 1
a1571 1
void gl_save_MapGrid2f( GLcontext *ctx, 
d1592 1
a1592 1
void gl_save_MatrixMode( GLcontext *ctx, GLenum mode )
d1606 1
a1606 1
void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
d1623 1
a1623 1
void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
d1633 1
a1633 1
void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
d1654 1
a1654 1
void gl_save_PixelMapfv( GLcontext *ctx,
d1672 1
a1672 1
void gl_save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
d1687 1
a1687 1
void gl_save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
d1702 1
a1702 1
void gl_save_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
d1720 1
a1720 1
void gl_save_PointSize( GLcontext *ctx, GLfloat size )
d1734 1
a1734 1
void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
d1752 1
a1752 1
void gl_save_PolygonStipple( GLcontext *ctx, const GLuint *pattern )
d1769 1
a1769 1
void gl_save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
d1784 1
a1784 1
void gl_save_PopAttrib( GLcontext *ctx )
d1794 1
a1794 1
void gl_save_PopMatrix( GLcontext *ctx )
d1804 1
a1804 1
void gl_save_PopName( GLcontext *ctx )
d1814 1
a1814 1
void gl_save_PrioritizeTextures( GLcontext *ctx,
d1835 1
a1835 1
void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask )
d1849 1
a1849 1
void gl_save_PushMatrix( GLcontext *ctx )
d1859 1
a1859 1
void gl_save_PushName( GLcontext *ctx, GLuint name )
d1873 1
a1873 1
void gl_save_RasterPos4f( GLcontext *ctx,
d1891 1
a1891 1
void gl_save_PassThrough( GLcontext *ctx, GLfloat token )
d1905 1
a1905 1
void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode )
d1919 1
a1919 1
void gl_save_Rectf( GLcontext *ctx,
d1937 1
a1937 1
void gl_save_Rotatef( GLcontext *ctx, GLfloat angle,
d1942 1
a1942 1
   gl_save_MultMatrixf( ctx, m );  /* save and maybe execute */
d1946 1
a1946 1
void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
d1962 1
a1962 1
void gl_save_Scissor( GLcontext *ctx,
d1980 1
a1980 1
void gl_save_ShadeModel( GLcontext *ctx, GLenum mode )
d1994 1
a1994 1
void gl_save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
d2010 1
a2010 1
void gl_save_StencilMask( GLcontext *ctx, GLuint mask )
d2024 1
a2024 1
void gl_save_StencilOp( GLcontext *ctx,
d2043 1
a2043 1
void gl_save_TexEnvfv( GLcontext *ctx,
d2063 1
a2063 1
void gl_save_TexGenfv( GLcontext *ctx,
d2083 1
a2083 1
void gl_save_TexParameterfv( GLcontext *ctx, GLenum target,
d2103 1
a2103 1
void gl_save_TexImage1D( GLcontext *ctx, GLenum target,
d2133 1
a2133 1
void gl_save_TexImage2D( GLcontext *ctx, GLenum target,
d2164 1
a2164 1
void gl_save_TexImage3DEXT( GLcontext *ctx, GLenum target,
d2193 1
a2193 1
void gl_save_TexSubImage1D( GLcontext *ctx,
d2219 1
a2219 1
void gl_save_TexSubImage2D( GLcontext *ctx,
d2249 1
a2249 1
void gl_save_TexSubImage3DEXT( GLcontext *ctx,
d2281 1
a2281 1
void gl_save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
d2298 1
a2298 1
void gl_save_Viewport( GLcontext *ctx,
d2316 1
a2316 1
void gl_save_WindowPos4fMESA( GLcontext *ctx,
d2337 1
a2337 1
void gl_save_SelectTextureSGIS( GLcontext *ctx, GLenum target )
d2352 1
a2352 1
void gl_save_SelectTextureCoordSet( GLcontext *ctx, GLenum target )
d2367 1
a2367 1
void gl_save_ActiveTexture( GLcontext *ctx, GLenum target )
d2382 1
a2382 1
void gl_save_ClientActiveTexture( GLcontext *ctx, GLenum target )
a2395 167
static void cliptest_bounds( GLubyte *orMask, 
			     GLubyte *andMask,
			     CONST GLfloat (*bounds)[4],
			     GLuint count )
{
   GLubyte tmpOrMask = 0;
   GLubyte tmpAndMask = ~0;
   GLuint i;   

   for (i = 0 ; i < count ; i++) {
      const GLfloat cx = bounds[i][0];
      const GLfloat cy = bounds[i][1];
      const GLfloat cz = bounds[i][2];
      const GLfloat cw = bounds[i][3];
      GLubyte mask = 0;

      if (cx > cw)       mask |= CLIP_RIGHT_BIT;
      else if (cx < -cw) mask |= CLIP_LEFT_BIT;
      if (cy > cw)       mask |= CLIP_TOP_BIT;
      else if (cy < -cw) mask |= CLIP_BOTTOM_BIT;
      if (cz > cw)       mask |= CLIP_FAR_BIT;
      else if (cz < -cw) mask |= CLIP_NEAR_BIT;

      tmpOrMask |= mask;
      tmpAndMask &= mask;
   }

   *orMask |= tmpOrMask;
   *andMask &= tmpAndMask;
}


void gl_transform_bounds3( GLubyte *orMask, GLubyte *andMask,
			   const GLmatrix *mat,
			   CONST GLfloat src[][3] )
{
   GLuint i;
   GLfloat dx[4], dy[4], dz[4];
   GLfloat data[8][4];
   const GLfloat *m = mat->m;

   /* Do the first transform */
   gl_transform_point_sz( data[0], mat->m, src[0], 3 );

   for (i = 1 ; i < 8 ; i++)
      COPY_4V( data[i], data[0] );

   dx[0] = m[ 0]*src[1][0];
   dx[1] = m[ 1]*src[1][0];
   dx[2] = m[ 2]*src[1][0];
   dx[3] = m[ 3]*src[1][0];
   
   for (i = 4 ; i < 8 ; i++)
      ACC_4V( data[i], dx );
   
   dy[0] = m[ 4]*src[1][1];
   dy[1] = m[ 5]*src[1][1];
   dy[2] = m[ 6]*src[1][1];
   dy[3] = m[ 7]*src[1][1];

   ACC_4V( data[2], dy );
   ACC_4V( data[3], dy );
   ACC_4V( data[6], dy );
   ACC_4V( data[7], dy );

   dz[0] = m[ 8]*src[1][2];
   dz[1] = m[ 9]*src[1][2];
   dz[2] = m[10]*src[1][2];
   dz[3] = m[11]*src[1][2];

   for (i = 1 ; i < 8 ; i+=2) 
      ACC_4V( data[i], dz );

   
   cliptest_bounds( orMask, andMask, data, 8 );
}

void gl_transform_bounds2( GLubyte *orMask, GLubyte *andMask, 
			   const GLmatrix *mat,
			   CONST GLfloat src[][3] )
{
   GLuint i;
   GLfloat dx[4], dy[4];
   GLfloat data[4][4];
   const GLfloat *m = mat->m;

   /* Do the first transform */
   gl_transform_point_sz( data[0], mat->m, src[0], 2 );

   for (i = 1 ; i < 4 ; i++)
      COPY_4V( data[i], data[0] );

   dx[0] = m[0]*src[1][0];
   dx[1] = m[1]*src[1][0];
   dx[2] = m[2]*src[1][0];
   dx[3] = m[3]*src[1][0];
   
   ACC_4V( data[1], dx );
   ACC_4V( data[3], dx );
   
   dy[0] = m[4]*src[1][1];
   dy[1] = m[5]*src[1][1];
   dy[2] = m[6]*src[1][1];
   dy[3] = m[7]*src[1][1];

   ACC_4V( data[2], dy );
   ACC_4V( data[3], dy );

   cliptest_bounds( orMask, andMask, data, 4 );
}



/* Would it be valid to talk about a bounding box for 4-vectors?
 */
static void calculate_bounds3( GLfloat (*bounds)[3],
                               const GLvector4f *obj )
{
   const GLfloat (*data)[4] = (GLfloat (*)[4])obj->start;
   GLfloat xmin = data[0][0];
   GLfloat ymin = data[0][1];
   GLfloat zmin = data[0][2];
   GLfloat xmax = data[0][0];
   GLfloat ymax = data[0][1];
   GLfloat zmax = data[0][2];
   GLuint i, count = obj->count;
   
   for (i = 1 ; i < count ; i++) {
      GLfloat t;
      t = data[i][0]; if (t > xmax) xmax = t; else if (t < xmin) xmin = t;
      t = data[i][1]; if (t > ymax) ymax = t; else if (t < ymin) ymin = t;
      t = data[i][2]; if (t > zmax) zmax = t; else if (t < zmin) zmin = t;
   }
   
   bounds[0][0] = xmin;
   bounds[0][1] = ymin;
   bounds[0][2] = zmin;
   bounds[1][0] = xmax - xmin;
   bounds[1][1] = ymax - ymin;
   bounds[1][2] = zmax - zmin;
}


static void calculate_bounds2( GLfloat (*bounds)[3],
			       const GLvector4f *obj )
{
   CONST GLfloat (*data)[4] = obj->data;
   GLfloat xmin = data[0][0];
   GLfloat ymin = data[0][1];
   GLfloat xmax = data[1][0];
   GLfloat ymax = data[1][1];
   GLuint i, count = obj->count;
   
   for (i = VB_START+1 ; i < count ; i++) {
      GLfloat t;
      t = data[i][0]; if (t > xmax) xmax = t; else if (t < xmin) xmin = t;
      t = data[i][1]; if (t > ymax) ymax = t; else if (t < ymin) ymin = t;
   }

   bounds[0][0] = xmin;
   bounds[0][1] = ymin;
   bounds[0][2] = 0;
   bounds[1][0] = xmax - xmin;
   bounds[1][1] = ymax - ymin;
   bounds[1][2] = 0;
}

d2402 1
a2402 1
   struct immediate *new_im = gl_alloc_immediate(ctx);
d2407 1
a2407 1
      if (new_im) free(new_im);
d2411 5
a2415 1
   /* Do some easy optimizations of the cassette.
d2417 3
a2419 1
   if (im->vObj.size < 4 && im->Count > 15)
d2422 1
a2422 5

      if (im->vObj.size == 3)
	 calculate_bounds3( im->Bounds, &im->vObj ); 
      else
	 calculate_bounds2( im->Bounds, &im->vObj ); 
d2482 3
a2484 1
	    gl_execute_cassette( ctx, (struct immediate *) n[1].data ); 
d3043 1
a3043 1
   IM = gl_alloc_immediate( ctx );
d3048 6
d3082 2
d3093 1
d3098 1
a3098 1
   SET_IMMEDIATE( ctx, &ctx->VB->store );
d3177 186
d3366 1
a3366 4

static char tmp[1000];

static char *enum_string( GLenum k )
d3368 1
a3368 22
   switch (k) {
      case GL_POINTS:		return "GL_POINTS";
      case GL_LINES:		return "GL_LINES";
      case GL_LINE_STRIP:	return "GL_LINE_STRIP";
      case GL_LINE_LOOP:	return "GL_LINE_LOOP";
      case GL_TRIANGLES:	return "GL_TRIANGLES";
      case GL_TRIANGLE_STRIP:	return "GL_TRIANGLE_STRIP";
      case GL_TRIANGLE_FAN:	return "GL_TRIANGLE_FAN";
      case GL_QUADS:		return "GL_QUADS";
      case GL_QUAD_STRIP:	return "GL_QUAD_STRIP";
      case GL_POLYGON:		return "GL_POLYGON";
      case GL_FRONT:		return "GL_FRONT";
      case GL_BACK:		return "GL_BACK";
      case GL_FRONT_AND_BACK:	return "GL_FRONT_AND_BACK";
      case GL_AMBIENT:		return "GL_AMBIENT";
      case GL_DIFFUSE:		return "GL_DIFFUSE";
      case GL_SPECULAR:		return "GL_SPECULAR";
      case GL_SHININESS:	return "GL_SHININESS";
      default:
         sprintf(tmp,"0x%X", k);
         return tmp;
   }
d3511 3
@


3.17
log
@Removed CLIP_4D_BIT, added CLIP_CULLED_BIT.  Clipmask is now used
to drive culling in vertex transformation, allowing us to skip
both clipped and culled vertices with a single test.
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.16 1999/03/02 13:05:04 brianp Exp $ */
d77 1
d2425 1
a2425 1
			   const GLfloat src[][3] )
d2470 1
a2470 1
			   const GLfloat src[][3] )
@


3.16
log
@fixed a few IRIX compiler warnings
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.15 1999/02/25 14:12:30 keithw Exp $ */
d114 4
a117 2
/* How many nodes to allocate at a time: */
#define BLOCK_SIZE 500
d2417 2
a2418 2
   *orMask = tmpOrMask;
   *andMask = tmpAndMask;
d2506 1
a2506 1
			       const GLvector4f *obj )
d2508 1
a2508 1
   CONST GLfloat (*data)[4] = obj->data;
d2512 3
a2514 3
   GLfloat xmax = data[1][0];
   GLfloat ymax = data[1][1];
   GLfloat zmax = data[1][2];
d2517 1
a2517 1
   for (i = VB_START+1 ; i < count ; i++) {
@


3.15
log
@Merged in kw3 patch
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.14 1999/02/24 22:48:05 jens Exp $ */
d2390 1
a2390 1
			     const GLfloat (*bounds)[4],
d2506 1
a2506 1
   const GLfloat (*data)[4] = obj->data;
d2534 1
a2534 1
   const GLfloat (*data)[4] = obj->data;
@


3.14
log
@Added header file to get XMesa to compile standalone and inside XFree86
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.13 1999/02/14 03:46:34 brianp Exp $ */
a27 46
/*
 * $Log: dlist.c,v $
 * Revision 3.13  1999/02/14 03:46:34  brianp
 * new copyright
 *
 * Revision 3.12  1998/11/18 04:43:03  brianp
 * glDeleteLists(0, n) caused assertion failure
 *
 * Revision 3.11  1998/11/03 01:40:37  brianp
 * implemented GL_ARB_multitexture
 *
 * Revision 3.10  1998/10/20 02:27:56  brianp
 * removed GL_EXT_multitexture extension
 *
 * Revision 3.9  1998/10/05 00:40:15  brianp
 * added GL_INGR_blend_func_separate extension
 *
 * Revision 3.8  1998/08/21 02:48:14  brianp
 * fixed polygon stipple pointer casting typo
 *
 * Revision 3.7  1998/08/21 02:42:21  brianp
 * changed gl_save_PolygonStipple() param type to GLuint *
 *
 * Revision 3.6  1998/06/07 22:18:52  brianp
 * implemented GL_EXT_multitexture extension
 *
 * Revision 3.5  1998/03/28 03:58:52  brianp
 * fixed a few IRIX compiler warnings
 *
 * Revision 3.4  1998/03/27 03:39:14  brianp
 * fixed G++ warnings
 *
 * Revision 3.3  1998/03/19 01:26:39  brianp
 * fixed API pointer restore problem in glCallList(s)
 *
 * Revision 3.2  1998/02/20 04:50:09  brianp
 * implemented GL_SGIS_multitexture
 *
 * Revision 3.1  1998/02/08 20:23:09  brianp
 * removed const from gl_save_Bitmap()'s bitmap parameter
 *
 * Revision 3.0  1998/01/31 20:50:39  brianp
 * initial rev
 *
 */

d37 1
d75 1
d123 2
a128 1
        OPCODE_BEGIN,
a143 3
	OPCODE_COLOR_3F,
	OPCODE_COLOR_4F,
	OPCODE_COLOR_4UB,
a161 1
        OPCODE_EDGE_FLAG,
a162 1
        OPCODE_END,
a172 1
	OPCODE_INDEX,
a187 1
	OPCODE_MATERIAL,
a189 2
	OPCODE_MULTI_TEXCOORD4,
        OPCODE_NORMAL,
a217 2
	OPCODE_TEXCOORD2,
	OPCODE_TEXCOORD4,
a227 3
        OPCODE_VERTEX2,
        OPCODE_VERTEX3,
        OPCODE_VERTEX4,
d233 3
a235 1
	/* The following two are meta instructions */
d342 5
a485 1
      InstSize[OPCODE_BEGIN] = 2;
a500 3
      InstSize[OPCODE_COLOR_3F] = 4;
      InstSize[OPCODE_COLOR_4F] = 5;
      InstSize[OPCODE_COLOR_4UB] = 5;
a518 2
      InstSize[OPCODE_EDGE_FLAG] = 2;
      InstSize[OPCODE_END] = 1;
a528 1
      InstSize[OPCODE_INDEX] = 2;
a543 1
      InstSize[OPCODE_MATERIAL] = 7;
a545 2
      InstSize[OPCODE_MULTI_TEXCOORD4] = 6;
      InstSize[OPCODE_NORMAL] = 4;
a573 2
      InstSize[OPCODE_TEXCOORD2] = 3;
      InstSize[OPCODE_TEXCOORD4] = 5;
a583 3
      InstSize[OPCODE_VERTEX2] = 3;
      InstSize[OPCODE_VERTEX3] = 4;
      InstSize[OPCODE_VERTEX4] = 5;
d587 2
d603 1
d606 3
a608 1
   Node *n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
d621 3
a623 1
   Node *n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
a632 13

void gl_save_Begin( GLcontext *ctx, GLenum mode )
{
   Node *n = alloc_instruction( ctx, OPCODE_BEGIN, 1 );
   if (n) {
      n[1].e = mode;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Begin)( ctx, mode );
   }
}


d635 3
a637 1
   Node *n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
d654 3
a656 1
   Node *n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
d678 3
a680 1
   Node *n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
d692 3
a694 1
   Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
d709 3
a711 1
   Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
d728 3
a730 1
   Node *n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
d745 3
a747 1
   Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
d761 1
d778 3
a780 1
   Node *n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
d793 3
a795 1
   Node *n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
d811 3
a813 1
   Node *n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
d828 3
a830 1
   Node *n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
d842 3
a844 1
   Node *n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
d856 3
a858 1
   Node *n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
d870 3
a872 1
   Node *n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
a885 89
void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b )
{
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
   if (n) {
      n[1].f = r;
      n[2].f = g;
      n[3].f = b;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Color3f)( ctx, r, g, b );
   }
}


void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c )
{
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
   if (n) {
      n[1].f = c[0];
      n[2].f = c[1];
      n[3].f = c[2];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Color3fv)( ctx, c );
   }
}


void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g,
                                      GLfloat b, GLfloat a )
{
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
   if (n) {
      n[1].f = r;
      n[2].f = g;
      n[3].f = b;
      n[4].f = a;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Color4f)( ctx, r, g, b, a );
   }
}


void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c )
{
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
   if (n) {
      n[1].f = c[0];
      n[2].f = c[1];
      n[3].f = c[2];
      n[4].f = c[3];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Color4fv)( ctx, c );
   }
}


void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g,
                                       GLubyte b, GLubyte a )
{
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
   if (n) {
      n[1].ub = r;
      n[2].ub = g;
      n[3].ub = b;
      n[4].ub = a;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Color4ub)( ctx, r, g, b, a );
   }
}


void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c )
{
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
   if (n) {
      n[1].ub = c[0];
      n[2].ub = c[1];
      n[3].ub = c[2];
      n[4].ub = c[3];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Color4ubv)( ctx, c );
   }
}

d890 3
a892 1
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
d907 3
a909 1
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
d923 3
a925 1
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
d944 3
a946 1
   Node *n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
d966 3
a968 1
   Node *n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
d989 3
a991 1
   Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
d1014 3
a1016 1
   Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
d1040 3
a1042 1
   Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
d1063 3
a1065 1
   Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
d1089 3
a1091 1
   Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
d1112 3
a1114 1
   Node *n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
d1126 3
a1128 1
   Node *n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
d1140 3
a1142 1
   Node *n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
d1154 3
a1156 1
   Node *n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
d1169 3
a1171 1
   Node *n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
d1183 3
a1185 1
   Node *n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
d1197 3
a1199 1
   Node *n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 1 );
a1211 11
void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag )
{
   Node *n = alloc_instruction( ctx, OPCODE_EDGE_FLAG, 1 );
   if (n) {
      n[1].b = flag;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EdgeFlag)( ctx, flag );
   }
}

d1215 3
a1217 1
   Node *n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
a1226 33
void gl_save_End( GLcontext *ctx )
{
   (void) alloc_instruction( ctx, OPCODE_END, 0 );
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.End)( ctx );
   }
}


void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u )
{
   Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD1, 1 );
   if (n) {
      n[1].f = u;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EvalCoord1f)( ctx, u );
   }
}


void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v )
{
   Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD2, 2 );
   if (n) {
      n[1].f = u;
      n[2].f = v;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EvalCoord2f)( ctx, u, v );
   }
}

d1231 3
a1233 1
   Node *n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
d1248 3
a1250 1
   Node *n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
a1263 23
void gl_save_EvalPoint1( GLcontext *ctx, GLint i )
{
   Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT1, 1 );
   if (n) {
      n[1].i = i;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EvalPoint1)( ctx, i );
   }
}


void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j )
{
   Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT2, 2 );
   if (n) {
      n[1].i = i;
      n[2].i = j;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.EvalPoint2)( ctx, i, j );
   }
}
d1268 3
a1270 1
   Node *n = alloc_instruction( ctx, OPCODE_FOG, 5 );
d1286 3
a1288 1
   Node *n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
d1302 3
a1304 1
   Node *n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
d1321 3
a1323 1
   Node *n = alloc_instruction( ctx, OPCODE_HINT, 2 );
a1333 23
void gl_save_Indexi( GLcontext *ctx, GLint index )
{
   Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
   if (n) {
      n[1].i = index;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Indexi)( ctx, index );
   }
}


void gl_save_Indexf( GLcontext *ctx, GLfloat index )
{
   Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
   if (n) {
      n[1].i = (GLint) index;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Indexf)( ctx,index );
   }
}

d1337 3
a1339 1
   Node *n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
d1351 1
d1362 3
a1364 1
   Node *n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
d1382 3
a1384 1
   Node *n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
d1400 3
a1402 1
   Node *n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
d1415 3
a1417 1
   Node *n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
d1429 3
a1431 1
   Node *n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
d1443 1
d1453 3
a1455 1
   Node *n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
d1470 3
a1472 1
   Node *n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
d1484 3
a1486 1
   Node *n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
d1500 3
a1502 1
   Node *n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
d1523 3
a1525 1
   Node *n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
d1549 3
a1551 1
   Node *n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
d1567 3
a1569 1
   Node *n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
a1583 18
void gl_save_Materialfv( GLcontext *ctx,
                         GLenum face, GLenum pname, const GLfloat *params )
{
   Node *n = alloc_instruction( ctx, OPCODE_MATERIAL, 6 );
   if (n) {
      n[1].e = face;
      n[2].e = pname;
      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.Materialfv)( ctx, face, pname, params );
   }
}


d1586 3
a1588 1
   Node *n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
d1600 3
a1602 1
   Node *n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
a1623 27
void gl_save_Normal3fv( GLcontext *ctx, const GLfloat norm[3] )
{
   Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
   if (n) {
      n[1].f = norm[0];
      n[2].f = norm[1];
      n[3].f = norm[2];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Normal3fv)( ctx, norm );
   }
}


void gl_save_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz )
{
   Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
   if (n) {
      n[1].f = nx;
      n[2].f = ny;
      n[3].f = nz;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Normal3f)( ctx, nx, ny, nz );
   }
}

d1629 3
a1631 1
   Node *n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
d1649 3
a1651 1
   Node *n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
d1666 3
a1668 1
   Node *n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
d1681 3
a1683 1
   Node *n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
d1697 3
a1699 1
   Node *n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
d1714 3
a1716 1
   Node *n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
d1728 3
a1730 1
   Node *n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
d1746 3
a1748 1
   Node *n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
d1763 3
a1765 1
   Node *n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
d1778 1
d1788 1
d1798 1
d1811 1
d1814 2
a1815 1
      Node *n = alloc_instruction( ctx,  OPCODE_PRIORITIZE_TEXTURE, 2 );
d1829 3
a1831 1
   Node *n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
d1843 1
d1853 3
a1855 1
   Node *n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
d1868 3
a1870 1
   Node *n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
d1885 3
a1887 1
   Node *n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
d1899 3
a1901 1
   Node *n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
d1914 3
a1916 1
   Node *n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
d1940 3
a1942 1
   Node *n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
d1957 3
a1959 1
   Node *n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
d1974 3
a1976 1
   Node *n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
d1988 3
a1990 1
   Node *n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
d2004 3
a2006 1
   Node *n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
d2019 3
a2021 1
   Node *n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
a2032 27
void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t )
{
   Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD2, 2 );
   if (n) {
      n[1].f = s;
      n[2].f = t;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexCoord2f)( ctx, s, t );
   }
}


void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t,
                                         GLfloat r, GLfloat q )
{
   Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD4, 4 );
   if (n) {
      n[1].f = s;
      n[2].f = t;
      n[3].f = r;
      n[4].f = q;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.TexCoord4f)( ctx, s, t, r, q );
   }
}
d2038 3
a2040 1
   Node *n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
d2058 3
a2060 1
   Node *n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
d2078 3
a2080 1
   Node *n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
d2101 3
a2103 1
   Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
d2131 3
a2133 1
   Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
d2163 3
a2165 1
   Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
d2190 3
a2192 1
   Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
d2218 3
a2220 1
   Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
d2248 3
a2250 1
   Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
d2275 3
a2277 1
   Node *n = alloc_instruction( ctx,  OPCODE_TRANSLATE, 3 );
a2288 56
void gl_save_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y )
{
   Node *n = alloc_instruction( ctx,  OPCODE_VERTEX2, 2 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Vertex2f)( ctx, x, y );
   }
}


void gl_save_Vertex3f( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
{
   Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
      n[3].f = z;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Vertex3f)( ctx, x, y, z );
   }
}


void gl_save_Vertex4f( GLcontext *ctx,
                       GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
   Node *n = alloc_instruction( ctx,  OPCODE_VERTEX4, 4 );
   if (n) {
      n[1].f = x;
      n[2].f = y;
      n[3].f = z;
      n[4].f = w;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Vertex4f)( ctx, x, y, z, w );
   }
}


void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat v[3] )
{
   Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
   if (n) {
      n[1].f = v[0];
      n[2].f = v[1];
      n[3].f = v[2];
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.Vertex3fv)( ctx, v );
   }
}

d2293 3
a2295 1
   Node *n = alloc_instruction( ctx,  OPCODE_VIEWPORT, 4 );
d2311 3
a2313 1
   Node *n = alloc_instruction( ctx,  OPCODE_WINDOW_POS, 4 );
a2325 16
/* GL_SGIS_multitexture */
void gl_save_MultiTexCoord4f( GLcontext *ctx, GLenum target,
                              GLfloat s, GLfloat t, GLfloat r, GLfloat q )
{
   Node *n = alloc_instruction( ctx, OPCODE_MULTI_TEXCOORD4, 5);
   if (n) {
      n[1].e = target;
      n[2].f = s;
      n[3].f = t;
      n[4].f = r;
      n[5].f = q;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.MultiTexCoord4f)( ctx, target, s, t, r, q );
   }
}
d2331 3
a2333 1
   Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_SGIS, 1 );
d2346 3
a2348 1
   Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_COORD_SET, 1 );
d2361 3
a2363 1
   Node *n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
d2376 3
a2378 1
   Node *n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
d2388 181
d2570 5
d2576 26
d2623 2
d2634 7
a2640 56
	 /* Frequently called functions: */
         case OPCODE_VERTEX2:
            (*ctx->Exec.Vertex2f)( ctx, n[1].f, n[2].f );
            break;
         case OPCODE_VERTEX3:
            (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f );
            break;
         case OPCODE_VERTEX4:
            (*ctx->Exec.Vertex4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
            break;
         case OPCODE_NORMAL:
            ctx->Current.Normal[0] = n[1].f;
            ctx->Current.Normal[1] = n[2].f;
            ctx->Current.Normal[2] = n[3].f;
            ctx->VB->MonoNormal = GL_FALSE;
            break;
	 case OPCODE_COLOR_4UB:
            (*ctx->Exec.Color4ub)( ctx, n[1].ub, n[2].ub, n[3].ub, n[4].ub );
	    break;
	 case OPCODE_COLOR_3F:
            (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f );
            break;
	 case OPCODE_COLOR_4F:
            (*ctx->Exec.Color4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
            break;
         case OPCODE_INDEX:
            ctx->Current.Index = n[1].ui;
            ctx->VB->MonoColor = GL_FALSE;
            break;
         case OPCODE_BEGIN:
            gl_Begin( ctx, n[1].e );
            break;
         case OPCODE_END:
            gl_End( ctx );
            break;
	 case OPCODE_TEXCOORD2:
	    ctx->Current.TexCoord[0] = n[1].f;
	    ctx->Current.TexCoord[1] = n[2].f;
            if (ctx->VB->TexCoordSize==4) {
               ctx->Current.TexCoord[2] = 0.0F;
               ctx->Current.TexCoord[3] = 1.0F;
            }
	    break;
	 case OPCODE_TEXCOORD4:
	    ctx->Current.TexCoord[0] = n[1].f;
	    ctx->Current.TexCoord[1] = n[2].f;
	    ctx->Current.TexCoord[2] = n[3].f;
	    ctx->Current.TexCoord[3] = n[4].f;
            if (ctx->VB->TexCoordSize==2) {
               /* Switch to 4-component texcoords */
               ctx->VB->TexCoordSize = 4;
               gl_set_vertex_function(ctx);
            }
	    break;

	 /* Everything Else: */
a2765 3
	 case OPCODE_EDGE_FLAG:
            ctx->Current.EdgeFlag = n[1].b;
            break;
a2768 6
	 case OPCODE_EVALCOORD1:
	    gl_EvalCoord1f( ctx, n[1].f );
	    break;
	 case OPCODE_EVALCOORD2:
	    gl_EvalCoord2f( ctx, n[1].f, n[2].f );
	    break;
a2774 6
	 case OPCODE_EVALPOINT1:
	    gl_EvalPoint1( ctx, n[1].i );
	    break;
	 case OPCODE_EVALPOINT2:
	    gl_EvalPoint2( ctx, n[1].i, n[2].i );
	    break;
a2869 10
	 case OPCODE_MATERIAL:
	    {
	       GLfloat params[4];
	       params[0] = n[3].f;
	       params[1] = n[4].f;
	       params[2] = n[5].f;
	       params[3] = n[6].f;
	       gl_Materialfv( ctx, n[1].e, n[2].e, params );
	    }
	    break;
a2885 4
         case OPCODE_MULTI_TEXCOORD4:
            (*ctx->Exec.MultiTexCoord4f)( ctx, n[1].e,
                                          n[2].f, n[3].f, n[4].f, n[5].f );
            break;
d3098 2
d3106 1
d3129 1
a3129 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glDeleteLists" );
      return;
   }
d3149 1
a3149 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glGenLists" );
      return 0;
   }
d3176 3
a3178 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
      return;
   }
d3198 4
d3221 2
d3241 5
d3256 1
a3256 1
   save_compile_flag = ctx->CompileFlag;
d3258 5
d3269 3
d3292 2
d3304 3
d3316 1
a3316 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glListBase" );
      return;
   }
a3330 1
   /* TODO: Add many more constant/string entries */
d3381 1
a3381 1
            fprintf(f,"accum %d %g\n", n[1].e, n[2].f );
a3382 3
         case OPCODE_BEGIN:
            fprintf(f,"Begin %s\n", enum_string(n[1].e) );
            break;
a3393 10
	 case OPCODE_COLOR_3F:
            fprintf(f,"Color3f %g %g %gn", n[1].f, n[2].f, n[3].f );
	    break;
	 case OPCODE_COLOR_4F:
            fprintf(f,"Color4f %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
	    break;
	 case OPCODE_COLOR_4UB:
            fprintf(f,"Color4ub %d %d %d %d\n", n[1].ub, n[2].ub,
                                                n[3].ub, n[4].ub );
	    break;
a3399 3
         case OPCODE_END:
            fprintf(f,"End\n");
            break;
a3403 3
         case OPCODE_INDEX:
            fprintf(f,"Index %d\n", (int) n[1].ui );
            break;
a3416 4
	 case OPCODE_MATERIAL:
            fprintf(f,"Material %s %s %g %g %g %g\n", enum_string(n[1].e),
                    enum_string(n[2].e), n[3].f, n[4].f, n[5].f, n[6].f );
            break;
a3423 3
         case OPCODE_NORMAL:
            fprintf(f,"Normal %g %g %g\n", n[1].f, n[2].f, n[3].f );
            break;
a3454 6
	 case OPCODE_TEXCOORD2:
            fprintf(f,"TexCoord %g %g\n", n[1].f, n[2].f);
	    break;
	 case OPCODE_TEXCOORD4:
            fprintf(f,"TexCoord %g %g %g %g\n", n[1].f, n[2].f, n[3].f,n[4].f);
	    break;
a3457 9
         case OPCODE_VERTEX2:
            fprintf(f,"Vertex %g %g\n", n[1].f, n[2].f );
            break;
         case OPCODE_VERTEX3:
            fprintf(f,"Vertex %g %g %g\n", n[1].f, n[2].f, n[3].f );
            break;
         case OPCODE_VERTEX4:
            fprintf(f,"Vertex %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
            break;
d3462 8
a3492 1

d3498 2
d3507 2
a3508 7
   GLcontext *ctx;
#ifdef THREADS
   ctx = gl_get_thread_context();
#else
   ctx = CC;
#endif
   print_list( ctx, stdout, list );
@


3.13
log
@new copyright
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.12 1998/11/18 04:43:03 brianp Exp brianp $ */
d30 3
d121 4
@


3.12
log
@glDeleteLists(0, n) caused assertion failure
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.11 1998/11/03 01:40:37 brianp Exp brianp $ */
d6 19
a24 15
 * Copyright (C) 1995-1998  Brian Paul
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
d30 3
@


3.11
log
@implemented GL_ARB_multitexture
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.10 1998/10/20 02:27:56 brianp Exp brianp $ */
d26 3
d372 3
@


3.10
log
@removed GL_EXT_multitexture extension
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.9 1998/10/05 00:40:15 brianp Exp brianp $ */
d26 3
d270 3
d633 3
d2547 24
d3115 6
@


3.9
log
@added GL_INGR_blend_func_separate extension
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.8 1998/08/21 02:48:14 brianp Exp brianp $ */
d26 3
a244 1
	OPCODE_SELECT_TEXTURE,
a245 1
	OPCODE_SELECT_TEXTURE_TRANSFORM,
a602 1
      InstSize[OPCODE_SELECT_TEXTURE] = 2;
a603 1
      InstSize[OPCODE_SELECT_TEXTURE_TRANSFORM] = 2;
a2524 13
/* GL_EXT_multitexture */
void gl_save_SelectTexture( GLcontext *ctx, GLenum target )
{
   Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE, 1 );
   if (n) {
      n[1].e = target;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.SelectTexture)( ctx, target );
   }
}


a2537 12
/* GL_EXT_multitexture */
void gl_save_SelectTextureTransform( GLcontext *ctx, GLenum target )
{
   Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_TRANSFORM, 1 );
   if (n) {
      n[1].e = target;
   }
   if (ctx->ExecuteFlag) {
      (*ctx->Exec.SelectTextureTransform)( ctx, target );
   }
}

a2967 3
         case OPCODE_SELECT_TEXTURE:
            gl_SelectTexture( ctx, n[1].e );
            break;
a2972 3
            break;
         case OPCODE_SELECT_TEXTURE_TRANSFORM:
            gl_SelectTextureTransform( ctx, n[1].e );
@


3.8
log
@fixed polygon stipple pointer casting typo
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.7 1998/08/21 02:42:21 brianp Exp brianp $ */
d5 1
a5 1
 * Version:  3.0
d26 3
d154 1
d515 1
d740 18
d2677 3
@


3.7
log
@changed gl_save_PolygonStipple() param type to GLuint *
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.6 1998/06/07 22:18:52 brianp Exp brianp $ */
d26 3
d2933 1
a2933 1
	    gl_PolygonStipple( ctx, (GLubyte *) n[1].data );
@


3.6
log
@implemented GL_EXT_multitexture extension
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.5 1998/03/28 03:58:52 brianp Exp brianp $ */
d26 3
d1859 4
a1862 1
void gl_save_PolygonStipple( GLcontext *ctx, const GLubyte *mask )
d1869 1
a1869 1
      MEMCPY( data, mask, 32 * 4 );
d1872 1
a1872 1
      (*ctx->Exec.PolygonStipple)( ctx, mask );
@


3.5
log
@fixed a few IRIX compiler warnings
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.4 1998/03/27 03:39:14 brianp Exp brianp $ */
d26 3
d231 1
d234 1
d590 1
d593 1
d2482 13
d2520 15
d2962 3
d2967 3
@


3.4
log
@fixed G++ warnings
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.3 1998/03/19 01:26:39 brianp Exp brianp $ */
d26 3
a3186 2
   Node *n;

d3193 1
a3193 1
   n = alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
d3341 1
a3341 1
            fprintf(f,"CallList %d\n", n[1].ui );
d3344 1
a3344 1
            fprintf(f,"CallList %d + offset %d = %d\n", n[1].ui,
d3371 1
a3371 1
            fprintf(f,"Index %d\n", n[1].ui );
d3420 1
a3420 1
            fprintf(f,"PushName %d\n", n[1].ui );
@


3.3
log
@fixed API pointer restore problem in glCallList(s)
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.2 1998/02/20 04:50:09 brianp Exp brianp $ */
d26 3
d201 1
d225 2
d297 1
a297 1
   assert( count == argcount+1 );
d361 1
a361 1
	    gl_free_image( n[1].data );
d558 1
d582 2
d750 1
a750 1
   GLuint i;
d1598 1
d1625 1
d1711 2
d2457 11
a2467 1

d2474 7
a2480 1

d2487 7
a2493 1

d2851 4
d2921 6
d3127 1
a3127 1
      GLuint i;
d3232 2
a3233 1
   GLuint i, list;
@


3.2
log
@implemented GL_SGIS_multitexture
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.1 1998/02/08 20:23:09 brianp Exp brianp $ */
d26 3
d3173 4
d3202 4
@


3.1
log
@removed const from gl_save_Bitmap()'s bitmap parameter
@
text
@d1 1
a1 1
/* $Id: dlist.c,v 3.0 1998/01/31 20:50:39 brianp Exp brianp $ */
d26 3
d2435 23
@


3.0
log
@initial rev
@
text
@d1 1
a1 1
/* $Id$ */
d25 4
a28 1
 * $Log$
d657 1
a657 1
		     const struct gl_image *bitmap )
d668 3
@
