home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src / dlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-07  |  96.1 KB  |  3,631 lines

  1. /* $Id: dlist.c,v 1.35 1997/10/29 01:29:09 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.5
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: dlist.c,v $
  26.  * Revision 1.35  1997/10/29 01:29:09  brianp
  27.  * added GL_EXT_point_parameters extension from Daniel Barrero
  28.  *
  29.  * Revision 1.34  1997/10/02 00:48:29  brianp
  30.  * removed the EXEC() macro stuff, it caused bugs in gl_save_Color*()
  31.  *
  32.  * Revision 1.33  1997/09/27 00:13:44  brianp
  33.  * added GL_EXT_paletted_texture extension
  34.  *
  35.  * Revision 1.32  1997/09/23 00:57:52  brianp
  36.  * removed list>MAX_DISPLAYLISTS test
  37.  *
  38.  * Revision 1.31  1997/09/22 02:33:58  brianp
  39.  * display lists now implemented with hash table
  40.  *
  41.  * Revision 1.30  1997/07/24 01:25:01  brianp
  42.  * changed precompiled header symbol from PCH to PC_HEADER
  43.  *
  44.  * Revision 1.29  1997/07/09 01:26:12  brianp
  45.  * fixed glDrawPixels() GL_COMPILE_AND_EXECUTE infinite loop (Renaud Cazoulat)
  46.  *
  47.  * Revision 1.28  1997/06/24 01:13:26  brianp
  48.  * initialize image RefCount to 1 for gl_save_TexSubImage[123]D()
  49.  *
  50.  * Revision 1.27  1997/06/20 01:57:57  brianp
  51.  * added gl_save_Color4ubv()
  52.  *
  53.  * Revision 1.26  1997/06/06 02:59:19  brianp
  54.  * renamed destroy_list() to gl_destroy_list()
  55.  *
  56.  * Revision 1.25  1997/05/28 03:24:22  brianp
  57.  * added precompiled header (PCH) support
  58.  *
  59.  * Revision 1.24  1997/05/27 03:13:41  brianp
  60.  * removed some debugging code
  61.  *
  62.  * Revision 1.23  1997/04/30 21:36:22  brianp
  63.  * added casts to gl_TexImage[123]D() calls
  64.  *
  65.  * Revision 1.22  1997/04/28 23:40:47  brianp
  66.  * added #include "rect.h"
  67.  *
  68.  * Revision 1.21  1997/04/24 01:50:53  brianp
  69.  * optimized glColor3f, glColor3fv, glColor4fv
  70.  *
  71.  * Revision 1.20  1997/04/24 00:30:17  brianp
  72.  * optimized glTexCoord2() code
  73.  *
  74.  * Revision 1.19  1997/04/21 01:21:33  brianp
  75.  * added gl_save_Rectf()
  76.  *
  77.  * Revision 1.18  1997/04/20 16:18:15  brianp
  78.  * added glOrtho and glFrustum API pointers
  79.  *
  80.  * Revision 1.17  1997/04/16 23:55:33  brianp
  81.  * added optimized glTexCoord2f code
  82.  *
  83.  * Revision 1.16  1997/04/14 22:18:23  brianp
  84.  * added optimized glVertex3fv code
  85.  *
  86.  * Revision 1.15  1997/04/14 02:00:39  brianp
  87.  * #include "texstate.h" instead of "texture.h"
  88.  *
  89.  * Revision 1.14  1997/04/07 02:58:49  brianp
  90.  * added gl_save_Vertex[23]f() and related code
  91.  *
  92.  * Revision 1.13  1997/04/01 04:26:02  brianp
  93.  * added code for glLoadIdentity(), changed #include's
  94.  *
  95.  * Revision 1.12  1997/02/27 19:58:08  brianp
  96.  * call gl_problem() instead of gl_warning()
  97.  *
  98.  * Revision 1.11  1997/02/09 18:50:18  brianp
  99.  * added GL_EXT_texture3D support
  100.  *
  101.  * Revision 1.10  1997/01/29 18:51:30  brianp
  102.  * small MEMCPY call change for Acorn compiler, per Graham Jones
  103.  *
  104.  * Revision 1.9  1997/01/09 21:25:28  brianp
  105.  * set reference count to one for texture images in display lists
  106.  *
  107.  * Revision 1.8  1996/12/11 20:19:11  brianp
  108.  * abort display list execution if invalid opcode found
  109.  *
  110.  * Revision 1.7  1996/12/09 21:39:23  brianp
  111.  * compare list to MAX_DISPLAYLISTS in gl_IsList()
  112.  *
  113.  * Revision 1.6  1996/12/04 22:14:27  brianp
  114.  * improved the mesa_print_display_list() debug function
  115.  *
  116.  * Revision 1.5  1996/11/07 04:12:45  brianp
  117.  * texture images are now gl_image structs, not gl_texture_image structs
  118.  *
  119.  * Revision 1.4  1996/10/16 00:59:12  brianp
  120.  * fixed bug in gl_save_Lightfv()
  121.  * execution of OPCODE_EDGE_FLAG used enum value instead of boolean
  122.  *
  123.  * Revision 1.3  1996/09/27 01:26:08  brianp
  124.  * removed unused variables
  125.  *
  126.  * Revision 1.2  1996/09/19 00:54:43  brianp
  127.  * fixed bug in gl_save_Rotatef() when in GL_COMPILE_AND_EXECUTE mode
  128.  *
  129.  * Revision 1.1  1996/09/13 01:38:16  brianp
  130.  * Initial revision
  131.  *
  132.  */
  133.  
  134.  
  135. #ifdef PC_HEADER
  136. #include "all.h"
  137. #else
  138. #include <assert.h>
  139. #include <stdio.h>
  140. #include <stdlib.h>
  141. #include <string.h>
  142. #include "accum.h"
  143. #include "alpha.h"
  144. #include "attrib.h"
  145. #include "bitmap.h"
  146. #include "blend.h"
  147. #include "clip.h"
  148. #include "colortab.h"
  149. #include "context.h"
  150. #include "copypix.h"
  151. #include "depth.h"
  152. #include "drawpix.h"
  153. #include "enable.h"
  154. #include "eval.h"
  155. #include "feedback.h"
  156. #include "fog.h"
  157. #include "hash.h"
  158. #include "image.h"
  159. #include "light.h"
  160. #include "lines.h"
  161. #include "dlist.h"
  162. #include "logic.h"
  163. #include "macros.h"
  164. #include "masking.h"
  165. #include "matrix.h"
  166. #include "misc.h"
  167. #include "pixel.h"
  168. #include "points.h"
  169. #include "polygon.h"
  170. #include "rastpos.h"
  171. #include "rect.h"
  172. #include "scissor.h"
  173. #include "stencil.h"
  174. #include "texobj.h"
  175. #include "teximage.h"
  176. #include "texstate.h"
  177. #include "types.h"
  178. #include "vb.h"
  179. #include "vbfill.h"
  180. #include "winpos.h"
  181. #endif
  182.  
  183.  
  184.  
  185. /*
  186. Functions which aren't compiled but executed immediately:
  187.         glIsList
  188.         glGenLists
  189.         glDeleteLists
  190.         glEndList
  191.         glFeedbackBuffer
  192.         glSelectBuffer
  193.         glRenderMode
  194.         glReadPixels
  195.         glPixelStore
  196.         glFlush
  197.         glFinish
  198.         glIsEnabled
  199.         glGet*
  200.  
  201. Functions which cause errors if called while compiling a display list:
  202.         glNewList
  203. */
  204.  
  205.  
  206.  
  207. /*
  208.  * Display list instructions are stored as sequences of "nodes".  Nodes
  209.  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
  210.  * are linked together with a pointer.
  211.  */
  212.  
  213.  
  214. /* How many nodes to allocate at a time: */
  215. #define BLOCK_SIZE 500
  216.  
  217.  
  218. /*
  219.  * Display list opcodes.
  220.  *
  221.  * The fact that these identifiers are assigned consecutive
  222.  * integer values starting at 0 is very important, see InstSize array usage)
  223.  */
  224. typedef enum {
  225.         OPCODE_ACCUM,
  226.         OPCODE_ALPHA_FUNC,
  227.         OPCODE_BEGIN,
  228.         OPCODE_BIND_TEXTURE,
  229.         OPCODE_BITMAP,
  230.         OPCODE_BLEND_COLOR,
  231.         OPCODE_BLEND_EQUATION,
  232.         OPCODE_BLEND_FUNC,
  233.         OPCODE_CALL_LIST,
  234.         OPCODE_CALL_LIST_OFFSET,
  235.         OPCODE_CLEAR,
  236.         OPCODE_CLEAR_ACCUM,
  237.         OPCODE_CLEAR_COLOR,
  238.         OPCODE_CLEAR_DEPTH,
  239.         OPCODE_CLEAR_INDEX,
  240.         OPCODE_CLEAR_STENCIL,
  241.         OPCODE_CLIP_PLANE,
  242.         OPCODE_COLOR_3F,
  243.         OPCODE_COLOR_4F,
  244.         OPCODE_COLOR_4UB,
  245.         OPCODE_COLOR_MASK,
  246.         OPCODE_COLOR_MATERIAL,
  247.         OPCODE_COLOR_TABLE,
  248.         OPCODE_COLOR_SUB_TABLE,
  249.         OPCODE_COPY_PIXELS,
  250.         OPCODE_COPY_TEX_IMAGE1D,
  251.         OPCODE_COPY_TEX_IMAGE2D,
  252.         OPCODE_COPY_TEX_IMAGE3D,
  253.         OPCODE_COPY_TEX_SUB_IMAGE1D,
  254.         OPCODE_COPY_TEX_SUB_IMAGE2D,
  255.         OPCODE_COPY_TEX_SUB_IMAGE3D,
  256.         OPCODE_CULL_FACE,
  257.         OPCODE_DEPTH_FUNC,
  258.         OPCODE_DEPTH_MASK,
  259.         OPCODE_DEPTH_RANGE,
  260.         OPCODE_DISABLE,
  261.         OPCODE_DRAW_BUFFER,
  262.         OPCODE_DRAW_PIXELS,
  263.         OPCODE_EDGE_FLAG,
  264.         OPCODE_ENABLE,
  265.         OPCODE_END,
  266.         OPCODE_EVALCOORD1,
  267.         OPCODE_EVALCOORD2,
  268.         OPCODE_EVALMESH1,
  269.         OPCODE_EVALMESH2,
  270.         OPCODE_EVALPOINT1,
  271.         OPCODE_EVALPOINT2,
  272.         OPCODE_FOG,
  273.         OPCODE_FRONT_FACE,
  274.         OPCODE_FRUSTUM,
  275.         OPCODE_HINT,
  276.         OPCODE_INDEX,
  277.         OPCODE_INDEX_MASK,
  278.         OPCODE_INIT_NAMES,
  279.         OPCODE_LIGHT,
  280.         OPCODE_LIGHT_MODEL,
  281.         OPCODE_LINE_STIPPLE,
  282.         OPCODE_LINE_WIDTH,
  283.         OPCODE_LIST_BASE,
  284.         OPCODE_LOAD_IDENTITY,
  285.         OPCODE_LOAD_MATRIX,
  286.         OPCODE_LOAD_NAME,
  287.         OPCODE_LOGIC_OP,
  288.         OPCODE_MAP1,
  289.         OPCODE_MAP2,
  290.         OPCODE_MAPGRID1,
  291.         OPCODE_MAPGRID2,
  292.         OPCODE_MATERIAL,
  293.         OPCODE_MATRIX_MODE,
  294.         OPCODE_MULT_MATRIX,
  295.         OPCODE_NORMAL,
  296.         OPCODE_ORTHO,
  297.         OPCODE_PASSTHROUGH,
  298.         OPCODE_PIXEL_MAP,
  299.         OPCODE_PIXEL_TRANSFER,
  300.         OPCODE_PIXEL_ZOOM,
  301.         OPCODE_POINT_SIZE,
  302.         OPCODE_POINT_PARAMETERS,
  303.         OPCODE_POLYGON_MODE,
  304.         OPCODE_POLYGON_STIPPLE,
  305.         OPCODE_POLYGON_OFFSET,
  306.         OPCODE_POP_ATTRIB,
  307.         OPCODE_POP_MATRIX,
  308.         OPCODE_POP_NAME,
  309.         OPCODE_PRIORITIZE_TEXTURE,
  310.         OPCODE_PUSH_ATTRIB,
  311.         OPCODE_PUSH_MATRIX,
  312.         OPCODE_PUSH_NAME,
  313.         OPCODE_RASTER_POS,
  314.         OPCODE_RECTF,
  315.         OPCODE_READ_BUFFER,
  316.         OPCODE_SCALE,
  317.         OPCODE_SCISSOR,
  318.         OPCODE_SHADE_MODEL,
  319.         OPCODE_STENCIL_FUNC,
  320.         OPCODE_STENCIL_MASK,
  321.         OPCODE_STENCIL_OP,
  322.         OPCODE_TEXCOORD2,
  323.         OPCODE_TEXCOORD4,
  324.         OPCODE_TEXENV,
  325.         OPCODE_TEXGEN,
  326.         OPCODE_TEXPARAMETER,
  327.         OPCODE_TEX_IMAGE1D,
  328.         OPCODE_TEX_IMAGE2D,
  329.         OPCODE_TEX_IMAGE3D,
  330.         OPCODE_TEX_SUB_IMAGE1D,
  331.         OPCODE_TEX_SUB_IMAGE2D,
  332.         OPCODE_TEX_SUB_IMAGE3D,
  333.         OPCODE_TRANSLATE,
  334.         OPCODE_VERTEX2,
  335.         OPCODE_VERTEX3,
  336.         OPCODE_VERTEX4,
  337.         OPCODE_VIEWPORT,
  338.         OPCODE_WINDOW_POS,
  339.         /* The following two are meta instructions */
  340.         OPCODE_CONTINUE,
  341.         OPCODE_END_OF_LIST
  342. } OpCode;
  343.  
  344.  
  345. /*
  346.  * Each instruction in the display list is stored as a sequence of
  347.  * contiguous nodes in memory.
  348.  * Each node is the union of a variety of datatypes.
  349.  */
  350. typedef union node {
  351.         OpCode          opcode;
  352.         GLboolean       b;
  353.         GLbitfield      bf;
  354.         GLubyte         ub;
  355.         GLshort         s;
  356.         GLushort        us;
  357.         GLint           i;
  358.         GLuint          ui;
  359.         GLenum          e;
  360.         GLfloat         f;
  361.         GLvoid          *data;
  362.         void            *next;  /* If prev node's opcode==OPCODE_CONTINUE */
  363. } Node;
  364.  
  365.  
  366.  
  367. /* Number of nodes of storage needed for each instruction: */
  368. static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
  369.  
  370.  
  371. /* Used while a display list is under construction: */
  372. static Node *CurrentListPtr;    /* Head of list being compiled */
  373. static GLuint CurrentListNum;   /* Number of the list being compiled */
  374. static Node *CurrentBlock;      /* Pointer to current block of nodes */
  375. static GLuint CurrentPos;       /* Index into current block of nodes */
  376.  
  377.  
  378.  
  379.  
  380. /**********************************************************************/
  381. /*****                           Private                          *****/
  382. /**********************************************************************/
  383.  
  384.  
  385. /*
  386.  * Allocate space for a display list instruction.
  387.  * Input:  opcode - type of instruction
  388.  *         argcount - number of arguments following the instruction
  389.  * Return: pointer to first node in the instruction
  390.  */
  391. static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
  392. {
  393.    Node *n, *newblock;
  394.    GLuint count = InstSize[opcode];
  395.  
  396.    assert( count == argcount+1 );
  397.  
  398.    if (CurrentPos + count + 2 > BLOCK_SIZE) {
  399.       /* This block is full.  Allocate a new block and chain to it */
  400.       n = CurrentBlock + CurrentPos;
  401.       n[0].opcode = OPCODE_CONTINUE;
  402.       newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
  403.       if (!newblock) {
  404.          gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
  405.          return NULL;
  406.       }
  407.       n[1].next = (Node *) newblock;
  408.       CurrentBlock = newblock;
  409.       CurrentPos = 0;
  410.    }
  411.  
  412.    n = CurrentBlock + CurrentPos;
  413.    CurrentPos += count;
  414.  
  415.    n[0].opcode = opcode;
  416.  
  417.    return n;
  418. }
  419.  
  420.  
  421.  
  422. /*
  423.  * Make an empty display list.  This is used by glGenLists() to
  424.  * reserver display list IDs.
  425.  */
  426. static Node *make_empty_list( void )
  427. {
  428.    Node *n = (Node *) malloc( sizeof(Node) );
  429.    n[0].opcode = OPCODE_END_OF_LIST;
  430.    return n;
  431. }
  432.  
  433.  
  434.  
  435. /*
  436.  * Destroy all nodes in a display list.
  437.  * Input:  list - display list number
  438.  */
  439. void gl_destroy_list( GLcontext *ctx, GLuint list )
  440. {
  441.    Node *n, *block;
  442.    GLboolean done;
  443.  
  444.    block = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  445.    n = block;
  446.  
  447.    done = block ? GL_FALSE : GL_TRUE;
  448.    while (!done) {
  449.       switch (n[0].opcode) {
  450.          /* special cases first */
  451.          case OPCODE_MAP1:
  452.             gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data );
  453.             n += InstSize[n[0].opcode];
  454.             break;
  455.          case OPCODE_MAP2:
  456.             gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data );
  457.             n += InstSize[n[0].opcode];
  458.             break;
  459.          case OPCODE_DRAW_PIXELS:
  460.             free( n[5].data );
  461.             n += InstSize[n[0].opcode];
  462.             break;
  463.          case OPCODE_BITMAP:
  464.             gl_free_image( (struct gl_image *) n[7].data );
  465.             n += InstSize[n[0].opcode];
  466.             break;
  467.          case OPCODE_COLOR_TABLE:
  468.             gl_free_image( (struct gl_image *) n[3].data );
  469.             n += InstSize[n[0].opcode];
  470.             break;
  471.          case OPCODE_COLOR_SUB_TABLE:
  472.             gl_free_image( (struct gl_image *) n[3].data );
  473.             n += InstSize[n[0].opcode];
  474.             break;
  475.          case OPCODE_POLYGON_STIPPLE:
  476.             free( n[1].data );
  477.             n += InstSize[n[0].opcode];
  478.             break;
  479.          case OPCODE_TEX_IMAGE1D:
  480.             gl_free_image( (struct gl_image *) n[8].data );
  481.             n += InstSize[n[0].opcode];
  482.             break;
  483.          case OPCODE_TEX_IMAGE2D:
  484.             gl_free_image( (struct gl_image *) n[9].data );
  485.             n += InstSize[n[0].opcode];
  486.             break;
  487.          case OPCODE_TEX_SUB_IMAGE1D:
  488.             {
  489.                struct gl_image *image;
  490.                image = (struct gl_image *) n[7].data;
  491.                gl_free_image( image );
  492.             }
  493.             break;
  494.          case OPCODE_TEX_SUB_IMAGE2D:
  495.             {
  496.                struct gl_image *image;
  497.                image = (struct gl_image *) n[9].data;
  498.                gl_free_image( image );
  499.             }
  500.             break;
  501.          case OPCODE_CONTINUE:
  502.             n = (Node *) n[1].next;
  503.             free( block );
  504.             block = n;
  505.             break;
  506.          case OPCODE_END_OF_LIST:
  507.             free( block );
  508.             done = GL_TRUE;
  509.             break;
  510.          default:
  511.             /* Most frequent case */
  512.             n += InstSize[n[0].opcode];
  513.             break;
  514.       }
  515.    }
  516.  
  517.    HashRemove(ctx->Shared->DisplayList, list);
  518. }
  519.  
  520.  
  521.  
  522. /*
  523.  * Translate the nth element of list from type to GLuint.
  524.  */
  525. static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
  526. {
  527.    GLbyte *bptr;
  528.    GLubyte *ubptr;
  529.    GLshort *sptr;
  530.    GLushort *usptr;
  531.    GLint *iptr;
  532.    GLuint *uiptr;
  533.    GLfloat *fptr;
  534.  
  535.    switch (type) {
  536.       case GL_BYTE:
  537.          bptr = (GLbyte *) list;
  538.          return (GLuint) *(bptr+n);
  539.       case GL_UNSIGNED_BYTE:
  540.          ubptr = (GLubyte *) list;
  541.          return (GLuint) *(ubptr+n);
  542.       case GL_SHORT:
  543.          sptr = (GLshort *) list;
  544.          return (GLuint) *(sptr+n);
  545.       case GL_UNSIGNED_SHORT:
  546.          usptr = (GLushort *) list;
  547.          return (GLuint) *(usptr+n);
  548.       case GL_INT:
  549.          iptr = (GLint *) list;
  550.          return (GLuint) *(iptr+n);
  551.       case GL_UNSIGNED_INT:
  552.          uiptr = (GLuint *) list;
  553.          return (GLuint) *(uiptr+n);
  554.       case GL_FLOAT:
  555.          fptr = (GLfloat *) list;
  556.          return (GLuint) *(fptr+n);
  557.       case GL_2_BYTES:
  558.          ubptr = ((GLubyte *) list) + 2*n;
  559.          return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
  560.       case GL_3_BYTES:
  561.          ubptr = ((GLubyte *) list) + 3*n;
  562.          return (GLuint) *ubptr * 65536
  563.               + (GLuint) *(ubptr+1) * 256
  564.               + (GLuint) *(ubptr+2);
  565.       case GL_4_BYTES:
  566.          ubptr = ((GLubyte *) list) + 4*n;
  567.          return (GLuint) *ubptr * 16777216
  568.               + (GLuint) *(ubptr+1) * 65536
  569.               + (GLuint) *(ubptr+2) * 256
  570.               + (GLuint) *(ubptr+3);
  571.       default:
  572.          return 0;
  573.    }
  574. }
  575.  
  576.  
  577.  
  578.  
  579. /**********************************************************************/
  580. /*****                        Public                              *****/
  581. /**********************************************************************/
  582.  
  583. void gl_init_lists( void )
  584. {
  585.    static int init_flag = 0;
  586.  
  587.    if (init_flag==0) {
  588.       CurrentListPtr = CurrentBlock = NULL;
  589.       CurrentListNum = 0;
  590.  
  591.       InstSize[OPCODE_ACCUM] = 3;
  592.       InstSize[OPCODE_ALPHA_FUNC] = 3;
  593.       InstSize[OPCODE_BEGIN] = 2;
  594.       InstSize[OPCODE_BIND_TEXTURE] = 3;
  595.       InstSize[OPCODE_BITMAP] = 8;
  596.       InstSize[OPCODE_BLEND_COLOR] = 5;
  597.       InstSize[OPCODE_BLEND_EQUATION] = 2;
  598.       InstSize[OPCODE_BLEND_FUNC] = 3;
  599.       InstSize[OPCODE_CALL_LIST] = 2;
  600.       InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
  601.       InstSize[OPCODE_CLEAR] = 2;
  602.       InstSize[OPCODE_CLEAR_ACCUM] = 5;
  603.       InstSize[OPCODE_CLEAR_COLOR] = 5;
  604.       InstSize[OPCODE_CLEAR_DEPTH] = 2;
  605.       InstSize[OPCODE_CLEAR_INDEX] = 2;
  606.       InstSize[OPCODE_CLEAR_STENCIL] = 2;
  607.       InstSize[OPCODE_CLIP_PLANE] = 6;
  608.       InstSize[OPCODE_COLOR_3F] = 4;
  609.       InstSize[OPCODE_COLOR_4F] = 5;
  610.       InstSize[OPCODE_COLOR_4UB] = 5;
  611.       InstSize[OPCODE_COLOR_MASK] = 5;
  612.       InstSize[OPCODE_COLOR_MATERIAL] = 3;
  613.       InstSize[OPCODE_COLOR_TABLE] = 4;
  614.       InstSize[OPCODE_COLOR_SUB_TABLE] = 4;
  615.       InstSize[OPCODE_COPY_PIXELS] = 6;
  616.       InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
  617.       InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
  618.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
  619.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
  620.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
  621.       InstSize[OPCODE_CULL_FACE] = 2;
  622.       InstSize[OPCODE_DEPTH_FUNC] = 2;
  623.       InstSize[OPCODE_DEPTH_MASK] = 2;
  624.       InstSize[OPCODE_DEPTH_RANGE] = 3;
  625.       InstSize[OPCODE_DISABLE] = 2;
  626.       InstSize[OPCODE_DRAW_BUFFER] = 2;
  627.       InstSize[OPCODE_DRAW_PIXELS] = 6;
  628.       InstSize[OPCODE_ENABLE] = 2;
  629.       InstSize[OPCODE_EDGE_FLAG] = 2;
  630.       InstSize[OPCODE_END] = 1;
  631.       InstSize[OPCODE_EVALCOORD1] = 2;
  632.       InstSize[OPCODE_EVALCOORD2] = 3;
  633.       InstSize[OPCODE_EVALMESH1] = 4;
  634.       InstSize[OPCODE_EVALMESH2] = 6;
  635.       InstSize[OPCODE_EVALPOINT1] = 2;
  636.       InstSize[OPCODE_EVALPOINT2] = 3;
  637.       InstSize[OPCODE_FOG] = 6;
  638.       InstSize[OPCODE_FRONT_FACE] = 2;
  639.       InstSize[OPCODE_FRUSTUM] = 7;
  640.       InstSize[OPCODE_HINT] = 3;
  641.       InstSize[OPCODE_INDEX] = 2;
  642.       InstSize[OPCODE_INDEX_MASK] = 2;
  643.       InstSize[OPCODE_INIT_NAMES] = 1;
  644.       InstSize[OPCODE_LIGHT] = 7;
  645.       InstSize[OPCODE_LIGHT_MODEL] = 6;
  646.       InstSize[OPCODE_LINE_STIPPLE] = 3;
  647.       InstSize[OPCODE_LINE_WIDTH] = 2;
  648.       InstSize[OPCODE_LIST_BASE] = 2;
  649.       InstSize[OPCODE_LOAD_IDENTITY] = 1;
  650.       InstSize[OPCODE_LOAD_MATRIX] = 17;
  651.       InstSize[OPCODE_LOAD_NAME] = 2;
  652.       InstSize[OPCODE_LOGIC_OP] = 2;
  653.       InstSize[OPCODE_MAP1] = 7;
  654.       InstSize[OPCODE_MAP2] = 11;
  655.       InstSize[OPCODE_MAPGRID1] = 4;
  656.       InstSize[OPCODE_MAPGRID2] = 7;
  657.       InstSize[OPCODE_MATERIAL] = 7;
  658.       InstSize[OPCODE_MATRIX_MODE] = 2;
  659.       InstSize[OPCODE_MULT_MATRIX] = 17;
  660.       InstSize[OPCODE_NORMAL] = 4;
  661.       InstSize[OPCODE_ORTHO] = 7;
  662.       InstSize[OPCODE_PASSTHROUGH] = 2;
  663.       InstSize[OPCODE_PIXEL_MAP] = 4;
  664.       InstSize[OPCODE_PIXEL_TRANSFER] = 3;
  665.       InstSize[OPCODE_PIXEL_ZOOM] = 3;
  666.       InstSize[OPCODE_POINT_SIZE] = 2;
  667.       InstSize[OPCODE_POINT_PARAMETERS] = 5;
  668.       InstSize[OPCODE_POLYGON_MODE] = 3;
  669.       InstSize[OPCODE_POLYGON_STIPPLE] = 2;
  670.       InstSize[OPCODE_POLYGON_OFFSET] = 3;
  671.       InstSize[OPCODE_POP_ATTRIB] = 1;
  672.       InstSize[OPCODE_POP_MATRIX] = 1;
  673.       InstSize[OPCODE_POP_NAME] = 1;
  674.       InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
  675.       InstSize[OPCODE_PUSH_ATTRIB] = 2;
  676.       InstSize[OPCODE_PUSH_MATRIX] = 1;
  677.       InstSize[OPCODE_PUSH_NAME] = 2;
  678.       InstSize[OPCODE_RASTER_POS] = 5;
  679.       InstSize[OPCODE_RECTF] = 5;
  680.       InstSize[OPCODE_READ_BUFFER] = 2;
  681.       InstSize[OPCODE_SCALE] = 4;
  682.       InstSize[OPCODE_SCISSOR] = 5;
  683.       InstSize[OPCODE_STENCIL_FUNC] = 4;
  684.       InstSize[OPCODE_STENCIL_MASK] = 2;
  685.       InstSize[OPCODE_STENCIL_OP] = 4;
  686.       InstSize[OPCODE_SHADE_MODEL] = 2;
  687.       InstSize[OPCODE_TEXCOORD2] = 3;
  688.       InstSize[OPCODE_TEXCOORD4] = 5;
  689.       InstSize[OPCODE_TEXENV] = 7;
  690.       InstSize[OPCODE_TEXGEN] = 7;
  691.       InstSize[OPCODE_TEXPARAMETER] = 7;
  692.       InstSize[OPCODE_TEX_IMAGE1D] = 9;
  693.       InstSize[OPCODE_TEX_IMAGE2D] = 10;
  694.       InstSize[OPCODE_TEX_IMAGE3D] = 11;
  695.       InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
  696.       InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
  697.       InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
  698.       InstSize[OPCODE_TRANSLATE] = 4;
  699.       InstSize[OPCODE_VERTEX2] = 3;
  700.       InstSize[OPCODE_VERTEX3] = 4;
  701.       InstSize[OPCODE_VERTEX4] = 5;
  702.       InstSize[OPCODE_VIEWPORT] = 5;
  703.       InstSize[OPCODE_WINDOW_POS] = 5;
  704.       InstSize[OPCODE_CONTINUE] = 2;
  705.       InstSize[OPCODE_END_OF_LIST] = 1;
  706.    }
  707.    init_flag = 1;
  708. }
  709.  
  710.  
  711.  
  712. /*
  713.  * Return the name of the display list currently being compiled.  This
  714.  * function is only called by glGet().
  715.  */
  716. GLint gl_list_index( void )
  717. {
  718.    return CurrentListNum;
  719. }
  720.  
  721.  
  722.  
  723. /*
  724.  * Display List compilation functions
  725.  */
  726.  
  727.  
  728. void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
  729. {
  730.    Node *n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
  731.    if (n) {
  732.       n[1].e = op;
  733.       n[2].f = value;
  734.    }
  735.    if (ctx->ExecuteFlag) {
  736.       (*ctx->Exec.Accum)( ctx, op, value );
  737.    }
  738. }
  739.  
  740.  
  741. void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
  742. {
  743.    Node *n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
  744.    if (n) {
  745.       n[1].e = func;
  746.       n[2].f = (GLfloat) ref;
  747.    }
  748.    if (ctx->ExecuteFlag) {
  749.       (*ctx->Exec.AlphaFunc)( ctx, func, ref );
  750.    }
  751. }
  752.  
  753.  
  754. void gl_save_Begin( GLcontext *ctx, GLenum mode )
  755. {
  756.    Node *n = alloc_instruction( ctx, OPCODE_BEGIN, 1 );
  757.    if (n) {
  758.       n[1].e = mode;
  759.    }
  760.    if (ctx->ExecuteFlag) {
  761.       (*ctx->Exec.Begin)( ctx, mode );
  762.    }
  763. }
  764.  
  765.  
  766. void gl_save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
  767. {
  768.    Node *n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
  769.    if (n) {
  770.       n[1].e = target;
  771.       n[2].ui = texture;
  772.    }
  773.    if (ctx->ExecuteFlag) {
  774.       (*ctx->Exec.BindTexture)( ctx, target, texture );
  775.    }
  776. }
  777.  
  778.  
  779. void gl_save_Bitmap( GLcontext *ctx,
  780.                      GLsizei width, GLsizei height,
  781.                      GLfloat xorig, GLfloat yorig,
  782.                      GLfloat xmove, GLfloat ymove,
  783.                      const struct gl_image *bitmap )
  784. {
  785.    Node *n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
  786.    if (n) {
  787.       n[1].i = (GLint) width;
  788.       n[2].i = (GLint) height;
  789.       n[3].f = xorig;
  790.       n[4].f = yorig;
  791.       n[5].f = xmove;
  792.       n[6].f = ymove;
  793.       n[7].data = (void *) bitmap;
  794.    }
  795.    if (ctx->ExecuteFlag) {
  796.       (*ctx->Exec.Bitmap)( ctx, width, height,
  797.                     xorig, yorig, xmove, ymove, bitmap );
  798.    }
  799. }
  800.  
  801.  
  802. void gl_save_BlendEquation( GLcontext *ctx, GLenum mode )
  803. {
  804.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
  805.    if (n) {
  806.       n[1].e = mode;
  807.    }
  808.    if (ctx->ExecuteFlag) {
  809.       (*ctx->Exec.BlendEquation)( ctx, mode );
  810.    }
  811. }
  812.  
  813.  
  814. void gl_save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
  815. {
  816.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
  817.    if (n) {
  818.       n[1].e = sfactor;
  819.       n[2].e = dfactor;
  820.    }
  821.    if (ctx->ExecuteFlag) {
  822.       (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor );
  823.    }
  824. }
  825.  
  826.  
  827. void gl_save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green,
  828.                          GLfloat blue, GLfloat alpha )
  829. {
  830.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
  831.    if (n) {
  832.       n[1].f = red;
  833.       n[2].f = green;
  834.       n[3].f = blue;
  835.       n[4].f = alpha;
  836.    }
  837.    if (ctx->ExecuteFlag) {
  838.       (*ctx->Exec.BlendColor)( ctx, red, green, blue, alpha );
  839.    }
  840. }
  841.  
  842.  
  843. void gl_save_CallList( GLcontext *ctx, GLuint list )
  844. {
  845.    Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
  846.    if (n) {
  847.       n[1].ui = list;
  848.    }
  849.    if (ctx->ExecuteFlag) {
  850.       (*ctx->Exec.CallList)( ctx, list );
  851.    }
  852. }
  853.  
  854.  
  855. void gl_save_CallLists( GLcontext *ctx,
  856.                         GLsizei n, GLenum type, const GLvoid *lists )
  857. {
  858.    GLuint i;
  859.  
  860.    for (i=0;i<n;i++) {
  861.       GLuint list = translate_id( i, type, lists );
  862.       Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
  863.       if (n) {
  864.          n[1].ui = list;
  865.       }
  866.    }
  867.    if (ctx->ExecuteFlag) {
  868.       (*ctx->Exec.CallLists)( ctx, n, type, lists );
  869.    }
  870. }
  871.  
  872.  
  873. void gl_save_Clear( GLcontext *ctx, GLbitfield mask )
  874. {
  875.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
  876.    if (n) {
  877.       n[1].bf = mask;
  878.    }
  879.    if (ctx->ExecuteFlag) {
  880.       (*ctx->Exec.Clear)( ctx, mask );
  881.    }
  882. }
  883.  
  884.  
  885. void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
  886.                          GLfloat blue, GLfloat alpha )
  887. {
  888.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
  889.    if (n) {
  890.       n[1].f = red;
  891.       n[2].f = green;
  892.       n[3].f = blue;
  893.       n[4].f = alpha;
  894.    }
  895.    if (ctx->ExecuteFlag) {
  896.       (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha );
  897.    }
  898. }
  899.  
  900.  
  901. void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
  902.                          GLclampf blue, GLclampf alpha )
  903. {
  904.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
  905.    if (n) {
  906.       n[1].f = red;
  907.       n[2].f = green;
  908.       n[3].f = blue;
  909.       n[4].f = alpha;
  910.    }
  911.    if (ctx->ExecuteFlag) {
  912.       (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha );
  913.    }
  914. }
  915.  
  916.  
  917. void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth )
  918. {
  919.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
  920.    if (n) {
  921.       n[1].f = (GLfloat) depth;
  922.    }
  923.    if (ctx->ExecuteFlag) {
  924.       (*ctx->Exec.ClearDepth)( ctx, depth );
  925.    }
  926. }
  927.  
  928.  
  929. void gl_save_ClearIndex( GLcontext *ctx, GLfloat c )
  930. {
  931.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
  932.    if (n) {
  933.       n[1].f = c;
  934.    }
  935.    if (ctx->ExecuteFlag) {
  936.       (*ctx->Exec.ClearIndex)( ctx, c );
  937.    }
  938. }
  939.  
  940.  
  941. void gl_save_ClearStencil( GLcontext *ctx, GLint s )
  942. {
  943.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
  944.    if (n) {
  945.       n[1].i = s;
  946.    }
  947.    if (ctx->ExecuteFlag) {
  948.       (*ctx->Exec.ClearStencil)( ctx, s );
  949.    }
  950. }
  951.  
  952.  
  953. void gl_save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
  954. {
  955.    Node *n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
  956.    if (n) {
  957.       n[1].e = plane;
  958.       n[2].f = equ[0];
  959.       n[3].f = equ[1];
  960.       n[4].f = equ[2];
  961.       n[5].f = equ[3];
  962.    }
  963.    if (ctx->ExecuteFlag) {
  964.       (*ctx->Exec.ClipPlane)( ctx, plane, equ );
  965.    }
  966. }
  967.  
  968.  
  969. void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b )
  970. {
  971.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
  972.    if (n) {
  973.       n[1].f = r;
  974.       n[2].f = g;
  975.       n[3].f = b;
  976.    }
  977.    if (ctx->ExecuteFlag) {
  978.       (*ctx->Exec.Color3f)( ctx, r, g, b );
  979.    }
  980. }
  981.  
  982.  
  983. void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c )
  984. {
  985.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
  986.    if (n) {
  987.       n[1].f = c[0];
  988.       n[2].f = c[1];
  989.       n[3].f = c[2];
  990.    }
  991.    if (ctx->ExecuteFlag) {
  992.       (*ctx->Exec.Color3fv)( ctx, c );
  993.    }
  994. }
  995.  
  996.  
  997. void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g,
  998.                                       GLfloat b, GLfloat a )
  999. {
  1000.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
  1001.    if (n) {
  1002.       n[1].f = r;
  1003.       n[2].f = g;
  1004.       n[3].f = b;
  1005.       n[4].f = a;
  1006.    }
  1007.    if (ctx->ExecuteFlag) {
  1008.       (*ctx->Exec.Color4f)( ctx, r, g, b, a );
  1009.    }
  1010. }
  1011.  
  1012.  
  1013. void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c )
  1014. {
  1015.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
  1016.    if (n) {
  1017.       n[1].f = c[0];
  1018.       n[2].f = c[1];
  1019.       n[3].f = c[2];
  1020.       n[4].f = c[3];
  1021.    }
  1022.    if (ctx->ExecuteFlag) {
  1023.       (*ctx->Exec.Color4fv)( ctx, c );
  1024.    }
  1025. }
  1026.  
  1027.  
  1028. void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g,
  1029.                                        GLubyte b, GLubyte a )
  1030. {
  1031.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
  1032.    if (n) {
  1033.       n[1].ub = r;
  1034.       n[2].ub = g;
  1035.       n[3].ub = b;
  1036.       n[4].ub = a;
  1037.    }
  1038.    if (ctx->ExecuteFlag) {
  1039.       (*ctx->Exec.Color4ub)( ctx, r, g, b, a );
  1040.    }
  1041. }
  1042.  
  1043.  
  1044. void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c )
  1045. {
  1046.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
  1047.    if (n) {
  1048.       n[1].ub = c[0];
  1049.       n[2].ub = c[1];
  1050.       n[3].ub = c[2];
  1051.       n[4].ub = c[3];
  1052.    }
  1053.    if (ctx->ExecuteFlag) {
  1054.       (*ctx->Exec.Color4ubv)( ctx, c );
  1055.    }
  1056. }
  1057.  
  1058.  
  1059. void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
  1060.                         GLboolean blue, GLboolean alpha )
  1061. {
  1062.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
  1063.    if (n) {
  1064.       n[1].b = red;
  1065.       n[2].b = green;
  1066.       n[3].b = blue;
  1067.       n[4].b = alpha;
  1068.    }
  1069.    if (ctx->ExecuteFlag) {
  1070.       (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha );
  1071.    }
  1072. }
  1073.  
  1074.  
  1075. void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
  1076. {
  1077.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
  1078.    if (n) {
  1079.       n[1].e = face;
  1080.       n[2].e = mode;
  1081.    }
  1082.    if (ctx->ExecuteFlag) {
  1083.       (*ctx->Exec.ColorMaterial)( ctx, face, mode );
  1084.    }
  1085. }
  1086.  
  1087.  
  1088. void gl_save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
  1089.                          struct gl_image *table )
  1090. {
  1091.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
  1092.    if (n) {
  1093.       n[1].e = target;
  1094.       n[2].e = internalFormat;
  1095.       n[3].data = (GLvoid *) table;
  1096.       if (table) {
  1097.          /* must retain this image */
  1098.          table->RefCount = 1;
  1099.       }
  1100.    }
  1101.    if (ctx->ExecuteFlag) {
  1102.       (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table );
  1103.    }
  1104. }
  1105.  
  1106.  
  1107. void gl_save_ColorSubTable( GLcontext *ctx, GLenum target,
  1108.                             GLsizei start, struct gl_image *data )
  1109. {
  1110.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
  1111.    if (n) {
  1112.       n[1].e = target;
  1113.       n[2].i = start;
  1114.       n[3].data = (GLvoid *) data;
  1115.       if (data) {
  1116.          /* must retain this image */
  1117.          data->RefCount = 1;
  1118.       }
  1119.    }
  1120.    if (ctx->ExecuteFlag) {
  1121.       (*ctx->Exec.ColorSubTable)( ctx, target, start, data );
  1122.    }
  1123. }
  1124.  
  1125.  
  1126.  
  1127. void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
  1128.                          GLsizei width, GLsizei height, GLenum type )
  1129. {
  1130.    Node *n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
  1131.    if (n) {
  1132.       n[1].i = x;
  1133.       n[2].i = y;
  1134.       n[3].i = (GLint) width;
  1135.       n[4].i = (GLint) height;
  1136.       n[5].e = type;
  1137.    }
  1138.    if (ctx->ExecuteFlag) {
  1139.       (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type );
  1140.    }
  1141. }
  1142.  
  1143.  
  1144.  
  1145. void gl_save_CopyTexImage1D( GLcontext *ctx,
  1146.                              GLenum target, GLint level,
  1147.                              GLenum internalformat,
  1148.                              GLint x, GLint y, GLsizei width,
  1149.                              GLint border )
  1150. {
  1151.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
  1152.    if (n) {
  1153.       n[1].e = target;
  1154.       n[2].i = level;
  1155.       n[3].e = internalformat;
  1156.       n[4].i = x;
  1157.       n[5].i = y;
  1158.       n[6].i = width;
  1159.       n[7].i = border;
  1160.    }
  1161.    if (ctx->ExecuteFlag) {
  1162.       (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat,
  1163.                             x, y, width, border );
  1164.    }
  1165. }
  1166.  
  1167.  
  1168. void gl_save_CopyTexImage2D( GLcontext *ctx,
  1169.                              GLenum target, GLint level,
  1170.                              GLenum internalformat,
  1171.                              GLint x, GLint y, GLsizei width,
  1172.                              GLsizei height, GLint border )
  1173. {
  1174.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
  1175.    if (n) {
  1176.       n[1].e = target;
  1177.       n[2].i = level;
  1178.       n[3].e = internalformat;
  1179.       n[4].i = x;
  1180.       n[5].i = y;
  1181.       n[6].i = width;
  1182.       n[7].i = height;
  1183.       n[8].i = border;
  1184.    }
  1185.    if (ctx->ExecuteFlag) {
  1186.       (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat,
  1187.                             x, y, width, height, border );
  1188.    }
  1189. }
  1190.  
  1191.  
  1192.  
  1193. void gl_save_CopyTexSubImage1D( GLcontext *ctx,
  1194.                                 GLenum target, GLint level,
  1195.                                 GLint xoffset, GLint x, GLint y,
  1196.                                 GLsizei width )
  1197. {
  1198.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
  1199.    if (n) {
  1200.       n[1].e = target;
  1201.       n[2].i = level;
  1202.       n[3].i = xoffset;
  1203.       n[4].i = x;
  1204.       n[5].i = y;
  1205.       n[6].i = width;
  1206.    }
  1207.    if (ctx->ExecuteFlag) {
  1208.       (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width );
  1209.    }
  1210. }
  1211.  
  1212.  
  1213. void gl_save_CopyTexSubImage2D( GLcontext *ctx,
  1214.                                 GLenum target, GLint level,
  1215.                                 GLint xoffset, GLint yoffset,
  1216.                                 GLint x, GLint y,
  1217.                                 GLsizei width, GLint height )
  1218. {
  1219.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
  1220.    if (n) {
  1221.       n[1].e = target;
  1222.       n[2].i = level;
  1223.       n[3].i = xoffset;
  1224.       n[4].i = yoffset;
  1225.       n[5].i = x;
  1226.       n[6].i = y;
  1227.       n[7].i = width;
  1228.       n[8].i = height;
  1229.    }
  1230.    if (ctx->ExecuteFlag) {
  1231.       (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset,
  1232.                                x, y, width, height );
  1233.    }
  1234. }
  1235.  
  1236.  
  1237. void gl_save_CopyTexSubImage3DEXT( GLcontext *ctx,
  1238.                                    GLenum target, GLint level,
  1239.                                    GLint xoffset, GLint yoffset, GLint zoffset,
  1240.                                    GLint x, GLint y,
  1241.                                    GLsizei width, GLint height )
  1242. {
  1243.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
  1244.    if (n) {
  1245.       n[1].e = target;
  1246.       n[2].i = level;
  1247.       n[3].i = xoffset;
  1248.       n[4].i = yoffset;
  1249.       n[5].i = zoffset;
  1250.       n[6].i = x;
  1251.       n[7].i = y;
  1252.       n[8].i = width;
  1253.       n[9].i = height;
  1254.    }
  1255.    if (ctx->ExecuteFlag) {
  1256.       (*ctx->Exec.CopyTexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
  1257.                                x, y, width, height );
  1258.    }
  1259. }
  1260.  
  1261.  
  1262. void gl_save_CullFace( GLcontext *ctx, GLenum mode )
  1263. {
  1264.    Node *n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
  1265.    if (n) {
  1266.       n[1].e = mode;
  1267.    }
  1268.    if (ctx->ExecuteFlag) {
  1269.       (*ctx->Exec.CullFace)( ctx, mode );
  1270.    }
  1271. }
  1272.  
  1273.  
  1274. void gl_save_DepthFunc( GLcontext *ctx, GLenum func )
  1275. {
  1276.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
  1277.    if (n) {
  1278.       n[1].e = func;
  1279.    }
  1280.    if (ctx->ExecuteFlag) {
  1281.       (*ctx->Exec.DepthFunc)( ctx, func );
  1282.    }
  1283. }
  1284.  
  1285.  
  1286. void gl_save_DepthMask( GLcontext *ctx, GLboolean mask )
  1287. {
  1288.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
  1289.    if (n) {
  1290.       n[1].b = mask;
  1291.    }
  1292.    if (ctx->ExecuteFlag) {
  1293.       (*ctx->Exec.DepthMask)( ctx, mask );
  1294.    }
  1295. }
  1296.  
  1297.  
  1298. void gl_save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
  1299. {
  1300.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
  1301.    if (n) {
  1302.       n[1].f = (GLfloat) nearval;
  1303.       n[2].f = (GLfloat) farval;
  1304.    }
  1305.    if (ctx->ExecuteFlag) {
  1306.       (*ctx->Exec.DepthRange)( ctx, nearval, farval );
  1307.    }
  1308. }
  1309.  
  1310.  
  1311. void gl_save_Disable( GLcontext *ctx, GLenum cap )
  1312. {
  1313.    Node *n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
  1314.    if (n) {
  1315.       n[1].e = cap;
  1316.    }
  1317.    if (ctx->ExecuteFlag) {
  1318.       (*ctx->Exec.Disable)( ctx, cap );
  1319.    }
  1320. }
  1321.  
  1322.  
  1323. void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode )
  1324. {
  1325.    Node *n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
  1326.    if (n) {
  1327.       n[1].e = mode;
  1328.    }
  1329.    if (ctx->ExecuteFlag) {
  1330.       (*ctx->Exec.DrawBuffer)( ctx, mode );
  1331.    }
  1332. }
  1333.  
  1334.  
  1335. void gl_save_DrawPixels( GLcontext *ctx, GLsizei width, GLsizei height,
  1336.                          GLenum format, GLenum type, const GLvoid *pixels )
  1337. {
  1338.    Node *n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 );
  1339.    if (n) {
  1340.       n[1].i = (GLint) width;
  1341.       n[2].i = (GLint) height;
  1342.       n[3].e = format;
  1343.       n[4].e = type;
  1344.       n[5].data = (GLvoid *) pixels;
  1345.    }
  1346. /* Special case:  gl_DrawPixels takes care of GL_COMPILE_AND_EXECUTE case!
  1347.    if (ctx->ExecuteFlag) {
  1348.       (*ctx->Exec.DrawPixels)( ctx, width, height, format, type, pixels );
  1349.    }
  1350. */
  1351. }
  1352.  
  1353.  
  1354. void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag )
  1355. {
  1356.    Node *n = alloc_instruction( ctx, OPCODE_EDGE_FLAG, 1 );
  1357.    if (n) {
  1358.       n[1].b = flag;
  1359.    }
  1360.    if (ctx->ExecuteFlag) {
  1361.       (*ctx->Exec.EdgeFlag)( ctx, flag );
  1362.    }
  1363. }
  1364.  
  1365.  
  1366. void gl_save_Enable( GLcontext *ctx, GLenum cap )
  1367. {
  1368.    Node *n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
  1369.    if (n) {
  1370.       n[1].e = cap;
  1371.    }
  1372.    if (ctx->ExecuteFlag) {
  1373.       (*ctx->Exec.Enable)( ctx, cap );
  1374.    }
  1375. }
  1376.  
  1377.  
  1378. void gl_save_End( GLcontext *ctx )
  1379. {
  1380.    (void) alloc_instruction( ctx, OPCODE_END, 0 );
  1381.    if (ctx->ExecuteFlag) {
  1382.       (*ctx->Exec.End)( ctx );
  1383.    }
  1384. }
  1385.  
  1386.  
  1387. void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u )
  1388. {
  1389.    Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD1, 1 );
  1390.    if (n) {
  1391.       n[1].f = u;
  1392.    }
  1393.    if (ctx->ExecuteFlag) {
  1394.       (*ctx->Exec.EvalCoord1f)( ctx, u );
  1395.    }
  1396. }
  1397.  
  1398.  
  1399. void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v )
  1400. {
  1401.    Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD2, 2 );
  1402.    if (n) {
  1403.       n[1].f = u;
  1404.       n[2].f = v;
  1405.    }
  1406.    if (ctx->ExecuteFlag) {
  1407.       (*ctx->Exec.EvalCoord2f)( ctx, u, v );
  1408.    }
  1409. }
  1410.  
  1411.  
  1412. void gl_save_EvalMesh1( GLcontext *ctx,
  1413.                         GLenum mode, GLint i1, GLint i2 )
  1414. {
  1415.    Node *n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
  1416.    if (n) {
  1417.       n[1].e = mode;
  1418.       n[2].i = i1;
  1419.       n[3].i = i2;
  1420.    }
  1421.    if (ctx->ExecuteFlag) {
  1422.       (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 );
  1423.    }
  1424. }
  1425.  
  1426.  
  1427. void gl_save_EvalMesh2( GLcontext *ctx, 
  1428.                         GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
  1429. {
  1430.    Node *n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
  1431.    if (n) {
  1432.       n[1].e = mode;
  1433.       n[2].i = i1;
  1434.       n[3].i = i2;
  1435.       n[4].i = j1;
  1436.       n[5].i = j2;
  1437.    }
  1438.    if (ctx->ExecuteFlag) {
  1439.       (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 );
  1440.    }
  1441. }
  1442.  
  1443.  
  1444. void gl_save_EvalPoint1( GLcontext *ctx, GLint i )
  1445. {
  1446.    Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT1, 1 );
  1447.    if (n) {
  1448.       n[1].i = i;
  1449.    }
  1450.    if (ctx->ExecuteFlag) {
  1451.       (*ctx->Exec.EvalPoint1)( ctx, i );
  1452.    }
  1453. }
  1454.  
  1455.  
  1456. void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j )
  1457. {
  1458.    Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT2, 2 );
  1459.    if (n) {
  1460.       n[1].i = i;
  1461.       n[2].i = j;
  1462.    }
  1463.    if (ctx->ExecuteFlag) {
  1464.       (*ctx->Exec.EvalPoint2)( ctx, i, j );
  1465.    }
  1466. }
  1467.  
  1468.  
  1469. void gl_save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
  1470. {
  1471.    Node *n = alloc_instruction( ctx, OPCODE_FOG, 5 );
  1472.    if (n) {
  1473.       n[1].e = pname;
  1474.       n[2].f = params[0];
  1475.       n[3].f = params[1];
  1476.       n[4].f = params[2];
  1477.       n[5].f = params[3];
  1478.    }
  1479.    if (ctx->ExecuteFlag) {
  1480.       (*ctx->Exec.Fogfv)( ctx, pname, params );
  1481.    }
  1482. }
  1483.  
  1484.  
  1485. void gl_save_FrontFace( GLcontext *ctx, GLenum mode )
  1486. {
  1487.    Node *n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
  1488.    if (n) {
  1489.       n[1].e = mode;
  1490.    }
  1491.    if (ctx->ExecuteFlag) {
  1492.       (*ctx->Exec.FrontFace)( ctx, mode );
  1493.    }
  1494. }
  1495.  
  1496.  
  1497. void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
  1498.                       GLdouble bottom, GLdouble top,
  1499.                       GLdouble nearval, GLdouble farval )
  1500. {
  1501.    Node *n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
  1502.    if (n) {
  1503.       n[1].f = left;
  1504.       n[2].f = right;
  1505.       n[3].f = bottom;
  1506.       n[4].f = top;
  1507.       n[5].f = nearval;
  1508.       n[6].f = farval;
  1509.    }
  1510.    if (ctx->ExecuteFlag) {
  1511.       (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval );
  1512.    }
  1513. }
  1514.  
  1515.  
  1516. void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
  1517. {
  1518.    Node *n = alloc_instruction( ctx, OPCODE_HINT, 2 );
  1519.    if (n) {
  1520.       n[1].e = target;
  1521.       n[2].e = mode;
  1522.    }
  1523.    if (ctx->ExecuteFlag) {
  1524.       (*ctx->Exec.Hint)( ctx, target, mode );
  1525.    }
  1526. }
  1527.  
  1528.  
  1529. void gl_save_Indexi( GLcontext *ctx, GLint index )
  1530. {
  1531.    Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
  1532.    if (n) {
  1533.       n[1].i = index;
  1534.    }
  1535.    if (ctx->ExecuteFlag) {
  1536.       (*ctx->Exec.Indexi)( ctx, index );
  1537.    }
  1538. }
  1539.  
  1540.  
  1541. void gl_save_Indexf( GLcontext *ctx, GLfloat index )
  1542. {
  1543.    Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
  1544.    if (n) {
  1545.       n[1].i = (GLint) index;
  1546.    }
  1547.    if (ctx->ExecuteFlag) {
  1548.       (*ctx->Exec.Indexf)( ctx,index );
  1549.    }
  1550. }
  1551.  
  1552.  
  1553. void gl_save_IndexMask( GLcontext *ctx, GLuint mask )
  1554. {
  1555.    Node *n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
  1556.    if (n) {
  1557.       n[1].ui = mask;
  1558.    }
  1559.    if (ctx->ExecuteFlag) {
  1560.       (*ctx->Exec.IndexMask)( ctx, mask );
  1561.    }
  1562. }
  1563.  
  1564.  
  1565. void gl_save_InitNames( GLcontext *ctx )
  1566. {
  1567.    (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
  1568.    if (ctx->ExecuteFlag) {
  1569.       (*ctx->Exec.InitNames)( ctx );
  1570.    }
  1571. }
  1572.  
  1573.  
  1574. void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
  1575.                       const GLfloat *params, GLint numparams )
  1576. {
  1577.    Node *n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
  1578.    if (OPCODE_LIGHT) {
  1579.       GLint i;
  1580.       n[1].e = light;
  1581.       n[2].e = pname;
  1582.       for (i=0;i<numparams;i++) {
  1583.          n[3+i].f = params[i];
  1584.       }
  1585.    }
  1586.    if (ctx->ExecuteFlag) {
  1587.       (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams );
  1588.    }
  1589. }
  1590.  
  1591.  
  1592. void gl_save_LightModelfv( GLcontext *ctx,
  1593.                            GLenum pname, const GLfloat *params )
  1594. {
  1595.    Node *n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
  1596.    if (n) {
  1597.       n[1].e = pname;
  1598.       n[2].f = params[0];
  1599.       n[3].f = params[1];
  1600.       n[4].f = params[2];
  1601.       n[5].f = params[3];
  1602.    }
  1603.    if (ctx->ExecuteFlag) {
  1604.       (*ctx->Exec.LightModelfv)( ctx, pname, params );
  1605.    }
  1606. }
  1607.  
  1608.  
  1609. void gl_save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
  1610. {
  1611.    Node *n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
  1612.    if (n) {
  1613.       n[1].i = factor;
  1614.       n[2].us = pattern;
  1615.    }
  1616.    if (ctx->ExecuteFlag) {
  1617.       (*ctx->Exec.LineStipple)( ctx, factor, pattern );
  1618.    }
  1619. }
  1620.  
  1621.  
  1622. void gl_save_LineWidth( GLcontext *ctx, GLfloat width )
  1623. {
  1624.    Node *n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
  1625.    if (n) {
  1626.       n[1].f = width;
  1627.    }
  1628.    if (ctx->ExecuteFlag) {
  1629.       (*ctx->Exec.LineWidth)( ctx, width );
  1630.    }
  1631. }
  1632.  
  1633.  
  1634. void gl_save_ListBase( GLcontext *ctx, GLuint base )
  1635. {
  1636.    Node *n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
  1637.    if (n) {
  1638.       n[1].ui = base;
  1639.    }
  1640.    if (ctx->ExecuteFlag) {
  1641.       (*ctx->Exec.ListBase)( ctx, base );
  1642.    }
  1643. }
  1644.  
  1645.  
  1646. void gl_save_LoadIdentity( GLcontext *ctx )
  1647. {
  1648.    (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
  1649.    if (ctx->ExecuteFlag) {
  1650.       (*ctx->Exec.LoadIdentity)( ctx );
  1651.    }
  1652. }
  1653.  
  1654.  
  1655. void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
  1656. {
  1657.    Node *n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
  1658.    if (n) {
  1659.       GLuint i;
  1660.       for (i=0;i<16;i++) {
  1661.          n[1+i].f = m[i];
  1662.       }
  1663.    }
  1664.    if (ctx->ExecuteFlag) {
  1665.       (*ctx->Exec.LoadMatrixf)( ctx, m );
  1666.    }
  1667. }
  1668.  
  1669.  
  1670. void gl_save_LoadName( GLcontext *ctx, GLuint name )
  1671. {
  1672.    Node *n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
  1673.    if (n) {
  1674.       n[1].ui = name;
  1675.    }
  1676.    if (ctx->ExecuteFlag) {
  1677.       (*ctx->Exec.LoadName)( ctx, name );
  1678.    }
  1679. }
  1680.  
  1681.  
  1682. void gl_save_LogicOp( GLcontext *ctx, GLenum opcode )
  1683. {
  1684.    Node *n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
  1685.    if (n) {
  1686.       n[1].e = opcode;
  1687.    }
  1688.    if (ctx->ExecuteFlag) {
  1689.       (*ctx->Exec.LogicOp)( ctx, opcode );
  1690.    }
  1691. }
  1692.  
  1693.  
  1694. void gl_save_Map1f( GLcontext *ctx,
  1695.                    GLenum target, GLfloat u1, GLfloat u2, GLint stride,
  1696.                    GLint order, const GLfloat *points, GLboolean retain )
  1697. {
  1698.    Node *n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
  1699.    if (n) {
  1700.       n[1].e = target;
  1701.       n[2].f = u1;
  1702.       n[3].f = u2;
  1703.       n[4].i = stride;
  1704.       n[5].i = order;
  1705.       n[6].data = (void *) points;
  1706.    }
  1707.    if (ctx->ExecuteFlag) {
  1708.       (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE );
  1709.    }
  1710. }
  1711.  
  1712.  
  1713. void gl_save_Map2f( GLcontext *ctx, GLenum target,
  1714.                     GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
  1715.                     GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
  1716.                     const GLfloat *points, GLboolean retain )
  1717. {
  1718.    Node *n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
  1719.    if (n) {
  1720.       n[1].e = target;
  1721.       n[2].f = u1;
  1722.       n[3].f = u2;
  1723.       n[4].f = v1;
  1724.       n[5].f = v2;
  1725.       n[6].i = ustride;
  1726.       n[7].i = vstride;
  1727.       n[8].i = uorder;
  1728.       n[9].i = vorder;
  1729.       n[10].data = (void *) points;
  1730.    }
  1731.    if (ctx->ExecuteFlag) {
  1732.       (*ctx->Exec.Map2f)( ctx, target,
  1733.                         u1, u2, ustride, uorder,
  1734.                         v1, v2, vstride, vorder, points, GL_TRUE );
  1735.    }
  1736. }
  1737.  
  1738.  
  1739. void gl_save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
  1740. {
  1741.    Node *n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
  1742.    if (n) {
  1743.       n[1].i = un;
  1744.       n[2].f = u1;
  1745.       n[3].f = u2;
  1746.    }
  1747.    if (ctx->ExecuteFlag) {
  1748.       (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 );
  1749.    }
  1750. }
  1751.  
  1752.  
  1753. void gl_save_MapGrid2f( GLcontext *ctx, 
  1754.                         GLint un, GLfloat u1, GLfloat u2,
  1755.                         GLint vn, GLfloat v1, GLfloat v2 )
  1756. {
  1757.    Node *n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
  1758.    if (n) {
  1759.       n[1].i = un;
  1760.       n[2].f = u1;
  1761.       n[3].f = u2;
  1762.       n[4].i = vn;
  1763.       n[5].f = v1;
  1764.       n[6].f = v2;
  1765.    }
  1766.    if (ctx->ExecuteFlag) {
  1767.       (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 );
  1768.    }
  1769. }
  1770.  
  1771.  
  1772. void gl_save_Materialfv( GLcontext *ctx,
  1773.                          GLenum face, GLenum pname, const GLfloat *params )
  1774. {
  1775.    Node *n = alloc_instruction( ctx, OPCODE_MATERIAL, 6 );
  1776.    if (n) {
  1777.       n[1].e = face;
  1778.       n[2].e = pname;
  1779.       n[3].f = params[0];
  1780.       n[4].f = params[1];
  1781.       n[5].f = params[2];
  1782.       n[6].f = params[3];
  1783.    }
  1784.    if (ctx->ExecuteFlag) {
  1785.       (*ctx->Exec.Materialfv)( ctx, face, pname, params );
  1786.    }
  1787. }
  1788.  
  1789.  
  1790. void gl_save_MatrixMode( GLcontext *ctx, GLenum mode )
  1791. {
  1792.    Node *n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
  1793.    if (n) {
  1794.       n[1].e = mode;
  1795.    }
  1796.    if (ctx->ExecuteFlag) {
  1797.       (*ctx->Exec.MatrixMode)( ctx, mode );
  1798.    }
  1799. }
  1800.  
  1801.  
  1802. void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
  1803. {
  1804.    Node *n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
  1805.    if (n) {
  1806.       GLuint i;
  1807.       for (i=0;i<16;i++) {
  1808.          n[1+i].f = m[i];
  1809.       }
  1810.    }
  1811.    if (ctx->ExecuteFlag) {
  1812.       (*ctx->Exec.MultMatrixf)( ctx, m );
  1813.    }
  1814. }
  1815.  
  1816.  
  1817. void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
  1818. {
  1819.    /* It's an error to call this function while building a display list */
  1820.    gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  1821. }
  1822.  
  1823.  
  1824. void gl_save_Normal3fv( GLcontext *ctx, const GLfloat norm[3] )
  1825. {
  1826.    Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
  1827.    if (n) {
  1828.       n[1].f = norm[0];
  1829.       n[2].f = norm[1];
  1830.       n[3].f = norm[2];
  1831.    }
  1832.    if (ctx->ExecuteFlag) {
  1833.       (*ctx->Exec.Normal3fv)( ctx, norm );
  1834.    }
  1835. }
  1836.  
  1837.  
  1838. void gl_save_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz )
  1839. {
  1840.    Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
  1841.    if (n) {
  1842.       n[1].f = nx;
  1843.       n[2].f = ny;
  1844.       n[3].f = nz;
  1845.    }
  1846.    if (ctx->ExecuteFlag) {
  1847.       (*ctx->Exec.Normal3f)( ctx, nx, ny, nz );
  1848.    }
  1849. }
  1850.  
  1851.  
  1852. void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
  1853.                     GLdouble bottom, GLdouble top,
  1854.                     GLdouble nearval, GLdouble farval )
  1855. {
  1856.    Node *n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
  1857.    if (n) {
  1858.       n[1].f = left;
  1859.       n[2].f = right;
  1860.       n[3].f = bottom;
  1861.       n[4].f = top;
  1862.       n[5].f = nearval;
  1863.       n[6].f = farval;
  1864.    }
  1865.    if (ctx->ExecuteFlag) {
  1866.       (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval );
  1867.    }
  1868. }
  1869.  
  1870.  
  1871. void gl_save_PixelMapfv( GLcontext *ctx,
  1872.                          GLenum map, GLint mapsize, const GLfloat *values )
  1873. {
  1874.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
  1875.    if (n) {
  1876.       n[1].e = map;
  1877.       n[2].i = mapsize;
  1878.       n[3].data  = (void *) malloc( mapsize * sizeof(GLfloat) );
  1879.       MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
  1880.    }
  1881.    if (ctx->ExecuteFlag) {
  1882.       (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values );
  1883.    }
  1884. }
  1885.  
  1886.  
  1887. void gl_save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
  1888. {
  1889.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
  1890.    if (n) {
  1891.       n[1].e = pname;
  1892.       n[2].f = param;
  1893.    }
  1894.    if (ctx->ExecuteFlag) {
  1895.       (*ctx->Exec.PixelTransferf)( ctx, pname, param );
  1896.    }
  1897. }
  1898.  
  1899.  
  1900. void gl_save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
  1901. {
  1902.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
  1903.    if (n) {
  1904.       n[1].f = xfactor;
  1905.       n[2].f = yfactor;
  1906.    }
  1907.    if (ctx->ExecuteFlag) {
  1908.       (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor );
  1909.    }
  1910. }
  1911.  
  1912.  
  1913. void gl_save_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
  1914.                                   const GLfloat *params)
  1915. {
  1916.    Node *n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
  1917.    if (n) {
  1918.       n[1].e = pname;
  1919.       n[2].f = params[0];
  1920.       n[3].f = params[1];
  1921.       n[4].f = params[2];
  1922.    }
  1923.    if (ctx->ExecuteFlag) {
  1924.       (*ctx->Exec.PointParameterfvEXT)( ctx, pname, params );
  1925.    }
  1926. }
  1927.  
  1928.  
  1929. void gl_save_PointSize( GLcontext *ctx, GLfloat size )
  1930. {
  1931.    Node *n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
  1932.    if (n) {
  1933.       n[1].f = size;
  1934.    }
  1935.    if (ctx->ExecuteFlag) {
  1936.       (*ctx->Exec.PointSize)( ctx, size );
  1937.    }
  1938. }
  1939.  
  1940.  
  1941. void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
  1942. {
  1943.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
  1944.    if (n) {
  1945.       n[1].e = face;
  1946.       n[2].e = mode;
  1947.    }
  1948.    if (ctx->ExecuteFlag) {
  1949.       (*ctx->Exec.PolygonMode)( ctx, face, mode );
  1950.    }
  1951. }
  1952.  
  1953.  
  1954. void gl_save_PolygonStipple( GLcontext *ctx, const GLubyte *mask )
  1955. {
  1956.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
  1957.    if (n) {
  1958.       void *data;
  1959.       n[1].data = malloc( 32 * 4 );
  1960.       data = n[1].data;   /* This needed for Acorn compiler */
  1961.       MEMCPY( data, mask, 32 * 4 );
  1962.    }
  1963.    if (ctx->ExecuteFlag) {
  1964.       (*ctx->Exec.PolygonStipple)( ctx, mask );
  1965.    }
  1966. }
  1967.  
  1968.  
  1969. void gl_save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
  1970. {
  1971.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
  1972.    if (n) {
  1973.       n[1].f = factor;
  1974.       n[2].f = units;
  1975.    }
  1976.    if (ctx->ExecuteFlag) {
  1977.       (*ctx->Exec.PolygonOffset)( ctx, factor, units );
  1978.    }
  1979. }
  1980.  
  1981.  
  1982. void gl_save_PopAttrib( GLcontext *ctx )
  1983. {
  1984.    (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
  1985.    if (ctx->ExecuteFlag) {
  1986.       (*ctx->Exec.PopAttrib)( ctx );
  1987.    }
  1988. }
  1989.  
  1990.  
  1991. void gl_save_PopMatrix( GLcontext *ctx )
  1992. {
  1993.    (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
  1994.    if (ctx->ExecuteFlag) {
  1995.       (*ctx->Exec.PopMatrix)( ctx );
  1996.    }
  1997. }
  1998.  
  1999.  
  2000. void gl_save_PopName( GLcontext *ctx )
  2001. {
  2002.    (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
  2003.    if (ctx->ExecuteFlag) {
  2004.       (*ctx->Exec.PopName)( ctx );
  2005.    }
  2006. }
  2007.  
  2008.  
  2009. void gl_save_PrioritizeTextures( GLcontext *ctx,
  2010.                                  GLsizei num, const GLuint *textures,
  2011.                                  const GLclampf *priorities )
  2012. {
  2013.    GLint i;
  2014.  
  2015.    for (i=0;i<num;i++) {
  2016.       Node *n = alloc_instruction( ctx,  OPCODE_PRIORITIZE_TEXTURE, 2 );
  2017.       if (n) {
  2018.          n[1].ui = textures[i];
  2019.          n[2].f = priorities[i];
  2020.       }
  2021.    }
  2022.    if (ctx->ExecuteFlag) {
  2023.       (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities );
  2024.    }
  2025. }
  2026.  
  2027.  
  2028. void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask )
  2029. {
  2030.    Node *n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
  2031.    if (n) {
  2032.       n[1].bf = mask;
  2033.    }
  2034.    if (ctx->ExecuteFlag) {
  2035.       (*ctx->Exec.PushAttrib)( ctx, mask );
  2036.    }
  2037. }
  2038.  
  2039.  
  2040. void gl_save_PushMatrix( GLcontext *ctx )
  2041. {
  2042.    (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
  2043.    if (ctx->ExecuteFlag) {
  2044.       (*ctx->Exec.PushMatrix)( ctx );
  2045.    }
  2046. }
  2047.  
  2048.  
  2049. void gl_save_PushName( GLcontext *ctx, GLuint name )
  2050. {
  2051.    Node *n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
  2052.    if (n) {
  2053.       n[1].ui = name;
  2054.    }
  2055.    if (ctx->ExecuteFlag) {
  2056.       (*ctx->Exec.PushName)( ctx, name );
  2057.    }
  2058. }
  2059.  
  2060.  
  2061. void gl_save_RasterPos4f( GLcontext *ctx,
  2062.                           GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2063. {
  2064.    Node *n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
  2065.    if (n) {
  2066.       n[1].f = x;
  2067.       n[2].f = y;
  2068.       n[3].f = z;
  2069.       n[4].f = w;
  2070.    }
  2071.    if (ctx->ExecuteFlag) {
  2072.       (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w );
  2073.    }
  2074. }
  2075.  
  2076.  
  2077. void gl_save_PassThrough( GLcontext *ctx, GLfloat token )
  2078. {
  2079.    Node *n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
  2080.    if (n) {
  2081.       n[1].f = token;
  2082.    }
  2083.    if (ctx->ExecuteFlag) {
  2084.       (*ctx->Exec.PassThrough)( ctx, token );
  2085.    }
  2086. }
  2087.  
  2088.  
  2089. void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode )
  2090. {
  2091.    Node *n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
  2092.    if (n) {
  2093.       n[1].e = mode;
  2094.    }
  2095.    if (ctx->ExecuteFlag) {
  2096.       (*ctx->Exec.ReadBuffer)( ctx, mode );
  2097.    }
  2098. }
  2099.  
  2100.  
  2101. void gl_save_Rectf( GLcontext *ctx,
  2102.                     GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
  2103. {
  2104.    Node *n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
  2105.    if (n) {
  2106.       n[1].f = x1;
  2107.       n[2].f = y1;
  2108.       n[3].f = x2;
  2109.       n[4].f = y2;
  2110.    }
  2111.    if (ctx->ExecuteFlag) {
  2112.       (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 );
  2113.    }
  2114. }
  2115.  
  2116.  
  2117. void gl_save_Rotatef( GLcontext *ctx, GLfloat angle,
  2118.                       GLfloat x, GLfloat y, GLfloat z )
  2119. {
  2120.    GLfloat m[16];
  2121.    gl_rotation_matrix( angle, x, y, z, m );
  2122.    gl_save_MultMatrixf( ctx, m );  /* save and maybe execute */
  2123. }
  2124.  
  2125.  
  2126. void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2127. {
  2128.    Node *n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
  2129.    if (n) {
  2130.       n[1].f = x;
  2131.       n[2].f = y;
  2132.       n[3].f = z;
  2133.    }
  2134.    if (ctx->ExecuteFlag) {
  2135.       (*ctx->Exec.Scalef)( ctx, x, y, z );
  2136.    }
  2137. }
  2138.  
  2139.  
  2140. void gl_save_Scissor( GLcontext *ctx,
  2141.                       GLint x, GLint y, GLsizei width, GLsizei height )
  2142. {
  2143.    Node *n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
  2144.    if (n) {
  2145.       n[1].i = x;
  2146.       n[2].i = y;
  2147.       n[3].i = width;
  2148.       n[4].i = height;
  2149.    }
  2150.    if (ctx->ExecuteFlag) {
  2151.       (*ctx->Exec.Scissor)( ctx, x, y, width, height );
  2152.    }
  2153. }
  2154.  
  2155.  
  2156. void gl_save_ShadeModel( GLcontext *ctx, GLenum mode )
  2157. {
  2158.    Node *n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
  2159.    if (n) {
  2160.       n[1].e = mode;
  2161.    }
  2162.    if (ctx->ExecuteFlag) {
  2163.       (*ctx->Exec.ShadeModel)( ctx, mode );
  2164.    }
  2165. }
  2166.  
  2167.  
  2168. void gl_save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
  2169. {
  2170.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
  2171.    if (n) {
  2172.       n[1].e = func;
  2173.       n[2].i = ref;
  2174.       n[3].ui = mask;
  2175.    }
  2176.    if (ctx->ExecuteFlag) {
  2177.       (*ctx->Exec.StencilFunc)( ctx, func, ref, mask );
  2178.    }
  2179. }
  2180.  
  2181.  
  2182. void gl_save_StencilMask( GLcontext *ctx, GLuint mask )
  2183. {
  2184.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
  2185.    if (n) {
  2186.       n[1].ui = mask;
  2187.    }
  2188.    if (ctx->ExecuteFlag) {
  2189.       (*ctx->Exec.StencilMask)( ctx, mask );
  2190.    }
  2191. }
  2192.  
  2193.  
  2194. void gl_save_StencilOp( GLcontext *ctx,
  2195.                         GLenum fail, GLenum zfail, GLenum zpass )
  2196. {
  2197.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
  2198.    if (n) {
  2199.       n[1].e = fail;
  2200.       n[2].e = zfail;
  2201.       n[3].e = zpass;
  2202.    }
  2203.    if (ctx->ExecuteFlag) {
  2204.       (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass );
  2205.    }
  2206. }
  2207.  
  2208.  
  2209. void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t )
  2210. {
  2211.    Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD2, 2 );
  2212.    if (n) {
  2213.       n[1].f = s;
  2214.       n[2].f = t;
  2215.    }
  2216.    if (ctx->ExecuteFlag) {
  2217.       (*ctx->Exec.TexCoord2f)( ctx, s, t );
  2218.    }
  2219. }
  2220.  
  2221.  
  2222. void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t,
  2223.                                          GLfloat r, GLfloat q )
  2224. {
  2225.    Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD4, 4 );
  2226.    if (n) {
  2227.       n[1].f = s;
  2228.       n[2].f = t;
  2229.       n[3].f = r;
  2230.       n[4].f = q;
  2231.    }
  2232.    if (ctx->ExecuteFlag) {
  2233.       (*ctx->Exec.TexCoord4f)( ctx, s, t, r, q );
  2234.    }
  2235. }
  2236.  
  2237.  
  2238. void gl_save_TexEnvfv( GLcontext *ctx,
  2239.                        GLenum target, GLenum pname, const GLfloat *params )
  2240. {
  2241.    Node *n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
  2242.    if (n) {
  2243.       n[1].e = target;
  2244.       n[2].e = pname;
  2245.       n[3].f = params[0];
  2246.       n[4].f = params[1];
  2247.       n[5].f = params[2];
  2248.       n[6].f = params[3];
  2249.    }
  2250.    if (ctx->ExecuteFlag) {
  2251.       (*ctx->Exec.TexEnvfv)( ctx, target, pname, params );
  2252.    }
  2253. }
  2254.  
  2255.  
  2256. void gl_save_TexGenfv( GLcontext *ctx,
  2257.                        GLenum coord, GLenum pname, const GLfloat *params )
  2258. {
  2259.    Node *n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
  2260.    if (n) {
  2261.       n[1].e = coord;
  2262.       n[2].e = pname;
  2263.       n[3].f = params[0];
  2264.       n[4].f = params[1];
  2265.       n[5].f = params[2];
  2266.       n[6].f = params[3];
  2267.    }
  2268.    if (ctx->ExecuteFlag) {
  2269.       (*ctx->Exec.TexGenfv)( ctx, coord, pname, params );
  2270.    }
  2271. }
  2272.  
  2273.  
  2274. void gl_save_TexParameterfv( GLcontext *ctx, GLenum target,
  2275.                              GLenum pname, const GLfloat *params )
  2276. {
  2277.    Node *n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
  2278.    if (n) {
  2279.       n[1].e = target;
  2280.       n[2].e = pname;
  2281.       n[3].f = params[0];
  2282.       n[4].f = params[1];
  2283.       n[5].f = params[2];
  2284.       n[6].f = params[3];
  2285.    }
  2286.    if (ctx->ExecuteFlag) {
  2287.       (*ctx->Exec.TexParameterfv)( ctx, target, pname, params );
  2288.    }
  2289. }
  2290.  
  2291.  
  2292. void gl_save_TexImage1D( GLcontext *ctx, GLenum target,
  2293.                          GLint level, GLint components,
  2294.                          GLsizei width, GLint border,
  2295.                          GLenum format, GLenum type,
  2296.                          struct gl_image *teximage )
  2297. {
  2298.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
  2299.    if (n) {
  2300.       n[1].e = target;
  2301.       n[2].i = level;
  2302.       n[3].i = components;
  2303.       n[4].i = (GLint) width;
  2304.       n[5].i = border;
  2305.       n[6].e = format;
  2306.       n[7].e = type;
  2307.       n[8].data = teximage;
  2308.       if (teximage) {
  2309.          /* this prevents gl_TexImage2D() from freeing the image */
  2310.          teximage->RefCount = 1;
  2311.       }
  2312.    }
  2313.    if (ctx->ExecuteFlag) {
  2314.       (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
  2315.                         border, format, type, teximage );
  2316.    }
  2317. }
  2318.  
  2319.  
  2320. void gl_save_TexImage2D( GLcontext *ctx, GLenum target,
  2321.                          GLint level, GLint components,
  2322.                          GLsizei width, GLsizei height, GLint border,
  2323.                          GLenum format, GLenum type,
  2324.                          struct gl_image *teximage )
  2325. {
  2326.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
  2327.    if (n) {
  2328.       n[1].e = target;
  2329.       n[2].i = level;
  2330.       n[3].i = components;
  2331.       n[4].i = (GLint) width;
  2332.       n[5].i = (GLint) height;
  2333.       n[6].i = border;
  2334.       n[7].e = format;
  2335.       n[8].e = type;
  2336.       n[9].data = teximage;
  2337.       if (teximage) {
  2338.          /* this prevents gl_TexImage2D() from freeing the image */
  2339.          teximage->RefCount = 1;
  2340.       }
  2341.    }
  2342.    if (ctx->ExecuteFlag) {
  2343.       (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
  2344.                         height, border, format, type, teximage );
  2345.    }
  2346. }
  2347.  
  2348.  
  2349. void gl_save_TexImage3DEXT( GLcontext *ctx, GLenum target,
  2350.                             GLint level, GLint components,
  2351.                             GLsizei width, GLsizei height, GLsizei depth,
  2352.                             GLint border,
  2353.                             GLenum format, GLenum type,
  2354.                             struct gl_image *teximage )
  2355. {
  2356.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
  2357.    if (n) {
  2358.       n[1].e = target;
  2359.       n[2].i = level;
  2360.       n[3].i = components;
  2361.       n[4].i = (GLint) width;
  2362.       n[5].i = (GLint) height;
  2363.       n[6].i = (GLint) depth; 
  2364.       n[7].i = border;
  2365.       n[8].e = format;
  2366.       n[9].e = type;
  2367.       n[10].data = teximage;
  2368.    }
  2369.    if (ctx->ExecuteFlag) {
  2370.       (*ctx->Exec.TexImage3DEXT)( ctx, target, level, components, width,
  2371.                            height, depth, border, format, type, teximage );
  2372.    }
  2373. }
  2374.  
  2375.  
  2376. void gl_save_TexSubImage1D( GLcontext *ctx,
  2377.                             GLenum target, GLint level, GLint xoffset,
  2378.                             GLsizei width, GLenum format, GLenum type,
  2379.                             struct gl_image *image )
  2380. {
  2381.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
  2382.    if (n) {
  2383.       n[1].e = target;
  2384.       n[2].i = level;
  2385.       n[3].i = xoffset;
  2386.       n[4].i = (GLint) width;
  2387.       n[5].e = format;
  2388.       n[6].e = type;
  2389.       n[7].data = image;
  2390.       if (image)
  2391.          image->RefCount = 1;
  2392.    }
  2393.    if (ctx->ExecuteFlag) {
  2394.       (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width,
  2395.                            format, type, image );
  2396.    }
  2397. }
  2398.  
  2399.  
  2400. void gl_save_TexSubImage2D( GLcontext *ctx,
  2401.                             GLenum target, GLint level,
  2402.                             GLint xoffset, GLint yoffset,
  2403.                             GLsizei width, GLsizei height,
  2404.                             GLenum format, GLenum type,
  2405.                             struct gl_image *image )
  2406. {
  2407.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
  2408.    if (n) {
  2409.       n[1].e = target;
  2410.       n[2].i = level;
  2411.       n[3].i = xoffset;
  2412.       n[4].i = yoffset;
  2413.       n[5].i = (GLint) width;
  2414.       n[6].i = (GLint) height;
  2415.       n[7].e = format;
  2416.       n[8].e = type;
  2417.       n[9].data = image;
  2418.       if (image)
  2419.          image->RefCount = 1;
  2420.    }
  2421.    if (ctx->ExecuteFlag) {
  2422.       (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset,
  2423.                            width, height, format, type, image );
  2424.    }
  2425. }
  2426.  
  2427.  
  2428. void gl_save_TexSubImage3DEXT( GLcontext *ctx,
  2429.                                GLenum target, GLint level,
  2430.                                GLint xoffset, GLint yoffset,GLint zoffset,
  2431.                                GLsizei width, GLsizei height, GLsizei depth,
  2432.                                GLenum format, GLenum type,
  2433.                                struct gl_image *image )
  2434. {
  2435.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
  2436.    if (n) {
  2437.       n[1].e = target;
  2438.       n[2].i = level;
  2439.       n[3].i = xoffset;
  2440.       n[4].i = yoffset;
  2441.       n[5].i = zoffset;
  2442.       n[6].i = (GLint) width;
  2443.       n[7].i = (GLint) height;
  2444.       n[8].i = (GLint) depth;
  2445.       n[9].e = format;
  2446.       n[10].e = type;
  2447.       n[11].data = image;
  2448.       if (image)
  2449.          image->RefCount = 1;
  2450.    }
  2451.    if (ctx->ExecuteFlag) {
  2452.       (*ctx->Exec.TexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
  2453.                               width, height, depth, format, type, image );
  2454.    }
  2455. }
  2456.  
  2457.  
  2458. void gl_save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2459. {
  2460.    Node *n = alloc_instruction( ctx,  OPCODE_TRANSLATE, 3 );
  2461.    if (n) {
  2462.       n[1].f = x;
  2463.       n[2].f = y;
  2464.       n[3].f = z;
  2465.    }
  2466.    if (ctx->ExecuteFlag) {
  2467.       (*ctx->Exec.Translatef)( ctx, x, y, z );
  2468.    }
  2469. }
  2470.  
  2471.  
  2472. void gl_save_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y )
  2473. {
  2474.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX2, 2 );
  2475.    if (n) {
  2476.       n[1].f = x;
  2477.       n[2].f = y;
  2478.    }
  2479.    if (ctx->ExecuteFlag) {
  2480.       (*ctx->Exec.Vertex2f)( ctx, x, y );
  2481.    }
  2482. }
  2483.  
  2484.  
  2485. void gl_save_Vertex3f( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2486. {
  2487.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
  2488.    if (n) {
  2489.       n[1].f = x;
  2490.       n[2].f = y;
  2491.       n[3].f = z;
  2492.    }
  2493.    if (ctx->ExecuteFlag) {
  2494.       (*ctx->Exec.Vertex3f)( ctx, x, y, z );
  2495.    }
  2496. }
  2497.  
  2498.  
  2499. void gl_save_Vertex4f( GLcontext *ctx,
  2500.                        GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2501. {
  2502.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX4, 4 );
  2503.    if (n) {
  2504.       n[1].f = x;
  2505.       n[2].f = y;
  2506.       n[3].f = z;
  2507.       n[4].f = w;
  2508.    }
  2509.    if (ctx->ExecuteFlag) {
  2510.       (*ctx->Exec.Vertex4f)( ctx, x, y, z, w );
  2511.    }
  2512. }
  2513.  
  2514.  
  2515. void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat v[3] )
  2516. {
  2517.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
  2518.    if (n) {
  2519.       n[1].f = v[0];
  2520.       n[2].f = v[1];
  2521.       n[3].f = v[2];
  2522.    }
  2523.    if (ctx->ExecuteFlag) {
  2524.       (*ctx->Exec.Vertex3fv)( ctx, v );
  2525.    }
  2526. }
  2527.  
  2528.  
  2529. void gl_save_Viewport( GLcontext *ctx,
  2530.                        GLint x, GLint y, GLsizei width, GLsizei height )
  2531. {
  2532.    Node *n = alloc_instruction( ctx,  OPCODE_VIEWPORT, 4 );
  2533.    if (n) {
  2534.       n[1].i = x;
  2535.       n[2].i = y;
  2536.       n[3].i = (GLint) width;
  2537.       n[4].i = (GLint) height;
  2538.    }
  2539.    if (ctx->ExecuteFlag) {
  2540.       (*ctx->Exec.Viewport)( ctx, x, y, width, height );
  2541.    }
  2542. }
  2543.  
  2544.  
  2545. void gl_save_WindowPos4fMESA( GLcontext *ctx,
  2546.                               GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2547. {
  2548.    Node *n = alloc_instruction( ctx,  OPCODE_WINDOW_POS, 4 );
  2549.    if (n) {
  2550.       n[1].f = x;
  2551.       n[2].f = y;
  2552.       n[3].f = z;
  2553.       n[4].f = w;
  2554.    }
  2555.    if (ctx->ExecuteFlag) {
  2556.       (*ctx->Exec.WindowPos4fMESA)( ctx, x, y, z, w );
  2557.    }
  2558. }
  2559.  
  2560.  
  2561.  
  2562. /**********************************************************************/
  2563. /*                     Display list execution                         */
  2564. /**********************************************************************/
  2565.  
  2566. #if (defined(AMIGAWARP) && defined(__PPC__))
  2567. GLfloat g_params[16];
  2568. #endif
  2569.  
  2570. /*
  2571.  * Execute a display list.  Note that the ListBase offset must have already
  2572.  * been added before calling this function.  I.e. the list argument is
  2573.  * the absolute list number, not relative to ListBase.
  2574.  * Input:  list - display list number
  2575.  */
  2576. static void execute_list( GLcontext *ctx, GLuint list )
  2577. {
  2578.    Node *n;
  2579.    GLboolean done;
  2580.    OpCode opcode;
  2581.  
  2582.    if (!gl_IsList(ctx,list))
  2583.       return;
  2584.  
  2585.    ctx->CallDepth++;
  2586.  
  2587.    n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  2588.  
  2589.    done = GL_FALSE;
  2590.    while (!done) {
  2591.       opcode = n[0].opcode;
  2592.  
  2593.       switch (opcode) {
  2594.          /* Frequently called functions: */
  2595.          case OPCODE_VERTEX2:
  2596.             (*ctx->Exec.Vertex2f)( ctx, n[1].f, n[2].f );
  2597.             break;
  2598.          case OPCODE_VERTEX3:
  2599.             (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f );
  2600.             break;
  2601.          case OPCODE_VERTEX4:
  2602.             (*ctx->Exec.Vertex4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2603.             break;
  2604.          case OPCODE_NORMAL:
  2605.             ctx->Current.Normal[0] = n[1].f;
  2606.             ctx->Current.Normal[1] = n[2].f;
  2607.             ctx->Current.Normal[2] = n[3].f;
  2608.             ctx->VB->MonoNormal = GL_FALSE;
  2609.             break;
  2610.          case OPCODE_COLOR_4UB:
  2611.             (*ctx->Exec.Color4ub)( ctx, n[1].ub, n[2].ub, n[3].ub, n[4].ub );
  2612.             break;
  2613.          case OPCODE_COLOR_3F:
  2614.             (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f );
  2615.             break;
  2616.          case OPCODE_COLOR_4F:
  2617.             (*ctx->Exec.Color4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2618.             break;
  2619.          case OPCODE_INDEX:
  2620.             ctx->Current.Index = n[1].ui;
  2621.             ctx->VB->MonoColor = GL_FALSE;
  2622.             break;
  2623.          case OPCODE_BEGIN:
  2624.             gl_Begin( ctx, n[1].e );
  2625.             break;
  2626.          case OPCODE_END:
  2627.             gl_End( ctx );
  2628.             break;
  2629.          case OPCODE_TEXCOORD2:
  2630.             ctx->Current.TexCoord[0] = n[1].f;
  2631.             ctx->Current.TexCoord[1] = n[2].f;
  2632.             if (ctx->VB->TexCoordSize==4) {
  2633.                ctx->Current.TexCoord[2] = 0.0F;
  2634.                ctx->Current.TexCoord[3] = 1.0F;
  2635.             }
  2636.             break;
  2637.          case OPCODE_TEXCOORD4:
  2638.             ctx->Current.TexCoord[0] = n[1].f;
  2639.             ctx->Current.TexCoord[1] = n[2].f;
  2640.             ctx->Current.TexCoord[2] = n[3].f;
  2641.             ctx->Current.TexCoord[3] = n[4].f;
  2642.             if (ctx->VB->TexCoordSize==2) {
  2643.                /* Switch to 4-component texcoords */
  2644.                ctx->VB->TexCoordSize = 4;
  2645.                gl_set_vertex_function(ctx);
  2646.             }
  2647.             break;
  2648.  
  2649.          /* Everything Else: */
  2650.          case OPCODE_ACCUM:
  2651.             gl_Accum( ctx, n[1].e, n[2].f );
  2652.             break;
  2653.          case OPCODE_ALPHA_FUNC:
  2654.             gl_AlphaFunc( ctx, n[1].e, n[2].f );
  2655.             break;
  2656.          case OPCODE_BIND_TEXTURE:
  2657.             gl_BindTexture( ctx, n[1].e, n[2].ui );
  2658.             break;
  2659.          case OPCODE_BITMAP:
  2660.             gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
  2661.                        n[3].f, n[4].f,
  2662.                        n[5].f, n[6].f,
  2663.                        (struct gl_image *) n[7].data );
  2664.             break;
  2665.          case OPCODE_BLEND_COLOR:
  2666.             gl_BlendColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2667.             break;
  2668.          case OPCODE_BLEND_EQUATION:
  2669.             gl_BlendEquation( ctx, n[1].e );
  2670.             break;
  2671.          case OPCODE_BLEND_FUNC:
  2672.             gl_BlendFunc( ctx, n[1].e, n[2].e );
  2673.             break;
  2674.          case OPCODE_CALL_LIST:
  2675.             /* Generated by glCallList(), don't add ListBase */
  2676.             if (ctx->CallDepth<MAX_LIST_NESTING) {
  2677.                execute_list( ctx, n[1].ui );
  2678.             }
  2679.             break;
  2680.          case OPCODE_CALL_LIST_OFFSET:
  2681.             /* Generated by glCallLists() so we must add ListBase */
  2682.             if (ctx->CallDepth<MAX_LIST_NESTING) {
  2683.                execute_list( ctx, ctx->List.ListBase + n[1].ui );
  2684.             }
  2685.             break;
  2686.          case OPCODE_CLEAR:
  2687.             gl_Clear( ctx, n[1].bf );
  2688.             break;
  2689.          case OPCODE_CLEAR_COLOR:
  2690.             gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2691.             break;
  2692.          case OPCODE_CLEAR_ACCUM:
  2693.             gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2694.             break;
  2695.          case OPCODE_CLEAR_DEPTH:
  2696.             gl_ClearDepth( ctx, (GLclampd) n[1].f );
  2697.             break;
  2698.          case OPCODE_CLEAR_INDEX:
  2699.             gl_ClearIndex( ctx, n[1].ui );
  2700.             break;
  2701.          case OPCODE_CLEAR_STENCIL:
  2702.             gl_ClearStencil( ctx, n[1].i );
  2703.             break;
  2704.          case OPCODE_CLIP_PLANE:
  2705.             {
  2706. #if (defined(AMIGAWARP) && defined(__PPC__))
  2707.                g_params[0] = n[2].f;
  2708.                g_params[1] = n[3].f;
  2709.                g_params[2] = n[4].f;
  2710.                g_params[3] = n[5].f;
  2711.                gl_ClipPlane( ctx, n[1].e, g_params );
  2712. #else
  2713.                GLfloat equ[4];
  2714.                equ[0] = n[2].f;
  2715.                equ[1] = n[3].f;
  2716.                equ[2] = n[4].f;
  2717.                equ[3] = n[5].f;
  2718.                gl_ClipPlane( ctx, n[1].e, equ );
  2719. #endif
  2720.             }
  2721.             break;
  2722.          case OPCODE_COLOR_MASK:
  2723.             gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b );
  2724.             break;
  2725.          case OPCODE_COLOR_MATERIAL:
  2726.             gl_ColorMaterial( ctx, n[1].e, n[2].e );
  2727.             break;
  2728.          case OPCODE_COLOR_TABLE:
  2729.             gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data);
  2730.             break;
  2731.          case OPCODE_COLOR_SUB_TABLE:
  2732.             gl_ColorSubTable( ctx, n[1].e, n[2].i,
  2733.                               (struct gl_image *) n[3].data);
  2734.             break;
  2735.          case OPCODE_COPY_PIXELS:
  2736.             gl_CopyPixels( ctx, n[1].i, n[2].i,
  2737.                            (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
  2738.             break;
  2739.          case OPCODE_COPY_TEX_IMAGE1D:
  2740.             gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
  2741.                                n[5].i, n[6].i, n[7].i );
  2742.             break;
  2743.          case OPCODE_COPY_TEX_IMAGE2D:
  2744.             gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
  2745.                                n[5].i, n[6].i, n[7].i, n[8].i );
  2746.             break;
  2747.          case OPCODE_COPY_TEX_SUB_IMAGE1D:
  2748.             gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2749.                                   n[5].i, n[6].i );
  2750.             break;
  2751.          case OPCODE_COPY_TEX_SUB_IMAGE2D:
  2752.             gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2753.                                   n[5].i, n[6].i, n[7].i, n[8].i );
  2754.             break;
  2755.          case OPCODE_COPY_TEX_SUB_IMAGE3D:
  2756.             gl_CopyTexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2757.                                      n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
  2758.             break;
  2759.          case OPCODE_CULL_FACE:
  2760.             gl_CullFace( ctx, n[1].e );
  2761.             break;
  2762.          case OPCODE_DEPTH_FUNC:
  2763.             gl_DepthFunc( ctx, n[1].e );
  2764.             break;
  2765.          case OPCODE_DEPTH_MASK:
  2766.             gl_DepthMask( ctx, n[1].b );
  2767.             break;
  2768.          case OPCODE_DEPTH_RANGE:
  2769.             gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f );
  2770.             break;
  2771.          case OPCODE_DISABLE:
  2772.             gl_Disable( ctx, n[1].e );
  2773.             break;
  2774.          case OPCODE_DRAW_BUFFER:
  2775.             gl_DrawBuffer( ctx, n[1].e );
  2776.             break;
  2777.          case OPCODE_DRAW_PIXELS:
  2778.             gl_DrawPixels( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
  2779.                            n[3].e, n[4].e, n[5].data );
  2780.             break;
  2781.          case OPCODE_EDGE_FLAG:
  2782.             ctx->Current.EdgeFlag = n[1].b;
  2783.             break;
  2784.          case OPCODE_ENABLE:
  2785.             gl_Enable( ctx, n[1].e );
  2786.             break;
  2787.          case OPCODE_EVALCOORD1:
  2788.             gl_EvalCoord1f( ctx, n[1].f );
  2789.             break;
  2790.          case OPCODE_EVALCOORD2:
  2791.             gl_EvalCoord2f( ctx, n[1].f, n[2].f );
  2792.             break;
  2793.          case OPCODE_EVALMESH1:
  2794.             gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i );
  2795.             break;
  2796.          case OPCODE_EVALMESH2:
  2797.             gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
  2798.             break;
  2799.          case OPCODE_EVALPOINT1:
  2800.             gl_EvalPoint1( ctx, n[1].i );
  2801.             break;
  2802.          case OPCODE_EVALPOINT2:
  2803.             gl_EvalPoint2( ctx, n[1].i, n[2].i );
  2804.             break;
  2805.          case OPCODE_FOG:
  2806.             {
  2807. #if (defined(AMIGAWARP) && defined(__PPC__))
  2808.                g_params[0] = n[2].f;
  2809.                g_params[1] = n[3].f;
  2810.                g_params[2] = n[4].f;
  2811.                g_params[3] = n[5].f;
  2812.                gl_Fogfv( ctx, n[1].e, g_params );
  2813. #else
  2814.                GLfloat p[4];
  2815.                p[0] = n[2].f;
  2816.                p[1] = n[3].f;
  2817.                p[2] = n[4].f;
  2818.                p[3] = n[5].f;
  2819.                gl_Fogfv( ctx, n[1].e, p );
  2820. #endif
  2821.             }
  2822.             break;
  2823.          case OPCODE_FRONT_FACE:
  2824.             gl_FrontFace( ctx, n[1].e );
  2825.             break;
  2826.          case OPCODE_FRUSTUM:
  2827.             gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  2828.             break;
  2829.          case OPCODE_HINT:
  2830.             gl_Hint( ctx, n[1].e, n[2].e );
  2831.             break;
  2832.          case OPCODE_INDEX_MASK:
  2833.             gl_IndexMask( ctx, n[1].ui );
  2834.             break;
  2835.          case OPCODE_INIT_NAMES:
  2836.             gl_InitNames( ctx );
  2837.             break;
  2838.          case OPCODE_LIGHT:
  2839.             {
  2840. #if (defined(AMIGAWARP) && defined(__PPC__))
  2841.                g_params[0] = n[2].f;
  2842.                g_params[1] = n[3].f;
  2843.                g_params[2] = n[4].f;
  2844.                g_params[3] = n[5].f;
  2845.                gl_Lightfv( ctx, n[1].e, n[2].e, g_params, 4 );
  2846. #else
  2847.                GLfloat p[4];
  2848.                p[0] = n[2].f;
  2849.                p[1] = n[3].f;
  2850.                p[2] = n[4].f;
  2851.                p[3] = n[5].f;
  2852.                gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 );
  2853. #endif
  2854.             }
  2855.             break;
  2856.          case OPCODE_LIGHT_MODEL:
  2857.             {
  2858. #if (defined(AMIGAWARP) && defined(__PPC__))
  2859.                g_params[0] = n[2].f;
  2860.                g_params[1] = n[3].f;
  2861.                g_params[2] = n[4].f;
  2862.                g_params[3] = n[5].f;
  2863.                gl_LightModelfv( ctx, n[1].e, g_params );
  2864. #else
  2865.                GLfloat p[4];
  2866.                p[0] = n[2].f;
  2867.                p[1] = n[3].f;
  2868.                p[2] = n[4].f;
  2869.                p[3] = n[5].f;
  2870.                gl_LightModelfv( ctx, n[1].e, p );
  2871. #endif
  2872.             }
  2873.             break;
  2874.          case OPCODE_LINE_STIPPLE:
  2875.             gl_LineStipple( ctx, n[1].i, n[2].us );
  2876.             break;
  2877.          case OPCODE_LINE_WIDTH:
  2878.             gl_LineWidth( ctx, n[1].f );
  2879.             break;
  2880.          case OPCODE_LIST_BASE:
  2881.             gl_ListBase( ctx, n[1].ui );
  2882.             break;
  2883.          case OPCODE_LOAD_IDENTITY:
  2884.             gl_LoadIdentity( ctx );
  2885.             break;
  2886.          case OPCODE_LOAD_MATRIX:
  2887.             if (sizeof(Node)==sizeof(GLfloat)) {
  2888.                gl_LoadMatrixf( ctx, &n[1].f );
  2889.             }
  2890.             else {
  2891. #if (defined(AMIGAWARP) && defined(__PPC__))
  2892.                GLuint i;
  2893.                for (i=0;i<16;i++) {
  2894.                   g_params[i] = n[1+i].f;
  2895.                }
  2896.                gl_LoadMatrixf( ctx, g_params );
  2897. #else
  2898.                GLfloat m[16];
  2899.                GLuint i;
  2900.                for (i=0;i<16;i++) {
  2901.                   m[i] = n[1+i].f;
  2902.                }
  2903.                gl_LoadMatrixf( ctx, m );
  2904. #endif
  2905.             }
  2906.             break;
  2907.          case OPCODE_LOAD_NAME:
  2908.             gl_LoadName( ctx, n[1].ui );
  2909.             break;
  2910.          case OPCODE_LOGIC_OP:
  2911.             gl_LogicOp( ctx, n[1].e );
  2912.             break;
  2913.          case OPCODE_MAP1:
  2914.             gl_Map1f( ctx, n[1].e, n[2].f, n[3].f,
  2915.                       n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE );
  2916.             break;
  2917.          case OPCODE_MAP2:
  2918.             gl_Map2f( ctx, n[1].e,
  2919.                       n[2].f, n[3].f,  /* u1, u2 */
  2920.                       n[6].i, n[8].i,  /* ustride, uorder */
  2921.                       n[4].f, n[5].f,  /* v1, v2 */
  2922.                       n[7].i, n[9].i,  /* vstride, vorder */
  2923.                       (GLfloat *) n[10].data,
  2924.                       GL_TRUE);
  2925.             break;
  2926.          case OPCODE_MAPGRID1:
  2927.             gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f );
  2928.             break;
  2929.          case OPCODE_MAPGRID2:
  2930.             gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
  2931.             break;
  2932.          case OPCODE_MATERIAL:
  2933.             {
  2934. #if (defined(AMIGAWARP) && defined(__PPC__))
  2935.                g_params[0] = n[3].f;
  2936.                g_params[1] = n[4].f;
  2937.                g_params[2] = n[5].f;
  2938.                g_params[3] = n[6].f;
  2939.                gl_Materialfv( ctx, n[1].e, n[2].e, g_params );
  2940. #else
  2941.                GLfloat params[4];
  2942.                params[0] = n[3].f;
  2943.                params[1] = n[4].f;
  2944.                params[2] = n[5].f;
  2945.                params[3] = n[6].f;
  2946.                gl_Materialfv( ctx, n[1].e, n[2].e, params );
  2947. #endif
  2948.             }
  2949.             break;
  2950.          case OPCODE_MATRIX_MODE:
  2951.             gl_MatrixMode( ctx, n[1].e );
  2952.             break;
  2953.          case OPCODE_MULT_MATRIX:
  2954.             if (sizeof(Node)==sizeof(GLfloat)) {
  2955.                gl_MultMatrixf( ctx, &n[1].f );
  2956.             }
  2957.             else {
  2958. #if (defined(AMIGAWARP) && defined(__PPC__))
  2959.                GLuint i;
  2960.                for (i=0;i<16;i++) {
  2961.                   g_params[i] = n[1+i].f;
  2962.                }
  2963.                gl_MultMatrixf( ctx, g_params );
  2964. #else
  2965.                GLfloat m[16];
  2966.                GLuint i;
  2967.                for (i=0;i<16;i++) {
  2968.                   m[i] = n[1+i].f;
  2969.                }
  2970.                gl_MultMatrixf( ctx, m );
  2971. #endif
  2972.             }
  2973.             break;
  2974.          case OPCODE_ORTHO:
  2975.             gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  2976.             break;
  2977.          case OPCODE_PASSTHROUGH:
  2978.             gl_PassThrough( ctx, n[1].f );
  2979.             break;
  2980.          case OPCODE_PIXEL_MAP:
  2981.             gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data );
  2982.             break;
  2983.          case OPCODE_PIXEL_TRANSFER:
  2984.             gl_PixelTransferf( ctx, n[1].e, n[2].f );
  2985.             break;
  2986.          case OPCODE_PIXEL_ZOOM:
  2987.             gl_PixelZoom( ctx, n[1].f, n[2].f );
  2988.             break;
  2989.          case OPCODE_POINT_SIZE:
  2990.             gl_PointSize( ctx, n[1].f );
  2991.             break;
  2992.          case OPCODE_POINT_PARAMETERS:
  2993.             {
  2994. #if (defined(AMIGAWARP) && defined(__PPC__))
  2995.                 g_params[0] = n[2].f;
  2996.                 g_params[1] = n[3].f;
  2997.                 g_params[2] = n[4].f;
  2998.                 gl_PointParameterfvEXT( ctx, n[1].e, g_params );
  2999. #else
  3000.                 GLfloat params[3];
  3001.                 params[0] = n[2].f;
  3002.                 params[1] = n[3].f;
  3003.                 params[2] = n[4].f;
  3004.                 gl_PointParameterfvEXT( ctx, n[1].e, params ); 
  3005. #endif
  3006.             }
  3007.             break;
  3008.          case OPCODE_POLYGON_MODE:
  3009.             gl_PolygonMode( ctx, n[1].e, n[2].e );
  3010.             break;
  3011.          case OPCODE_POLYGON_STIPPLE:
  3012.             gl_PolygonStipple( ctx, (GLubyte *) n[1].data );
  3013.             break;
  3014.          case OPCODE_POLYGON_OFFSET:
  3015.             gl_PolygonOffset( ctx, n[1].f, n[2].f );
  3016.             break;
  3017.          case OPCODE_POP_ATTRIB:
  3018.             gl_PopAttrib( ctx );
  3019.             break;
  3020.          case OPCODE_POP_MATRIX:
  3021.             gl_PopMatrix( ctx );
  3022.             break;
  3023.          case OPCODE_POP_NAME:
  3024.             gl_PopName( ctx );
  3025.             break;
  3026.          case OPCODE_PRIORITIZE_TEXTURE:
  3027.             gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f );
  3028.             break;
  3029.          case OPCODE_PUSH_ATTRIB:
  3030.             gl_PushAttrib( ctx, n[1].bf );
  3031.             break;
  3032.          case OPCODE_PUSH_MATRIX:
  3033.             gl_PushMatrix( ctx );
  3034.             break;
  3035.          case OPCODE_PUSH_NAME:
  3036.             gl_PushName( ctx, n[1].ui );
  3037.             break;
  3038.          case OPCODE_RASTER_POS:
  3039.             gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3040.             break;
  3041.          case OPCODE_READ_BUFFER:
  3042.             gl_ReadBuffer( ctx, n[1].e );
  3043.             break;
  3044.          case OPCODE_RECTF:
  3045.             gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3046.             break;
  3047.          case OPCODE_SCALE:
  3048.             gl_Scalef( ctx, n[1].f, n[2].f, n[3].f );
  3049.             break;
  3050.          case OPCODE_SCISSOR:
  3051.             gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i );
  3052.             break;
  3053.          case OPCODE_SHADE_MODEL:
  3054.             gl_ShadeModel( ctx, n[1].e );
  3055.             break;
  3056.          case OPCODE_STENCIL_FUNC:
  3057.             gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui );
  3058.             break;
  3059.          case OPCODE_STENCIL_MASK:
  3060.             gl_StencilMask( ctx, n[1].ui );
  3061.             break;
  3062.          case OPCODE_STENCIL_OP:
  3063.             gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e );
  3064.             break;
  3065.          case OPCODE_TEXENV:
  3066.             {
  3067. #if (defined(AMIGAWARP) && defined(__PPC__))
  3068.                g_params[0] = n[3].f;
  3069.                g_params[1] = n[4].f;
  3070.                g_params[2] = n[5].f;
  3071.                g_params[3] = n[6].f;
  3072.                gl_TexEnvfv( ctx, n[1].e, n[2].e, g_params );
  3073. #else
  3074.                GLfloat params[4];
  3075.                params[0] = n[3].f;
  3076.                params[1] = n[4].f;
  3077.                params[2] = n[5].f;
  3078.                params[3] = n[6].f;
  3079.                gl_TexEnvfv( ctx, n[1].e, n[2].e, params );
  3080. #endif
  3081.             }
  3082.             break;
  3083.          case OPCODE_TEXGEN:
  3084.             {
  3085. #if (defined(AMIGAWARP) && defined(__PPC__))
  3086.                g_params[0] = n[3].f;
  3087.                g_params[1] = n[4].f;
  3088.                g_params[2] = n[5].f;
  3089.                g_params[3] = n[6].f;
  3090.                gl_TexGenfv( ctx, n[1].e, n[2].e, g_params );
  3091. #else
  3092.                GLfloat params[4];
  3093.                params[0] = n[3].f;
  3094.                params[1] = n[4].f;
  3095.                params[2] = n[5].f;
  3096.                params[3] = n[6].f;
  3097.                gl_TexGenfv( ctx, n[1].e, n[2].e, params );
  3098. #endif
  3099.             }
  3100.             break;
  3101.          case OPCODE_TEXPARAMETER:
  3102.             {
  3103. #if (defined(AMIGAWARP) && defined(__PPC__))
  3104.                g_params[0] = n[3].f;
  3105.                g_params[1] = n[4].f;
  3106.                g_params[2] = n[5].f;
  3107.                g_params[3] = n[6].f;
  3108.                gl_TexParameterfv( ctx, n[1].e, n[2].e, g_params );
  3109. #else
  3110.                GLfloat params[4];
  3111.                params[0] = n[3].f;
  3112.                params[1] = n[4].f;
  3113.                params[2] = n[5].f;
  3114.                params[3] = n[6].f;
  3115.                gl_TexParameterfv( ctx, n[1].e, n[2].e, params );
  3116. #endif
  3117.             }
  3118.             break;
  3119.          case OPCODE_TEX_IMAGE1D:
  3120.             gl_TexImage1D( ctx,
  3121.                            n[1].e, /* target */
  3122.                            n[2].i, /* level */
  3123.                            n[3].i, /* components */
  3124.                            n[4].i, /* width */
  3125.                            n[5].e, /* border */
  3126.                            n[6].e, /* format */
  3127.                            n[7].e, /* type */
  3128.                            (struct gl_image *) n[8].data );
  3129.             break;
  3130.          case OPCODE_TEX_IMAGE2D:
  3131.             gl_TexImage2D( ctx,
  3132.                            n[1].e, /* target */
  3133.                            n[2].i, /* level */
  3134.                            n[3].i, /* components */
  3135.                            n[4].i, /* width */
  3136.                            n[5].i, /* height */
  3137.                            n[6].e, /* border */
  3138.                            n[7].e, /* format */
  3139.                            n[8].e, /* type */
  3140.                            (struct gl_image *) n[9].data );
  3141.             break;
  3142.          case OPCODE_TEX_IMAGE3D:
  3143.             gl_TexImage3DEXT( ctx,
  3144.                               n[1].e, /* target */
  3145.                               n[2].i, /* level */
  3146.                               n[3].i, /* components */
  3147.                               n[4].i, /* width */
  3148.                               n[5].i, /* height */
  3149.                               n[6].i, /* depth  */
  3150.                               n[7].e, /* border */
  3151.                               n[8].e, /* format */
  3152.                               n[9].e, /* type */
  3153.                               (struct gl_image *) n[10].data );
  3154.             break;
  3155.          case OPCODE_TEX_SUB_IMAGE1D:
  3156.             gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
  3157.                               n[6].e, (struct gl_image *) n[7].data );
  3158.             break;
  3159.          case OPCODE_TEX_SUB_IMAGE2D:
  3160.             gl_TexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
  3161.                               n[6].i, n[7].e, n[8].e,
  3162.                               (struct gl_image *) n[9].data );
  3163.             break;
  3164.          case OPCODE_TEX_SUB_IMAGE3D:
  3165.             gl_TexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i,
  3166.                                  n[6].i, n[7].i, n[8].i, n[9].e, n[10].e,
  3167.                                  (struct gl_image *) n[11].data );
  3168.             break;
  3169.          case OPCODE_TRANSLATE:
  3170.             gl_Translatef( ctx, n[1].f, n[2].f, n[3].f );
  3171.             break;
  3172.          case OPCODE_VIEWPORT:
  3173.             gl_Viewport( ctx,
  3174.                          n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
  3175.             break;
  3176.          case OPCODE_WINDOW_POS:
  3177.             gl_WindowPos4fMESA( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3178.             break;
  3179.          case OPCODE_CONTINUE:
  3180.             n = (Node *) n[1].next;
  3181.             break;
  3182.          case OPCODE_END_OF_LIST:
  3183.             done = GL_TRUE;
  3184.             break;
  3185.          default:
  3186.             {
  3187.                char msg[1000];
  3188.                sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
  3189.                gl_problem( ctx, msg );
  3190.             }
  3191.             done = GL_TRUE;
  3192.       }
  3193.  
  3194.       /* increment n to point to next compiled command */
  3195.       if (opcode!=OPCODE_CONTINUE) {
  3196.          n += InstSize[opcode];
  3197.       }
  3198.  
  3199.    }
  3200.    ctx->CallDepth--;
  3201. }
  3202.  
  3203.  
  3204.  
  3205. /**********************************************************************/
  3206. /*                           GL functions                             */
  3207. /**********************************************************************/
  3208.  
  3209.  
  3210.  
  3211. /*
  3212.  * Test if a display list number is valid.
  3213.  */
  3214. GLboolean gl_IsList( GLcontext *ctx, GLuint list )
  3215. {
  3216.    if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) {
  3217.       return GL_TRUE;
  3218.    }
  3219.    else {
  3220.       return GL_FALSE;
  3221.    }
  3222. }
  3223.  
  3224.  
  3225.  
  3226. /*
  3227.  * Delete a sequence of consecutive display lists.
  3228.  */
  3229. void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range )
  3230. {
  3231.    GLuint i;
  3232.  
  3233.    if (INSIDE_BEGIN_END(ctx)) {
  3234.       gl_error( ctx, GL_INVALID_OPERATION, "glDeleteLists" );
  3235.       return;
  3236.    }
  3237.    if (range<0) {
  3238.       gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
  3239.       return;
  3240.    }
  3241.    for (i=list;i<list+range;i++) {
  3242.       gl_destroy_list( ctx, i );
  3243.    }
  3244. }
  3245.  
  3246.  
  3247.  
  3248. /*
  3249.  * Return a display list number, n, such that lists n through n+range-1
  3250.  * are free.
  3251.  */
  3252. GLuint gl_GenLists( GLcontext *ctx, GLsizei range )
  3253. {
  3254.    GLuint base;
  3255.  
  3256.    if (INSIDE_BEGIN_END(ctx)) {
  3257.       gl_error( ctx, GL_INVALID_OPERATION, "glGenLists" );
  3258.       return 0;
  3259.    }
  3260.    if (range<0) {
  3261.       gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
  3262.       return 0;
  3263.    }
  3264.    if (range==0) {
  3265.       return 0;
  3266.    }
  3267.  
  3268.    base = HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
  3269.    if (base) {
  3270.       /* reserve the list IDs by with empty/dummy lists */
  3271.       GLuint i;
  3272.       for (i=0; i<range; i++) {
  3273.          HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
  3274.       }
  3275.    }
  3276.    return base;
  3277. }
  3278.  
  3279.  
  3280.  
  3281. /*
  3282.  * Begin a new display list.
  3283.  */
  3284. void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
  3285. {
  3286.    if (INSIDE_BEGIN_END(ctx)) {
  3287.       gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  3288.       return;
  3289.    }
  3290.    if (list==0) {
  3291.       gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
  3292.       return;
  3293.    }
  3294.    if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
  3295.       gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
  3296.       return;
  3297.    }
  3298.    if (CurrentListPtr) {
  3299.       /* already compiling a display list */
  3300.       gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  3301.       return;
  3302.    }
  3303.  
  3304.    /* Allocate new display list */
  3305.    CurrentListNum = list;
  3306.    CurrentListPtr = CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
  3307.    CurrentPos = 0;
  3308.  
  3309.    ctx->CompileFlag = GL_TRUE;
  3310.    if (mode==GL_COMPILE) {
  3311.       ctx->ExecuteFlag = GL_FALSE;
  3312.    }
  3313.    else {
  3314.       /* Compile and execute */
  3315.       ctx->ExecuteFlag = GL_TRUE;
  3316.    }
  3317.  
  3318.    ctx->API = ctx->Save;  /* Switch the API function pointers */
  3319. }
  3320.  
  3321.  
  3322.  
  3323. /*
  3324.  * End definition of current display list.
  3325.  */
  3326. void gl_EndList( GLcontext *ctx )
  3327. {
  3328.    Node *n;
  3329.  
  3330.    /* Check that a list is under construction */
  3331.    if (!CurrentListPtr) {
  3332.       gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
  3333.       return;
  3334.    }
  3335.  
  3336.    n = alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
  3337.  
  3338.    /* Destroy old list, if any */
  3339.    gl_destroy_list(ctx, CurrentListNum);
  3340.    /* Install the list */
  3341.    HashInsert(ctx->Shared->DisplayList, CurrentListNum, CurrentListPtr);
  3342.  
  3343.    CurrentListNum = 0;
  3344.    CurrentListPtr = NULL;
  3345.    ctx->ExecuteFlag = GL_TRUE;
  3346.    ctx->CompileFlag = GL_FALSE;
  3347.  
  3348.    ctx->API = ctx->Exec;   /* Switch the API function pointers */
  3349. }
  3350.  
  3351.  
  3352.  
  3353. void gl_CallList( GLcontext *ctx, GLuint list )
  3354. {
  3355.    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
  3356.    /* execute the display list, and restore the CompileFlag. */
  3357.    GLboolean save_compile_flag;
  3358.    save_compile_flag = ctx->CompileFlag;
  3359.    ctx->CompileFlag = GL_FALSE;
  3360.    execute_list( ctx, list );
  3361.    ctx->CompileFlag = save_compile_flag;
  3362. }
  3363.  
  3364.  
  3365.  
  3366. /*
  3367.  * Execute glCallLists:  call multiple display lists.
  3368.  */
  3369. void gl_CallLists( GLcontext *ctx,
  3370.                    GLsizei n, GLenum type, const GLvoid *lists )
  3371. {
  3372.    GLuint i, list;
  3373.    GLboolean save_compile_flag;
  3374.  
  3375.    /* Save the CompileFlag status, turn it off, execute display list,
  3376.     * and restore the CompileFlag.
  3377.     */
  3378.    save_compile_flag = ctx->CompileFlag;
  3379.    ctx->CompileFlag = GL_FALSE;
  3380.  
  3381.    for (i=0;i<n;i++) {
  3382.       list = translate_id( i, type, lists );
  3383.       execute_list( ctx, ctx->List.ListBase + list );
  3384.    }
  3385.  
  3386.    ctx->CompileFlag = save_compile_flag;
  3387. }
  3388.  
  3389.  
  3390.  
  3391. /*
  3392.  * Set the offset added to list numbers in glCallLists.
  3393.  */
  3394. void gl_ListBase( GLcontext *ctx, GLuint base )
  3395. {
  3396.    if (INSIDE_BEGIN_END(ctx)) {
  3397.       gl_error( ctx, GL_INVALID_OPERATION, "glListBase" );
  3398.       return;
  3399.    }
  3400.    ctx->List.ListBase = base;
  3401. }
  3402.  
  3403.  
  3404.  
  3405.  
  3406. /***
  3407.  *** Debugging code
  3408.  ***/
  3409.  
  3410. static char tmp[1000];
  3411.  
  3412. static char *enum_string( GLenum k )
  3413. {
  3414.    /* TODO: Add many more constant/string entries */
  3415.    switch (k) {
  3416.       case GL_POINTS:           return "GL_POINTS";
  3417.       case GL_LINES:            return "GL_LINES";
  3418.       case GL_LINE_STRIP:       return "GL_LINE_STRIP";
  3419.       case GL_LINE_LOOP:        return "GL_LINE_LOOP";
  3420.       case GL_TRIANGLES:        return "GL_TRIANGLES";
  3421.       case GL_TRIANGLE_STRIP:   return "GL_TRIANGLE_STRIP";
  3422.       case GL_TRIANGLE_FAN:     return "GL_TRIANGLE_FAN";
  3423.       case GL_QUADS:            return "GL_QUADS";
  3424.       case GL_QUAD_STRIP:       return "GL_QUAD_STRIP";
  3425.       case GL_POLYGON:          return "GL_POLYGON";
  3426.       case GL_FRONT:            return "GL_FRONT";
  3427.       case GL_BACK:             return "GL_BACK";
  3428.       case GL_FRONT_AND_BACK:   return "GL_FRONT_AND_BACK";
  3429.       case GL_AMBIENT:          return "GL_AMBIENT";
  3430.       case GL_DIFFUSE:          return "GL_DIFFUSE";
  3431.       case GL_SPECULAR:         return "GL_SPECULAR";
  3432.       case GL_SHININESS:        return "GL_SHININESS";
  3433.       default:
  3434.          sprintf(tmp,"0x%X", k);
  3435.          return tmp;
  3436.    }
  3437. }
  3438.  
  3439.  
  3440. /*
  3441.  * Print the commands in a display list.  For debugging only.
  3442.  * TODO: many commands aren't handled yet.
  3443.  */
  3444. static void print_list( GLcontext *ctx, FILE *f, GLuint list )
  3445. {
  3446.    Node *n;
  3447.    GLboolean done;
  3448.    OpCode opcode;
  3449.  
  3450.    if (!glIsList(list)) {
  3451.       fprintf(f,"%d is not a display list ID\n",list);
  3452.       return;
  3453.    }
  3454.  
  3455.    n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  3456.  
  3457.    fprintf( f, "START-LIST %d, address %p\n", list, (void*)n );
  3458.  
  3459.    done = n ? GL_FALSE : GL_TRUE;
  3460.    while (!done) {
  3461.       opcode = n[0].opcode;
  3462.  
  3463.       switch (opcode) {
  3464.          case OPCODE_ACCUM:
  3465.             fprintf(f,"accum %d %g\n", n[1].e, n[2].f );
  3466.             break;
  3467.          case OPCODE_BEGIN:
  3468.             fprintf(f,"Begin %s\n", enum_string(n[1].e) );
  3469.             break;
  3470.          case OPCODE_BITMAP:
  3471.             fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
  3472.                        n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
  3473.             break;
  3474.          case OPCODE_CALL_LIST:
  3475.             fprintf(f,"CallList %d\n", n[1].ui );
  3476.             break;
  3477.          case OPCODE_CALL_LIST_OFFSET:
  3478.             fprintf(f,"CallList %d + offset %d = %d\n", n[1].ui,
  3479.                     ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
  3480.             break;
  3481.          case OPCODE_COLOR_3F:
  3482.             fprintf(f,"Color3f %g %g %gn", n[1].f, n[2].f, n[3].f );
  3483.             break;
  3484.          case OPCODE_COLOR_4F:
  3485.             fprintf(f,"Color4f %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
  3486.             break;
  3487.          case OPCODE_COLOR_4UB:
  3488.             fprintf(f,"Color4ub %d %d %d %d\n", n[1].ub, n[2].ub,
  3489.                                                 n[3].ub, n[4].ub );
  3490.             break;
  3491.          case OPCODE_DISABLE:
  3492.             fprintf(f,"Disable %s\n", enum_string(n[1].e));
  3493.             break;
  3494.          case OPCODE_ENABLE:
  3495.             fprintf(f,"Enable %s\n", enum_string(n[1].e));
  3496.             break;
  3497.          case OPCODE_END:
  3498.             fprintf(f,"End\n");
  3499.             break;
  3500.          case OPCODE_FRUSTUM:
  3501.             fprintf(f,"Frustum %g %g %g %g %g %g\n",
  3502.                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  3503.             break;
  3504.          case OPCODE_INDEX:
  3505.             fprintf(f,"Index %d\n", n[1].ui );
  3506.             break;
  3507.          case OPCODE_LINE_STIPPLE:
  3508.             fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
  3509.             break;
  3510.          case OPCODE_LOAD_IDENTITY:
  3511.             fprintf(f,"LoadIdentity\n");
  3512.             break;
  3513.          case OPCODE_LOAD_MATRIX:
  3514.             fprintf(f,"LoadMatrix\n");
  3515.             fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
  3516.             fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
  3517.             fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
  3518.             fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
  3519.             break;
  3520.          case OPCODE_MATERIAL:
  3521.             fprintf(f,"Material %s %s %g %g %g %g\n", enum_string(n[1].e),
  3522.                     enum_string(n[2].e), n[3].f, n[4].f, n[5].f, n[6].f );
  3523.             break;
  3524.          case OPCODE_MULT_MATRIX:
  3525.             fprintf(f,"MultMatrix (or Rotate)\n");
  3526.             fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
  3527.             fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
  3528.             fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
  3529.             fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
  3530.             break;
  3531.          case OPCODE_NORMAL:
  3532.             fprintf(f,"Normal %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3533.             break;
  3534.          case OPCODE_ORTHO:
  3535.             fprintf(f,"Ortho %g %g %g %g %g %g\n",
  3536.                     n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  3537.             break;
  3538.          case OPCODE_POP_ATTRIB:
  3539.             fprintf(f,"PopAttrib\n");
  3540.             break;
  3541.          case OPCODE_POP_MATRIX:
  3542.             fprintf(f,"PopMatrix\n");
  3543.             break;
  3544.          case OPCODE_POP_NAME:
  3545.             fprintf(f,"PopName\n");
  3546.             break;
  3547.          case OPCODE_PUSH_ATTRIB:
  3548.             fprintf(f,"PushAttrib %x\n", n[1].bf );
  3549.             break;
  3550.          case OPCODE_PUSH_MATRIX:
  3551.             fprintf(f,"PushMatrix\n");
  3552.             break;
  3553.          case OPCODE_PUSH_NAME:
  3554.             fprintf(f,"PushName %d\n", n[1].ui );
  3555.             break;
  3556.          case OPCODE_RASTER_POS:
  3557.             fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
  3558.             break;
  3559.          case OPCODE_RECTF:
  3560.             fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
  3561.             break;
  3562.          case OPCODE_SCALE:
  3563.             fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3564.             break;
  3565.          case OPCODE_TEXCOORD2:
  3566.             fprintf(f,"TexCoord %g %g\n", n[1].f, n[2].f);
  3567.             break;
  3568.          case OPCODE_TEXCOORD4:
  3569.             fprintf(f,"TexCoord %g %g %g %g\n", n[1].f, n[2].f, n[3].f,n[4].f);
  3570.             break;
  3571.          case OPCODE_TRANSLATE:
  3572.             fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3573.             break;
  3574.          case OPCODE_VERTEX2:
  3575.             fprintf(f,"Vertex %g %g\n", n[1].f, n[2].f );
  3576.             break;
  3577.          case OPCODE_VERTEX3:
  3578.             fprintf(f,"Vertex %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3579.             break;
  3580.          case OPCODE_VERTEX4:
  3581.             fprintf(f,"Vertex %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
  3582.             break;
  3583.  
  3584.          /*
  3585.           * meta opcodes/commands
  3586.           */
  3587.          case OPCODE_CONTINUE:
  3588.             fprintf(f,"DISPLAY-LIST-CONTINUE\n");
  3589.             n = (Node *) n[1].next;
  3590.             break;
  3591.          case OPCODE_END_OF_LIST:
  3592.             fprintf(f,"END-LIST %d\n", list);
  3593.             done = GL_TRUE;
  3594.             break;
  3595.          default:
  3596.             if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
  3597.                fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
  3598.                        opcode, (void*) n);
  3599.                return;
  3600.             }
  3601.             else {
  3602.                fprintf(f,"command %d, %d operands\n",opcode,InstSize[opcode]);
  3603.             }
  3604.       }
  3605.  
  3606.       /* increment n to point to next compiled command */
  3607.       if (opcode!=OPCODE_CONTINUE) {
  3608.          n += InstSize[opcode];
  3609.       }
  3610.  
  3611.    }
  3612. }
  3613.  
  3614.  
  3615.  
  3616. /*
  3617.  * Clients may call this function to help debug display list problems.
  3618.  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
  3619.  * changed, or break in the future without notice.
  3620.  */
  3621. void mesa_print_display_list( GLuint list )
  3622. {
  3623.    GLcontext *ctx;
  3624. #ifdef MULTI_THREADING
  3625.    ctx = gl_get_thread_context();
  3626. #else
  3627.    ctx = CC;
  3628. #endif
  3629.    print_list( ctx, stdout, list );
  3630. }
  3631.