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