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