Debian Codegraph @

debian/external_deps/fetk/sg/src/gl/dlist.c

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