use BCOPY macro on FreeBSD
[mesa.git] / src / mesa / main / dlist.c
1 /* $Id: dlist.c,v 1.36 2000/03/21 17:42:27 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 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 "glheader.h"
32 #include "accum.h"
33 #include "attrib.h"
34 #include "bitmap.h"
35 #include "bbox.h"
36 #include "blend.h"
37 #include "buffers.h"
38 #include "clip.h"
39 #include "colortab.h"
40 #include "context.h"
41 #include "copypix.h"
42 #include "cva.h"
43 #include "depth.h"
44 #include "enable.h"
45 #include "enums.h"
46 #include "eval.h"
47 #include "extensions.h"
48 #include "feedback.h"
49 #include "get.h"
50 #include "glapi.h"
51 #include "hash.h"
52 #include "image.h"
53 #include "imaging.h"
54 #include "light.h"
55 #include "lines.h"
56 #include "dlist.h"
57 #include "macros.h"
58 #include "matrix.h"
59 #include "mem.h"
60 #include "pipeline.h"
61 #include "pixel.h"
62 #include "points.h"
63 #include "polygon.h"
64 #include "readpix.h"
65 #include "rect.h"
66 #include "state.h"
67 #include "texobj.h"
68 #include "teximage.h"
69 #include "texstate.h"
70 #include "types.h"
71 #include "varray.h"
72 #include "vb.h"
73 #include "vbfill.h"
74 #include "vbxform.h"
75 #include "xform.h"
76 #endif
77
78
79
80 /*
81 Functions which aren't compiled but executed immediately:
82 glIsList
83 glGenLists
84 glDeleteLists
85 glEndList
86 glFeedbackBuffer
87 glSelectBuffer
88 glRenderMode
89 glReadPixels
90 glPixelStore
91 glFlush
92 glFinish
93 glIsEnabled
94 glGet*
95
96 Functions which cause errors if called while compiling a display list:
97 glNewList
98 */
99
100
101
102 /*
103 * Display list instructions are stored as sequences of "nodes". Nodes
104 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
105 * are linked together with a pointer.
106 */
107
108
109 /* How many nodes to allocate at a time:
110 * - reduced now that we hold vertices etc. elsewhere.
111 */
112 #define BLOCK_SIZE 64
113
114
115 /*
116 * Display list opcodes.
117 *
118 * The fact that these identifiers are assigned consecutive
119 * integer values starting at 0 is very important, see InstSize array usage)
120 *
121 * KW: Commented out opcodes now handled by vertex-cassettes.
122 */
123 typedef enum {
124 OPCODE_ACCUM,
125 OPCODE_ALPHA_FUNC,
126 OPCODE_BIND_TEXTURE,
127 OPCODE_BITMAP,
128 OPCODE_BLEND_COLOR,
129 OPCODE_BLEND_EQUATION,
130 OPCODE_BLEND_FUNC,
131 OPCODE_BLEND_FUNC_SEPARATE,
132 OPCODE_CALL_LIST,
133 OPCODE_CALL_LIST_OFFSET,
134 OPCODE_CLEAR,
135 OPCODE_CLEAR_ACCUM,
136 OPCODE_CLEAR_COLOR,
137 OPCODE_CLEAR_DEPTH,
138 OPCODE_CLEAR_INDEX,
139 OPCODE_CLEAR_STENCIL,
140 OPCODE_CLIP_PLANE,
141 OPCODE_COLOR_MASK,
142 OPCODE_COLOR_MATERIAL,
143 OPCODE_COLOR_TABLE,
144 OPCODE_COLOR_SUB_TABLE,
145 OPCODE_COPY_PIXELS,
146 OPCODE_COPY_TEX_IMAGE1D,
147 OPCODE_COPY_TEX_IMAGE2D,
148 OPCODE_COPY_TEX_SUB_IMAGE1D,
149 OPCODE_COPY_TEX_SUB_IMAGE2D,
150 OPCODE_COPY_TEX_SUB_IMAGE3D,
151 OPCODE_CULL_FACE,
152 OPCODE_DEPTH_FUNC,
153 OPCODE_DEPTH_MASK,
154 OPCODE_DEPTH_RANGE,
155 OPCODE_DISABLE,
156 OPCODE_DRAW_BUFFER,
157 OPCODE_DRAW_PIXELS,
158 OPCODE_ENABLE,
159 OPCODE_EVALCOORD1,
160 OPCODE_EVALCOORD2,
161 OPCODE_EVALMESH1,
162 OPCODE_EVALMESH2,
163 OPCODE_EVALPOINT1,
164 OPCODE_EVALPOINT2,
165 OPCODE_FOG,
166 OPCODE_FRONT_FACE,
167 OPCODE_FRUSTUM,
168 OPCODE_HINT,
169 OPCODE_HINT_PGI,
170 OPCODE_INDEX_MASK,
171 OPCODE_INIT_NAMES,
172 OPCODE_LIGHT,
173 OPCODE_LIGHT_MODEL,
174 OPCODE_LINE_STIPPLE,
175 OPCODE_LINE_WIDTH,
176 OPCODE_LIST_BASE,
177 OPCODE_LOAD_IDENTITY,
178 OPCODE_LOAD_MATRIX,
179 OPCODE_LOAD_NAME,
180 OPCODE_LOGIC_OP,
181 OPCODE_MAP1,
182 OPCODE_MAP2,
183 OPCODE_MAPGRID1,
184 OPCODE_MAPGRID2,
185 OPCODE_MATRIX_MODE,
186 OPCODE_MULT_MATRIX,
187 OPCODE_ORTHO,
188 OPCODE_PASSTHROUGH,
189 OPCODE_PIXEL_MAP,
190 OPCODE_PIXEL_TRANSFER,
191 OPCODE_PIXEL_ZOOM,
192 OPCODE_POINT_SIZE,
193 OPCODE_POINT_PARAMETERS,
194 OPCODE_POLYGON_MODE,
195 OPCODE_POLYGON_STIPPLE,
196 OPCODE_POLYGON_OFFSET,
197 OPCODE_POP_ATTRIB,
198 OPCODE_POP_MATRIX,
199 OPCODE_POP_NAME,
200 OPCODE_PRIORITIZE_TEXTURE,
201 OPCODE_PUSH_ATTRIB,
202 OPCODE_PUSH_MATRIX,
203 OPCODE_PUSH_NAME,
204 OPCODE_RASTER_POS,
205 OPCODE_RECTF,
206 OPCODE_READ_BUFFER,
207 OPCODE_SCALE,
208 OPCODE_SCISSOR,
209 OPCODE_SELECT_TEXTURE_SGIS,
210 OPCODE_SELECT_TEXTURE_COORD_SET,
211 OPCODE_SHADE_MODEL,
212 OPCODE_STENCIL_FUNC,
213 OPCODE_STENCIL_MASK,
214 OPCODE_STENCIL_OP,
215 OPCODE_TEXENV,
216 OPCODE_TEXGEN,
217 OPCODE_TEXPARAMETER,
218 OPCODE_TEX_IMAGE1D,
219 OPCODE_TEX_IMAGE2D,
220 OPCODE_TEX_IMAGE3D,
221 OPCODE_TEX_SUB_IMAGE1D,
222 OPCODE_TEX_SUB_IMAGE2D,
223 OPCODE_TEX_SUB_IMAGE3D,
224 OPCODE_TRANSLATE,
225 OPCODE_VIEWPORT,
226 OPCODE_WINDOW_POS,
227 /* GL_ARB_multitexture */
228 OPCODE_ACTIVE_TEXTURE,
229 OPCODE_CLIENT_ACTIVE_TEXTURE,
230 /* The following three are meta instructions */
231 OPCODE_ERROR, /* raise compiled-in error */
232 OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */
233 OPCODE_CONTINUE,
234 OPCODE_END_OF_LIST
235 } OpCode;
236
237
238 /*
239 * Each instruction in the display list is stored as a sequence of
240 * contiguous nodes in memory.
241 * Each node is the union of a variety of datatypes.
242 */
243 union node {
244 OpCode opcode;
245 GLboolean b;
246 GLbitfield bf;
247 GLubyte ub;
248 GLshort s;
249 GLushort us;
250 GLint i;
251 GLuint ui;
252 GLenum e;
253 GLfloat f;
254 GLvoid *data;
255 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
256 };
257
258
259
260 /* Number of nodes of storage needed for each instruction: */
261 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
262
263 void mesa_print_display_list( GLuint list );
264
265
266 /**********************************************************************/
267 /***** Private *****/
268 /**********************************************************************/
269
270
271 /*
272 * Allocate space for a display list instruction.
273 * Input: opcode - type of instruction
274 * argcount - number of arguments following the instruction
275 * Return: pointer to first node in the instruction
276 */
277 static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
278 {
279 Node *n, *newblock;
280 GLuint count = InstSize[opcode];
281
282 assert( (GLint) count == argcount+1 );
283
284 if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
285 /* This block is full. Allocate a new block and chain to it */
286 n = ctx->CurrentBlock + ctx->CurrentPos;
287 n[0].opcode = OPCODE_CONTINUE;
288 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
289 if (!newblock) {
290 gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
291 return NULL;
292 }
293 n[1].next = (Node *) newblock;
294 ctx->CurrentBlock = newblock;
295 ctx->CurrentPos = 0;
296 }
297
298 n = ctx->CurrentBlock + ctx->CurrentPos;
299 ctx->CurrentPos += count;
300
301 n[0].opcode = opcode;
302
303 return n;
304 }
305
306
307
308 /*
309 * Make an empty display list. This is used by glGenLists() to
310 * reserver display list IDs.
311 */
312 static Node *make_empty_list( void )
313 {
314 Node *n = (Node *) MALLOC( sizeof(Node) );
315 n[0].opcode = OPCODE_END_OF_LIST;
316 return n;
317 }
318
319
320
321 /*
322 * Destroy all nodes in a display list.
323 * Input: list - display list number
324 */
325 void gl_destroy_list( GLcontext *ctx, GLuint list )
326 {
327 Node *n, *block;
328 GLboolean done;
329
330 if (list==0)
331 return;
332
333 block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
334 n = block;
335
336 done = block ? GL_FALSE : GL_TRUE;
337 while (!done) {
338 switch (n[0].opcode) {
339 /* special cases first */
340 case OPCODE_VERTEX_CASSETTE:
341 if ( ! -- ((struct immediate *) n[1].data)->ref_count )
342 gl_immediate_free( (struct immediate *) n[1].data );
343 n += InstSize[n[0].opcode];
344 break;
345 case OPCODE_MAP1:
346 FREE(n[6].data);
347 n += InstSize[n[0].opcode];
348 break;
349 case OPCODE_MAP2:
350 FREE(n[10].data);
351 n += InstSize[n[0].opcode];
352 break;
353 case OPCODE_DRAW_PIXELS:
354 FREE( n[5].data );
355 n += InstSize[n[0].opcode];
356 break;
357 case OPCODE_BITMAP:
358 FREE( n[7].data );
359 n += InstSize[n[0].opcode];
360 break;
361 case OPCODE_COLOR_TABLE:
362 FREE( n[6].data );
363 n += InstSize[n[0].opcode];
364 break;
365 case OPCODE_COLOR_SUB_TABLE:
366 FREE( n[6].data );
367 n += InstSize[n[0].opcode];
368 break;
369 case OPCODE_POLYGON_STIPPLE:
370 FREE( n[1].data );
371 n += InstSize[n[0].opcode];
372 break;
373 case OPCODE_TEX_IMAGE1D:
374 FREE(n[8].data);
375 n += InstSize[n[0].opcode];
376 break;
377 case OPCODE_TEX_IMAGE2D:
378 FREE( n[9]. data );
379 n += InstSize[n[0].opcode];
380 break;
381 case OPCODE_TEX_IMAGE3D:
382 FREE( n[10]. data );
383 n += InstSize[n[0].opcode];
384 break;
385 case OPCODE_TEX_SUB_IMAGE1D:
386 FREE(n[7].data);
387 n += InstSize[n[0].opcode];
388 break;
389 case OPCODE_TEX_SUB_IMAGE2D:
390 FREE(n[9].data);
391 n += InstSize[n[0].opcode];
392 break;
393 case OPCODE_TEX_SUB_IMAGE3D:
394 FREE(n[11].data);
395 n += InstSize[n[0].opcode];
396 break;
397 case OPCODE_CONTINUE:
398 n = (Node *) n[1].next;
399 FREE( block );
400 block = n;
401 break;
402 case OPCODE_END_OF_LIST:
403 FREE( block );
404 done = GL_TRUE;
405 break;
406 default:
407 /* Most frequent case */
408 n += InstSize[n[0].opcode];
409 break;
410 }
411 }
412
413 _mesa_HashRemove(ctx->Shared->DisplayList, list);
414 }
415
416
417
418 /*
419 * Translate the nth element of list from type to GLuint.
420 */
421 static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
422 {
423 GLbyte *bptr;
424 GLubyte *ubptr;
425 GLshort *sptr;
426 GLushort *usptr;
427 GLint *iptr;
428 GLuint *uiptr;
429 GLfloat *fptr;
430
431 switch (type) {
432 case GL_BYTE:
433 bptr = (GLbyte *) list;
434 return (GLuint) *(bptr+n);
435 case GL_UNSIGNED_BYTE:
436 ubptr = (GLubyte *) list;
437 return (GLuint) *(ubptr+n);
438 case GL_SHORT:
439 sptr = (GLshort *) list;
440 return (GLuint) *(sptr+n);
441 case GL_UNSIGNED_SHORT:
442 usptr = (GLushort *) list;
443 return (GLuint) *(usptr+n);
444 case GL_INT:
445 iptr = (GLint *) list;
446 return (GLuint) *(iptr+n);
447 case GL_UNSIGNED_INT:
448 uiptr = (GLuint *) list;
449 return (GLuint) *(uiptr+n);
450 case GL_FLOAT:
451 fptr = (GLfloat *) list;
452 return (GLuint) *(fptr+n);
453 case GL_2_BYTES:
454 ubptr = ((GLubyte *) list) + 2*n;
455 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
456 case GL_3_BYTES:
457 ubptr = ((GLubyte *) list) + 3*n;
458 return (GLuint) *ubptr * 65536
459 + (GLuint) *(ubptr+1) * 256
460 + (GLuint) *(ubptr+2);
461 case GL_4_BYTES:
462 ubptr = ((GLubyte *) list) + 4*n;
463 return (GLuint) *ubptr * 16777216
464 + (GLuint) *(ubptr+1) * 65536
465 + (GLuint) *(ubptr+2) * 256
466 + (GLuint) *(ubptr+3);
467 default:
468 return 0;
469 }
470 }
471
472
473
474
475 /**********************************************************************/
476 /***** Public *****/
477 /**********************************************************************/
478
479 void gl_init_lists( void )
480 {
481 static int init_flag = 0;
482
483 if (init_flag==0) {
484 InstSize[OPCODE_ACCUM] = 3;
485 InstSize[OPCODE_ALPHA_FUNC] = 3;
486 InstSize[OPCODE_BIND_TEXTURE] = 3;
487 InstSize[OPCODE_BITMAP] = 8;
488 InstSize[OPCODE_BLEND_COLOR] = 5;
489 InstSize[OPCODE_BLEND_EQUATION] = 2;
490 InstSize[OPCODE_BLEND_FUNC] = 3;
491 InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
492 InstSize[OPCODE_CALL_LIST] = 2;
493 InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
494 InstSize[OPCODE_CLEAR] = 2;
495 InstSize[OPCODE_CLEAR_ACCUM] = 5;
496 InstSize[OPCODE_CLEAR_COLOR] = 5;
497 InstSize[OPCODE_CLEAR_DEPTH] = 2;
498 InstSize[OPCODE_CLEAR_INDEX] = 2;
499 InstSize[OPCODE_CLEAR_STENCIL] = 2;
500 InstSize[OPCODE_CLIP_PLANE] = 6;
501 InstSize[OPCODE_COLOR_MASK] = 5;
502 InstSize[OPCODE_COLOR_MATERIAL] = 3;
503 InstSize[OPCODE_COLOR_TABLE] = 7;
504 InstSize[OPCODE_COLOR_SUB_TABLE] = 7;
505 InstSize[OPCODE_COPY_PIXELS] = 6;
506 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
507 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
508 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
509 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
510 InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
511 InstSize[OPCODE_CULL_FACE] = 2;
512 InstSize[OPCODE_DEPTH_FUNC] = 2;
513 InstSize[OPCODE_DEPTH_MASK] = 2;
514 InstSize[OPCODE_DEPTH_RANGE] = 3;
515 InstSize[OPCODE_DISABLE] = 2;
516 InstSize[OPCODE_DRAW_BUFFER] = 2;
517 InstSize[OPCODE_DRAW_PIXELS] = 6;
518 InstSize[OPCODE_ENABLE] = 2;
519 InstSize[OPCODE_EVALCOORD1] = 2;
520 InstSize[OPCODE_EVALCOORD2] = 3;
521 InstSize[OPCODE_EVALMESH1] = 4;
522 InstSize[OPCODE_EVALMESH2] = 6;
523 InstSize[OPCODE_EVALPOINT1] = 2;
524 InstSize[OPCODE_EVALPOINT2] = 3;
525 InstSize[OPCODE_FOG] = 6;
526 InstSize[OPCODE_FRONT_FACE] = 2;
527 InstSize[OPCODE_FRUSTUM] = 7;
528 InstSize[OPCODE_HINT] = 3;
529 InstSize[OPCODE_HINT_PGI] = 3;
530 InstSize[OPCODE_INDEX_MASK] = 2;
531 InstSize[OPCODE_INIT_NAMES] = 1;
532 InstSize[OPCODE_LIGHT] = 7;
533 InstSize[OPCODE_LIGHT_MODEL] = 6;
534 InstSize[OPCODE_LINE_STIPPLE] = 3;
535 InstSize[OPCODE_LINE_WIDTH] = 2;
536 InstSize[OPCODE_LIST_BASE] = 2;
537 InstSize[OPCODE_LOAD_IDENTITY] = 1;
538 InstSize[OPCODE_LOAD_MATRIX] = 17;
539 InstSize[OPCODE_LOAD_NAME] = 2;
540 InstSize[OPCODE_LOGIC_OP] = 2;
541 InstSize[OPCODE_MAP1] = 7;
542 InstSize[OPCODE_MAP2] = 11;
543 InstSize[OPCODE_MAPGRID1] = 4;
544 InstSize[OPCODE_MAPGRID2] = 7;
545 InstSize[OPCODE_MATRIX_MODE] = 2;
546 InstSize[OPCODE_MULT_MATRIX] = 17;
547 InstSize[OPCODE_ORTHO] = 7;
548 InstSize[OPCODE_PASSTHROUGH] = 2;
549 InstSize[OPCODE_PIXEL_MAP] = 4;
550 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
551 InstSize[OPCODE_PIXEL_ZOOM] = 3;
552 InstSize[OPCODE_POINT_SIZE] = 2;
553 InstSize[OPCODE_POINT_PARAMETERS] = 5;
554 InstSize[OPCODE_POLYGON_MODE] = 3;
555 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
556 InstSize[OPCODE_POLYGON_OFFSET] = 3;
557 InstSize[OPCODE_POP_ATTRIB] = 1;
558 InstSize[OPCODE_POP_MATRIX] = 1;
559 InstSize[OPCODE_POP_NAME] = 1;
560 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
561 InstSize[OPCODE_PUSH_ATTRIB] = 2;
562 InstSize[OPCODE_PUSH_MATRIX] = 1;
563 InstSize[OPCODE_PUSH_NAME] = 2;
564 InstSize[OPCODE_RASTER_POS] = 5;
565 InstSize[OPCODE_RECTF] = 5;
566 InstSize[OPCODE_READ_BUFFER] = 2;
567 InstSize[OPCODE_SCALE] = 4;
568 InstSize[OPCODE_SCISSOR] = 5;
569 InstSize[OPCODE_STENCIL_FUNC] = 4;
570 InstSize[OPCODE_STENCIL_MASK] = 2;
571 InstSize[OPCODE_STENCIL_OP] = 4;
572 InstSize[OPCODE_SHADE_MODEL] = 2;
573 InstSize[OPCODE_TEXENV] = 7;
574 InstSize[OPCODE_TEXGEN] = 7;
575 InstSize[OPCODE_TEXPARAMETER] = 7;
576 InstSize[OPCODE_TEX_IMAGE1D] = 9;
577 InstSize[OPCODE_TEX_IMAGE2D] = 10;
578 InstSize[OPCODE_TEX_IMAGE3D] = 11;
579 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
580 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
581 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
582 InstSize[OPCODE_TRANSLATE] = 4;
583 InstSize[OPCODE_VIEWPORT] = 5;
584 InstSize[OPCODE_WINDOW_POS] = 5;
585 InstSize[OPCODE_CONTINUE] = 2;
586 InstSize[OPCODE_ERROR] = 3;
587 InstSize[OPCODE_VERTEX_CASSETTE] = 9;
588 InstSize[OPCODE_END_OF_LIST] = 1;
589 /* GL_ARB_multitexture */
590 InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
591 InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
592 }
593 init_flag = 1;
594 }
595
596
597 /*
598 * Display List compilation functions
599 */
600
601
602
603 static void save_Accum( GLenum op, GLfloat value )
604 {
605 GET_CURRENT_CONTEXT(ctx);
606 Node *n;
607 FLUSH_VB(ctx, "dlist");
608 n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
609 if (n) {
610 n[1].e = op;
611 n[2].f = value;
612 }
613 if (ctx->ExecuteFlag) {
614 (*ctx->Exec->Accum)( op, value );
615 }
616 }
617
618
619 static void save_AlphaFunc( GLenum func, GLclampf ref )
620 {
621 GET_CURRENT_CONTEXT(ctx);
622 Node *n;
623 FLUSH_VB(ctx, "dlist");
624 n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
625 if (n) {
626 n[1].e = func;
627 n[2].f = (GLfloat) ref;
628 }
629 if (ctx->ExecuteFlag) {
630 (*ctx->Exec->AlphaFunc)( func, ref );
631 }
632 }
633
634
635 static void save_Begin( GLenum mode )
636 {
637 _mesa_Begin(mode); /* special case */
638 }
639
640
641 static void save_BindTexture( GLenum target, GLuint texture )
642 {
643 GET_CURRENT_CONTEXT(ctx);
644 Node *n;
645 FLUSH_VB(ctx, "dlist");
646 n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
647 if (n) {
648 n[1].e = target;
649 n[2].ui = texture;
650 }
651 if (ctx->ExecuteFlag) {
652 (*ctx->Exec->BindTexture)( target, texture );
653 }
654 }
655
656
657 static void save_Bitmap( GLsizei width, GLsizei height,
658 GLfloat xorig, GLfloat yorig,
659 GLfloat xmove, GLfloat ymove,
660 const GLubyte *pixels )
661 {
662 GET_CURRENT_CONTEXT(ctx);
663 GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
664 Node *n;
665 FLUSH_VB(ctx, "dlist");
666 n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
667 if (n) {
668 n[1].i = (GLint) width;
669 n[2].i = (GLint) height;
670 n[3].f = xorig;
671 n[4].f = yorig;
672 n[5].f = xmove;
673 n[6].f = ymove;
674 n[7].data = image;
675 }
676 else if (image) {
677 FREE(image);
678 }
679 if (ctx->ExecuteFlag) {
680 (*ctx->Exec->Bitmap)( width, height,
681 xorig, yorig, xmove, ymove, pixels );
682 }
683 }
684
685
686 static void save_BlendEquation( GLenum mode )
687 {
688 GET_CURRENT_CONTEXT(ctx);
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)( mode );
697 }
698 }
699
700
701 static void save_BlendFunc( GLenum sfactor, GLenum dfactor )
702 {
703 GET_CURRENT_CONTEXT(ctx);
704 Node *n;
705 FLUSH_VB(ctx, "dlist");
706 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
707 if (n) {
708 n[1].e = sfactor;
709 n[2].e = dfactor;
710 }
711 if (ctx->ExecuteFlag) {
712 (*ctx->Exec->BlendFunc)( sfactor, dfactor );
713 }
714 }
715
716
717 static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
718 GLenum sfactorA, GLenum dfactorA)
719 {
720 GET_CURRENT_CONTEXT(ctx);
721 Node *n;
722 FLUSH_VB(ctx, "dlist");
723 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
724 if (n) {
725 n[1].e = sfactorRGB;
726 n[2].e = dfactorRGB;
727 n[3].e = sfactorA;
728 n[4].e = dfactorA;
729 }
730 if (ctx->ExecuteFlag) {
731 (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB,
732 sfactorA, dfactorA);
733 }
734 }
735
736
737 static void save_BlendColor( GLfloat red, GLfloat green,
738 GLfloat blue, GLfloat alpha )
739 {
740 GET_CURRENT_CONTEXT(ctx);
741 Node *n;
742 FLUSH_VB(ctx, "dlist");
743 n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
744 if (n) {
745 n[1].f = red;
746 n[2].f = green;
747 n[3].f = blue;
748 n[4].f = alpha;
749 }
750 if (ctx->ExecuteFlag) {
751 (*ctx->Exec->BlendColor)( red, green, blue, alpha );
752 }
753 }
754
755
756 static void save_CallList( GLuint list )
757 {
758 GET_CURRENT_CONTEXT(ctx);
759 Node *n;
760 FLUSH_VB(ctx, "dlist");
761 n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
762 if (n) {
763 n[1].ui = list;
764 }
765 if (ctx->ExecuteFlag) {
766 (*ctx->Exec->CallList)( list );
767 }
768 }
769
770
771 static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
772 {
773 GET_CURRENT_CONTEXT(ctx);
774 GLint i;
775 FLUSH_VB(ctx, "dlist");
776
777 for (i=0;i<n;i++) {
778 GLuint list = translate_id( i, type, lists );
779 Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
780 if (n) {
781 n[1].ui = list;
782 }
783 }
784 if (ctx->ExecuteFlag) {
785 (*ctx->Exec->CallLists)( n, type, lists );
786 }
787 }
788
789
790 static void save_Clear( GLbitfield mask )
791 {
792 GET_CURRENT_CONTEXT(ctx);
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)( mask );
801 }
802 }
803
804
805 static void save_ClearAccum( GLfloat red, GLfloat green,
806 GLfloat blue, GLfloat alpha )
807 {
808 GET_CURRENT_CONTEXT(ctx);
809 Node *n;
810 FLUSH_VB(ctx, "dlist");
811 n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
812 if (n) {
813 n[1].f = red;
814 n[2].f = green;
815 n[3].f = blue;
816 n[4].f = alpha;
817 }
818 if (ctx->ExecuteFlag) {
819 (*ctx->Exec->ClearAccum)( red, green, blue, alpha );
820 }
821 }
822
823
824 static void save_ClearColor( GLclampf red, GLclampf green,
825 GLclampf blue, GLclampf alpha )
826 {
827 GET_CURRENT_CONTEXT(ctx);
828 Node *n;
829 FLUSH_VB(ctx, "dlist");
830 n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
831 if (n) {
832 n[1].f = red;
833 n[2].f = green;
834 n[3].f = blue;
835 n[4].f = alpha;
836 }
837 if (ctx->ExecuteFlag) {
838 (*ctx->Exec->ClearColor)( red, green, blue, alpha );
839 }
840 }
841
842
843 static void save_ClearDepth( GLclampd depth )
844 {
845 GET_CURRENT_CONTEXT(ctx);
846 Node *n;
847 FLUSH_VB(ctx, "dlist");
848 n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
849 if (n) {
850 n[1].f = (GLfloat) depth;
851 }
852 if (ctx->ExecuteFlag) {
853 (*ctx->Exec->ClearDepth)( depth );
854 }
855 }
856
857
858 static void save_ClearIndex( GLfloat c )
859 {
860 GET_CURRENT_CONTEXT(ctx);
861 Node *n;
862 FLUSH_VB(ctx, "dlist");
863 n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
864 if (n) {
865 n[1].f = c;
866 }
867 if (ctx->ExecuteFlag) {
868 (*ctx->Exec->ClearIndex)( c );
869 }
870 }
871
872
873 static void save_ClearStencil( GLint s )
874 {
875 GET_CURRENT_CONTEXT(ctx);
876 Node *n;
877 FLUSH_VB(ctx, "dlist");
878 n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
879 if (n) {
880 n[1].i = s;
881 }
882 if (ctx->ExecuteFlag) {
883 (*ctx->Exec->ClearStencil)( s );
884 }
885 }
886
887
888 static void save_ClipPlane( GLenum plane, const GLdouble *equ )
889 {
890 GET_CURRENT_CONTEXT(ctx);
891 Node *n;
892 FLUSH_VB(ctx, "dlist");
893 n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
894 if (n) {
895 n[1].e = plane;
896 n[2].f = equ[0];
897 n[3].f = equ[1];
898 n[4].f = equ[2];
899 n[5].f = equ[3];
900 }
901 if (ctx->ExecuteFlag) {
902 (*ctx->Exec->ClipPlane)( plane, equ );
903 }
904 }
905
906
907
908 static void save_ColorMask( GLboolean red, GLboolean green,
909 GLboolean blue, GLboolean alpha )
910 {
911 GET_CURRENT_CONTEXT(ctx);
912 Node *n;
913 FLUSH_VB(ctx, "dlist");
914 n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
915 if (n) {
916 n[1].b = red;
917 n[2].b = green;
918 n[3].b = blue;
919 n[4].b = alpha;
920 }
921 if (ctx->ExecuteFlag) {
922 (*ctx->Exec->ColorMask)( red, green, blue, alpha );
923 }
924 }
925
926
927 static void save_ColorMaterial( GLenum face, GLenum mode )
928 {
929 GET_CURRENT_CONTEXT(ctx);
930 Node *n;
931 FLUSH_VB(ctx, "dlist");
932 n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
933 if (n) {
934 n[1].e = face;
935 n[2].e = mode;
936 }
937 if (ctx->ExecuteFlag) {
938 (*ctx->Exec->ColorMaterial)( face, mode );
939 }
940 }
941
942
943 static void save_ColorTable( GLenum target, GLenum internalFormat,
944 GLsizei width, GLenum format, GLenum type,
945 const GLvoid *table )
946 {
947 GET_CURRENT_CONTEXT(ctx);
948 if (target == GL_PROXY_TEXTURE_1D ||
949 target == GL_PROXY_TEXTURE_2D ||
950 target == GL_PROXY_TEXTURE_3D) {
951 /* execute immediately */
952 (*ctx->Exec->ColorTable)( target, internalFormat, width,
953 format, type, table );
954 }
955 else {
956 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
957 &ctx->Unpack);
958 Node *n;
959 FLUSH_VB(ctx, "dlist");
960 n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 6 );
961 if (n) {
962 n[1].e = target;
963 n[2].e = internalFormat;
964 n[3].i = width;
965 n[4].e = format;
966 n[5].e = type;
967 n[6].data = image;
968 }
969 else if (image) {
970 FREE(image);
971 }
972 if (ctx->ExecuteFlag) {
973 (*ctx->Exec->ColorTable)( target, internalFormat, width,
974 format, type, table );
975 }
976 }
977 }
978
979
980 static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
981 GLenum format, GLenum type,
982 const GLvoid *table)
983 {
984 GET_CURRENT_CONTEXT(ctx);
985 GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
986 &ctx->Unpack);
987 Node *n;
988 FLUSH_VB(ctx, "dlist");
989 n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
990 if (n) {
991 n[1].e = target;
992 n[2].i = start;
993 n[3].i = count;
994 n[4].e = format;
995 n[5].e = type;
996 n[6].data = image;
997 }
998 else if (image) {
999 FREE(image);
1000 }
1001 if (ctx->ExecuteFlag) {
1002 (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table);
1003 }
1004 }
1005
1006
1007
1008 static void save_CopyPixels( GLint x, GLint y,
1009 GLsizei width, GLsizei height, GLenum type )
1010 {
1011 GET_CURRENT_CONTEXT(ctx);
1012 Node *n;
1013 FLUSH_VB(ctx, "dlist");
1014 n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
1015 if (n) {
1016 n[1].i = x;
1017 n[2].i = y;
1018 n[3].i = (GLint) width;
1019 n[4].i = (GLint) height;
1020 n[5].e = type;
1021 }
1022 if (ctx->ExecuteFlag) {
1023 (*ctx->Exec->CopyPixels)( x, y, width, height, type );
1024 }
1025 }
1026
1027
1028
1029 static void
1030 save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
1031 GLint x, GLint y, GLsizei width, GLint border )
1032 {
1033 GET_CURRENT_CONTEXT(ctx);
1034 Node *n;
1035 FLUSH_VB(ctx, "dlist");
1036 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1037 if (n) {
1038 n[1].e = target;
1039 n[2].i = level;
1040 n[3].e = internalformat;
1041 n[4].i = x;
1042 n[5].i = y;
1043 n[6].i = width;
1044 n[7].i = border;
1045 }
1046 if (ctx->ExecuteFlag) {
1047 (*ctx->Exec->CopyTexImage1D)( target, level, internalformat,
1048 x, y, width, border );
1049 }
1050 }
1051
1052
1053 static void
1054 save_CopyTexImage2D( GLenum target, GLint level,
1055 GLenum internalformat,
1056 GLint x, GLint y, GLsizei width,
1057 GLsizei height, GLint border )
1058 {
1059 GET_CURRENT_CONTEXT(ctx);
1060 Node *n;
1061 FLUSH_VB(ctx, "dlist");
1062 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1063 if (n) {
1064 n[1].e = target;
1065 n[2].i = level;
1066 n[3].e = internalformat;
1067 n[4].i = x;
1068 n[5].i = y;
1069 n[6].i = width;
1070 n[7].i = height;
1071 n[8].i = border;
1072 }
1073 if (ctx->ExecuteFlag) {
1074 (*ctx->Exec->CopyTexImage2D)( target, level, internalformat,
1075 x, y, width, height, border );
1076 }
1077 }
1078
1079
1080
1081 static void
1082 save_CopyTexSubImage1D( GLenum target, GLint level,
1083 GLint xoffset, GLint x, GLint y,
1084 GLsizei width )
1085 {
1086 GET_CURRENT_CONTEXT(ctx);
1087 Node *n;
1088 FLUSH_VB(ctx, "dlist");
1089 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1090 if (n) {
1091 n[1].e = target;
1092 n[2].i = level;
1093 n[3].i = xoffset;
1094 n[4].i = x;
1095 n[5].i = y;
1096 n[6].i = width;
1097 }
1098 if (ctx->ExecuteFlag) {
1099 (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width );
1100 }
1101 }
1102
1103
1104 static void
1105 save_CopyTexSubImage2D( GLenum target, GLint level,
1106 GLint xoffset, GLint yoffset,
1107 GLint x, GLint y,
1108 GLsizei width, GLint height )
1109 {
1110 GET_CURRENT_CONTEXT(ctx);
1111 Node *n;
1112 FLUSH_VB(ctx, "dlist");
1113 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1114 if (n) {
1115 n[1].e = target;
1116 n[2].i = level;
1117 n[3].i = xoffset;
1118 n[4].i = yoffset;
1119 n[5].i = x;
1120 n[6].i = y;
1121 n[7].i = width;
1122 n[8].i = height;
1123 }
1124 if (ctx->ExecuteFlag) {
1125 (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset,
1126 x, y, width, height );
1127 }
1128 }
1129
1130
1131 static void
1132 save_CopyTexSubImage3D( GLenum target, GLint level,
1133 GLint xoffset, GLint yoffset, GLint zoffset,
1134 GLint x, GLint y,
1135 GLsizei width, GLint height )
1136 {
1137 GET_CURRENT_CONTEXT(ctx);
1138 Node *n;
1139 FLUSH_VB(ctx, "dlist");
1140 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
1141 if (n) {
1142 n[1].e = target;
1143 n[2].i = level;
1144 n[3].i = xoffset;
1145 n[4].i = yoffset;
1146 n[5].i = zoffset;
1147 n[6].i = x;
1148 n[7].i = y;
1149 n[8].i = width;
1150 n[9].i = height;
1151 }
1152 if (ctx->ExecuteFlag) {
1153 (*ctx->Exec->CopyTexSubImage3D)( target, level,
1154 xoffset, yoffset, zoffset,
1155 x, y, width, height );
1156 }
1157 }
1158
1159
1160 static void save_CullFace( GLenum mode )
1161 {
1162 GET_CURRENT_CONTEXT(ctx);
1163 Node *n;
1164 FLUSH_VB(ctx, "dlist");
1165 n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
1166 if (n) {
1167 n[1].e = mode;
1168 }
1169 if (ctx->ExecuteFlag) {
1170 (*ctx->Exec->CullFace)( mode );
1171 }
1172 }
1173
1174
1175 static void save_DepthFunc( GLenum func )
1176 {
1177 GET_CURRENT_CONTEXT(ctx);
1178 Node *n;
1179 FLUSH_VB(ctx, "dlist");
1180 n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
1181 if (n) {
1182 n[1].e = func;
1183 }
1184 if (ctx->ExecuteFlag) {
1185 (*ctx->Exec->DepthFunc)( func );
1186 }
1187 }
1188
1189
1190 static void save_DepthMask( GLboolean mask )
1191 {
1192 GET_CURRENT_CONTEXT(ctx);
1193 Node *n;
1194 FLUSH_VB(ctx, "dlist");
1195 n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
1196 if (n) {
1197 n[1].b = mask;
1198 }
1199 if (ctx->ExecuteFlag) {
1200 (*ctx->Exec->DepthMask)( mask );
1201 }
1202 }
1203
1204
1205 static void save_DepthRange( GLclampd nearval, GLclampd farval )
1206 {
1207 GET_CURRENT_CONTEXT(ctx);
1208 Node *n;
1209 FLUSH_VB(ctx, "dlist");
1210 n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
1211 if (n) {
1212 n[1].f = (GLfloat) nearval;
1213 n[2].f = (GLfloat) farval;
1214 }
1215 if (ctx->ExecuteFlag) {
1216 (*ctx->Exec->DepthRange)( nearval, farval );
1217 }
1218 }
1219
1220
1221 static void save_Disable( GLenum cap )
1222 {
1223 GET_CURRENT_CONTEXT(ctx);
1224 Node *n;
1225 FLUSH_VB(ctx, "dlist");
1226 n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
1227 if (n) {
1228 n[1].e = cap;
1229 }
1230 if (ctx->ExecuteFlag) {
1231 (*ctx->Exec->Disable)( cap );
1232 }
1233 }
1234
1235
1236 static void save_DrawBuffer( GLenum mode )
1237 {
1238 GET_CURRENT_CONTEXT(ctx);
1239 Node *n;
1240 FLUSH_VB(ctx, "dlist");
1241 n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
1242 if (n) {
1243 n[1].e = mode;
1244 }
1245 if (ctx->ExecuteFlag) {
1246 (*ctx->Exec->DrawBuffer)( mode );
1247 }
1248 }
1249
1250
1251 static void save_DrawPixels( GLsizei width, GLsizei height,
1252 GLenum format, GLenum type,
1253 const GLvoid *pixels )
1254 {
1255 GET_CURRENT_CONTEXT(ctx);
1256 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
1257 pixels, &ctx->Unpack);
1258 Node *n;
1259 FLUSH_VB(ctx, "dlist");
1260 n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 );
1261 if (n) {
1262 n[1].i = width;
1263 n[2].i = height;
1264 n[3].e = format;
1265 n[4].e = type;
1266 n[5].data = image;
1267 }
1268 else if (image) {
1269 FREE(image);
1270 }
1271 if (ctx->ExecuteFlag) {
1272 (*ctx->Exec->DrawPixels)( width, height, format, type, pixels );
1273 }
1274 }
1275
1276
1277
1278 static void save_Enable( GLenum cap )
1279 {
1280 GET_CURRENT_CONTEXT(ctx);
1281 Node *n;
1282 FLUSH_VB(ctx, "dlist");
1283 n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
1284 if (n) {
1285 n[1].e = cap;
1286 }
1287 if (ctx->ExecuteFlag) {
1288 (*ctx->Exec->Enable)( cap );
1289 }
1290 }
1291
1292
1293
1294 static void save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
1295 {
1296 GET_CURRENT_CONTEXT(ctx);
1297 Node *n;
1298 FLUSH_VB(ctx, "dlist");
1299 n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
1300 if (n) {
1301 n[1].e = mode;
1302 n[2].i = i1;
1303 n[3].i = i2;
1304 }
1305 if (ctx->ExecuteFlag) {
1306 (*ctx->Exec->EvalMesh1)( mode, i1, i2 );
1307 }
1308 }
1309
1310
1311 static void save_EvalMesh2(
1312 GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1313 {
1314 GET_CURRENT_CONTEXT(ctx);
1315 Node *n;
1316 FLUSH_VB(ctx, "dlist");
1317 n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
1318 if (n) {
1319 n[1].e = mode;
1320 n[2].i = i1;
1321 n[3].i = i2;
1322 n[4].i = j1;
1323 n[5].i = j2;
1324 }
1325 if (ctx->ExecuteFlag) {
1326 (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 );
1327 }
1328 }
1329
1330
1331
1332
1333 static void save_Fogfv( GLenum pname, const GLfloat *params )
1334 {
1335 GET_CURRENT_CONTEXT(ctx);
1336 Node *n;
1337 FLUSH_VB(ctx, "dlist");
1338 n = alloc_instruction( ctx, OPCODE_FOG, 5 );
1339 if (n) {
1340 n[1].e = pname;
1341 n[2].f = params[0];
1342 n[3].f = params[1];
1343 n[4].f = params[2];
1344 n[5].f = params[3];
1345 }
1346 if (ctx->ExecuteFlag) {
1347 (*ctx->Exec->Fogfv)( pname, params );
1348 }
1349 }
1350
1351
1352 static void save_Fogf( GLenum pname, GLfloat param )
1353 {
1354 save_Fogfv(pname, &param);
1355 }
1356
1357
1358 static void save_Fogiv(GLenum pname, const GLint *params )
1359 {
1360 GLfloat p[4];
1361 switch (pname) {
1362 case GL_FOG_MODE:
1363 case GL_FOG_DENSITY:
1364 case GL_FOG_START:
1365 case GL_FOG_END:
1366 case GL_FOG_INDEX:
1367 p[0] = (GLfloat) *params;
1368 break;
1369 case GL_FOG_COLOR:
1370 p[0] = INT_TO_FLOAT( params[0] );
1371 p[1] = INT_TO_FLOAT( params[1] );
1372 p[2] = INT_TO_FLOAT( params[2] );
1373 p[3] = INT_TO_FLOAT( params[3] );
1374 break;
1375 default:
1376 /* Error will be caught later in gl_Fogfv */
1377 ;
1378 }
1379 save_Fogfv(pname, p);
1380 }
1381
1382
1383 static void save_Fogi(GLenum pname, GLint param )
1384 {
1385 save_Fogiv(pname, &param);
1386 }
1387
1388
1389 static void save_FrontFace( GLenum mode )
1390 {
1391 GET_CURRENT_CONTEXT(ctx);
1392 Node *n;
1393 FLUSH_VB(ctx, "dlist");
1394 n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
1395 if (n) {
1396 n[1].e = mode;
1397 }
1398 if (ctx->ExecuteFlag) {
1399 (*ctx->Exec->FrontFace)( mode );
1400 }
1401 }
1402
1403
1404 static void save_Frustum( GLdouble left, GLdouble right,
1405 GLdouble bottom, GLdouble top,
1406 GLdouble nearval, GLdouble farval )
1407 {
1408 GET_CURRENT_CONTEXT(ctx);
1409 Node *n;
1410 FLUSH_VB(ctx, "dlist");
1411 n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
1412 if (n) {
1413 n[1].f = left;
1414 n[2].f = right;
1415 n[3].f = bottom;
1416 n[4].f = top;
1417 n[5].f = nearval;
1418 n[6].f = farval;
1419 }
1420 if (ctx->ExecuteFlag) {
1421 (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval );
1422 }
1423 }
1424
1425
1426 static void save_Hint( GLenum target, GLenum mode )
1427 {
1428 GET_CURRENT_CONTEXT(ctx);
1429 Node *n;
1430 FLUSH_VB(ctx, "dlist");
1431 n = alloc_instruction( ctx, OPCODE_HINT, 2 );
1432 if (n) {
1433 n[1].e = target;
1434 n[2].e = mode;
1435 }
1436 if (ctx->ExecuteFlag) {
1437 (*ctx->Exec->Hint)( target, mode );
1438 }
1439 }
1440
1441
1442 /* GL_PGI_misc_hints*/
1443 static void save_HintPGI( GLenum target, GLint mode )
1444 {
1445 GET_CURRENT_CONTEXT(ctx);
1446 Node *n;
1447 FLUSH_VB(ctx, "dlist");
1448 n = alloc_instruction( ctx, OPCODE_HINT_PGI, 2 );
1449 if (n) {
1450 n[1].e = target;
1451 n[2].i = mode;
1452 }
1453 if (ctx->ExecuteFlag) {
1454 (*ctx->Exec->HintPGI)( target, mode );
1455 }
1456 }
1457
1458
1459 static void save_IndexMask( GLuint mask )
1460 {
1461 GET_CURRENT_CONTEXT(ctx);
1462 Node *n;
1463 FLUSH_VB(ctx, "dlist");
1464 n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
1465 if (n) {
1466 n[1].ui = mask;
1467 }
1468 if (ctx->ExecuteFlag) {
1469 (*ctx->Exec->IndexMask)( mask );
1470 }
1471 }
1472
1473
1474 static void save_InitNames( void )
1475 {
1476 GET_CURRENT_CONTEXT(ctx);
1477 FLUSH_VB(ctx, "dlist");
1478 (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
1479 if (ctx->ExecuteFlag) {
1480 (*ctx->Exec->InitNames)();
1481 }
1482 }
1483
1484
1485 static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
1486 {
1487 GET_CURRENT_CONTEXT(ctx);
1488 Node *n;
1489 FLUSH_VB(ctx, "dlist");
1490 n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
1491 if (OPCODE_LIGHT) {
1492 GLint i, nParams;
1493 n[1].e = light;
1494 n[2].e = pname;
1495 switch (pname) {
1496 case GL_AMBIENT:
1497 nParams = 4;
1498 break;
1499 case GL_DIFFUSE:
1500 nParams = 4;
1501 break;
1502 case GL_SPECULAR:
1503 nParams = 4;
1504 break;
1505 case GL_POSITION:
1506 nParams = 4;
1507 break;
1508 case GL_SPOT_DIRECTION:
1509 nParams = 3;
1510 break;
1511 case GL_SPOT_EXPONENT:
1512 nParams = 1;
1513 break;
1514 case GL_SPOT_CUTOFF:
1515 nParams = 1;
1516 break;
1517 case GL_CONSTANT_ATTENUATION:
1518 nParams = 1;
1519 break;
1520 case GL_LINEAR_ATTENUATION:
1521 nParams = 1;
1522 break;
1523 case GL_QUADRATIC_ATTENUATION:
1524 nParams = 1;
1525 break;
1526 default:
1527 nParams = 0;
1528 }
1529 for (i = 0; i < nParams; i++) {
1530 n[3+i].f = params[i];
1531 }
1532 }
1533 if (ctx->ExecuteFlag) {
1534 (*ctx->Exec->Lightfv)( light, pname, params );
1535 }
1536 }
1537
1538
1539 static void save_Lightf( GLenum light, GLenum pname, GLfloat params )
1540 {
1541 save_Lightfv(light, pname, &params);
1542 }
1543
1544
1545 static void save_Lightiv( GLenum light, GLenum pname, const GLint *params )
1546 {
1547 GLfloat fparam[4];
1548 switch (pname) {
1549 case GL_AMBIENT:
1550 case GL_DIFFUSE:
1551 case GL_SPECULAR:
1552 fparam[0] = INT_TO_FLOAT( params[0] );
1553 fparam[1] = INT_TO_FLOAT( params[1] );
1554 fparam[2] = INT_TO_FLOAT( params[2] );
1555 fparam[3] = INT_TO_FLOAT( params[3] );
1556 break;
1557 case GL_POSITION:
1558 fparam[0] = (GLfloat) params[0];
1559 fparam[1] = (GLfloat) params[1];
1560 fparam[2] = (GLfloat) params[2];
1561 fparam[3] = (GLfloat) params[3];
1562 break;
1563 case GL_SPOT_DIRECTION:
1564 fparam[0] = (GLfloat) params[0];
1565 fparam[1] = (GLfloat) params[1];
1566 fparam[2] = (GLfloat) params[2];
1567 break;
1568 case GL_SPOT_EXPONENT:
1569 case GL_SPOT_CUTOFF:
1570 case GL_CONSTANT_ATTENUATION:
1571 case GL_LINEAR_ATTENUATION:
1572 case GL_QUADRATIC_ATTENUATION:
1573 fparam[0] = (GLfloat) params[0];
1574 break;
1575 default:
1576 /* error will be caught later in gl_Lightfv */
1577 ;
1578 }
1579 save_Lightfv( light, pname, fparam );
1580 }
1581
1582
1583 static void save_Lighti( GLenum light, GLenum pname, GLint param )
1584 {
1585 save_Lightiv( light, pname, &param );
1586 }
1587
1588
1589 static void save_LightModelfv( GLenum pname, const GLfloat *params )
1590 {
1591 GET_CURRENT_CONTEXT(ctx);
1592 Node *n;
1593 FLUSH_VB(ctx, "dlist");
1594 n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
1595 if (n) {
1596 n[1].e = pname;
1597 n[2].f = params[0];
1598 n[3].f = params[1];
1599 n[4].f = params[2];
1600 n[5].f = params[3];
1601 }
1602 if (ctx->ExecuteFlag) {
1603 (*ctx->Exec->LightModelfv)( pname, params );
1604 }
1605 }
1606
1607
1608 static void save_LightModelf( GLenum pname, GLfloat param )
1609 {
1610 save_LightModelfv(pname, &param);
1611 }
1612
1613
1614 static void save_LightModeliv( GLenum pname, const GLint *params )
1615 {
1616 GLfloat fparam[4];
1617 switch (pname) {
1618 case GL_LIGHT_MODEL_AMBIENT:
1619 fparam[0] = INT_TO_FLOAT( params[0] );
1620 fparam[1] = INT_TO_FLOAT( params[1] );
1621 fparam[2] = INT_TO_FLOAT( params[2] );
1622 fparam[3] = INT_TO_FLOAT( params[3] );
1623 break;
1624 case GL_LIGHT_MODEL_LOCAL_VIEWER:
1625 case GL_LIGHT_MODEL_TWO_SIDE:
1626 case GL_LIGHT_MODEL_COLOR_CONTROL:
1627 fparam[0] = (GLfloat) params[0];
1628 break;
1629 default:
1630 /* Error will be caught later in gl_LightModelfv */
1631 ;
1632 }
1633 save_LightModelfv(pname, fparam);
1634 }
1635
1636
1637 static void save_LightModeli( GLenum pname, GLint param )
1638 {
1639 save_LightModeliv(pname, &param);
1640 }
1641
1642
1643 static void save_LineStipple( GLint factor, GLushort pattern )
1644 {
1645 GET_CURRENT_CONTEXT(ctx);
1646 Node *n;
1647 FLUSH_VB(ctx, "dlist");
1648 n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
1649 if (n) {
1650 n[1].i = factor;
1651 n[2].us = pattern;
1652 }
1653 if (ctx->ExecuteFlag) {
1654 (*ctx->Exec->LineStipple)( factor, pattern );
1655 }
1656 }
1657
1658
1659 static void save_LineWidth( GLfloat width )
1660 {
1661 GET_CURRENT_CONTEXT(ctx);
1662 Node *n;
1663 FLUSH_VB(ctx, "dlist");
1664 n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
1665 if (n) {
1666 n[1].f = width;
1667 }
1668 if (ctx->ExecuteFlag) {
1669 (*ctx->Exec->LineWidth)( width );
1670 }
1671 }
1672
1673
1674 static void save_ListBase( GLuint base )
1675 {
1676 GET_CURRENT_CONTEXT(ctx);
1677 Node *n;
1678 FLUSH_VB(ctx, "dlist");
1679 n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
1680 if (n) {
1681 n[1].ui = base;
1682 }
1683 if (ctx->ExecuteFlag) {
1684 (*ctx->Exec->ListBase)( base );
1685 }
1686 }
1687
1688
1689 static void save_LoadIdentity( void )
1690 {
1691 GET_CURRENT_CONTEXT(ctx);
1692 FLUSH_VB(ctx, "dlist");
1693 (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
1694 if (ctx->ExecuteFlag) {
1695 (*ctx->Exec->LoadIdentity)();
1696 }
1697 }
1698
1699
1700 static void save_LoadMatrixf( const GLfloat *m )
1701 {
1702 GET_CURRENT_CONTEXT(ctx);
1703 Node *n;
1704 FLUSH_VB(ctx, "dlist");
1705 n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
1706 if (n) {
1707 GLuint i;
1708 for (i=0;i<16;i++) {
1709 n[1+i].f = m[i];
1710 }
1711 }
1712 if (ctx->ExecuteFlag) {
1713 (*ctx->Exec->LoadMatrixf)( m );
1714 }
1715 }
1716
1717
1718 static void save_LoadMatrixd( const GLdouble *m )
1719 {
1720 GLfloat f[16];
1721 GLint i;
1722 for (i = 0; i < 16; i++) {
1723 f[i] = m[i];
1724 }
1725 save_LoadMatrixf(f);
1726 }
1727
1728
1729 static void save_LoadName( GLuint name )
1730 {
1731 GET_CURRENT_CONTEXT(ctx);
1732 Node *n;
1733 FLUSH_VB(ctx, "dlist");
1734 n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
1735 if (n) {
1736 n[1].ui = name;
1737 }
1738 if (ctx->ExecuteFlag) {
1739 (*ctx->Exec->LoadName)( name );
1740 }
1741 }
1742
1743
1744 static void save_LogicOp( GLenum opcode )
1745 {
1746 GET_CURRENT_CONTEXT(ctx);
1747 Node *n;
1748 FLUSH_VB(ctx, "dlist");
1749 n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
1750 if (n) {
1751 n[1].e = opcode;
1752 }
1753 if (ctx->ExecuteFlag) {
1754 (*ctx->Exec->LogicOp)( opcode );
1755 }
1756 }
1757
1758
1759 static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
1760 GLint order, const GLdouble *points)
1761 {
1762 GET_CURRENT_CONTEXT(ctx);
1763 Node *n;
1764 FLUSH_VB(ctx, "dlist");
1765 n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
1766 if (n) {
1767 GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points );
1768 n[1].e = target;
1769 n[2].f = u1;
1770 n[3].f = u2;
1771 n[4].i = _mesa_evaluator_components(target); /* stride */
1772 n[5].i = order;
1773 n[6].data = (void *) pnts;
1774 }
1775 if (ctx->ExecuteFlag) {
1776 (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points );
1777 }
1778 }
1779
1780 static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
1781 GLint order, const GLfloat *points)
1782 {
1783 GET_CURRENT_CONTEXT(ctx);
1784 Node *n;
1785 FLUSH_VB(ctx, "dlist");
1786 n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
1787 if (n) {
1788 GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
1789 n[1].e = target;
1790 n[2].f = u1;
1791 n[3].f = u2;
1792 n[4].i = _mesa_evaluator_components(target); /* stride */
1793 n[5].i = order;
1794 n[6].data = (void *) pnts;
1795 }
1796 if (ctx->ExecuteFlag) {
1797 (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points );
1798 }
1799 }
1800
1801
1802 static void save_Map2d( GLenum target,
1803 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
1804 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
1805 const GLdouble *points )
1806 {
1807 GET_CURRENT_CONTEXT(ctx);
1808 Node *n;
1809 FLUSH_VB(ctx, "dlist");
1810 n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
1811 if (n) {
1812 GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder,
1813 vstride, vorder, points );
1814 n[1].e = target;
1815 n[2].f = u1;
1816 n[3].f = u2;
1817 n[4].f = v1;
1818 n[5].f = v2;
1819 /* XXX verify these strides are correct */
1820 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
1821 n[7].i = _mesa_evaluator_components(target); /*vstride*/
1822 n[8].i = uorder;
1823 n[9].i = vorder;
1824 n[10].data = (void *) pnts;
1825 }
1826 if (ctx->ExecuteFlag) {
1827 (*ctx->Exec->Map2d)( target,
1828 u1, u2, ustride, uorder,
1829 v1, v2, vstride, vorder, points );
1830 }
1831 }
1832
1833
1834 static void save_Map2f( GLenum target,
1835 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
1836 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
1837 const GLfloat *points )
1838 {
1839 GET_CURRENT_CONTEXT(ctx);
1840 Node *n;
1841 FLUSH_VB(ctx, "dlist");
1842 n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
1843 if (n) {
1844 GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
1845 vstride, vorder, points );
1846 n[1].e = target;
1847 n[2].f = u1;
1848 n[3].f = u2;
1849 n[4].f = v1;
1850 n[5].f = v2;
1851 /* XXX verify these strides are correct */
1852 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
1853 n[7].i = _mesa_evaluator_components(target); /*vstride*/
1854 n[8].i = uorder;
1855 n[9].i = vorder;
1856 n[10].data = (void *) pnts;
1857 }
1858 if (ctx->ExecuteFlag) {
1859 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
1860 v1, v2, vstride, vorder, points );
1861 }
1862 }
1863
1864
1865 static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
1866 {
1867 GET_CURRENT_CONTEXT(ctx);
1868 Node *n;
1869 FLUSH_VB(ctx, "dlist");
1870 n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
1871 if (n) {
1872 n[1].i = un;
1873 n[2].f = u1;
1874 n[3].f = u2;
1875 }
1876 if (ctx->ExecuteFlag) {
1877 (*ctx->Exec->MapGrid1f)( un, u1, u2 );
1878 }
1879 }
1880
1881
1882 static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
1883 {
1884 save_MapGrid1f(un, u1, u2);
1885 }
1886
1887
1888 static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
1889 GLint vn, GLfloat v1, GLfloat v2 )
1890 {
1891 GET_CURRENT_CONTEXT(ctx);
1892 Node *n;
1893 FLUSH_VB(ctx, "dlist");
1894 n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
1895 if (n) {
1896 n[1].i = un;
1897 n[2].f = u1;
1898 n[3].f = u2;
1899 n[4].i = vn;
1900 n[5].f = v1;
1901 n[6].f = v2;
1902 }
1903 if (ctx->ExecuteFlag) {
1904 (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 );
1905 }
1906 }
1907
1908
1909
1910 static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
1911 GLint vn, GLdouble v1, GLdouble v2 )
1912 {
1913 save_MapGrid2f(un, u1, u2, vn, v1, v2);
1914 }
1915
1916
1917 static void save_MatrixMode( GLenum mode )
1918 {
1919 GET_CURRENT_CONTEXT(ctx);
1920 Node *n;
1921 FLUSH_VB(ctx, "dlist");
1922 n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
1923 if (n) {
1924 n[1].e = mode;
1925 }
1926 if (ctx->ExecuteFlag) {
1927 (*ctx->Exec->MatrixMode)( mode );
1928 }
1929 }
1930
1931
1932 static void save_MultMatrixf( const GLfloat *m )
1933 {
1934 GET_CURRENT_CONTEXT(ctx);
1935 Node *n;
1936 FLUSH_VB(ctx, "dlist");
1937 n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
1938 if (n) {
1939 GLuint i;
1940 for (i=0;i<16;i++) {
1941 n[1+i].f = m[i];
1942 }
1943 }
1944 if (ctx->ExecuteFlag) {
1945 (*ctx->Exec->MultMatrixf)( m );
1946 }
1947 }
1948
1949
1950 static void save_MultMatrixd( const GLdouble *m )
1951 {
1952 GLfloat f[16];
1953 GLint i;
1954 for (i = 0; i < 16; i++) {
1955 f[i] = m[i];
1956 }
1957 save_MultMatrixf(f);
1958 }
1959
1960
1961 static void save_NewList( GLuint list, GLenum mode )
1962 {
1963 GET_CURRENT_CONTEXT(ctx);
1964 /* It's an error to call this function while building a display list */
1965 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
1966 (void) list;
1967 (void) mode;
1968 }
1969
1970
1971
1972 static void save_Ortho( GLdouble left, GLdouble right,
1973 GLdouble bottom, GLdouble top,
1974 GLdouble nearval, GLdouble farval )
1975 {
1976 GET_CURRENT_CONTEXT(ctx);
1977 Node *n;
1978 FLUSH_VB(ctx, "dlist");
1979 n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
1980 if (n) {
1981 n[1].f = left;
1982 n[2].f = right;
1983 n[3].f = bottom;
1984 n[4].f = top;
1985 n[5].f = nearval;
1986 n[6].f = farval;
1987 }
1988 if (ctx->ExecuteFlag) {
1989 (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval );
1990 }
1991 }
1992
1993
1994 static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
1995 {
1996 GET_CURRENT_CONTEXT(ctx);
1997 Node *n;
1998 FLUSH_VB(ctx, "dlist");
1999 n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
2000 if (n) {
2001 n[1].e = map;
2002 n[2].i = mapsize;
2003 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
2004 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
2005 }
2006 if (ctx->ExecuteFlag) {
2007 (*ctx->Exec->PixelMapfv)( map, mapsize, values );
2008 }
2009 }
2010
2011
2012 static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
2013 {
2014 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2015 GLint i;
2016 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2017 for (i=0;i<mapsize;i++) {
2018 fvalues[i] = (GLfloat) values[i];
2019 }
2020 }
2021 else {
2022 for (i=0;i<mapsize;i++) {
2023 fvalues[i] = UINT_TO_FLOAT( values[i] );
2024 }
2025 }
2026 save_PixelMapfv(map, mapsize, fvalues);
2027 }
2028
2029
2030 static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
2031 {
2032 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
2033 GLint i;
2034 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
2035 for (i=0;i<mapsize;i++) {
2036 fvalues[i] = (GLfloat) values[i];
2037 }
2038 }
2039 else {
2040 for (i=0;i<mapsize;i++) {
2041 fvalues[i] = USHORT_TO_FLOAT( values[i] );
2042 }
2043 }
2044 save_PixelMapfv(map, mapsize, fvalues);
2045 }
2046
2047
2048 static void save_PixelTransferf( GLenum pname, GLfloat param )
2049 {
2050 GET_CURRENT_CONTEXT(ctx);
2051 Node *n;
2052 FLUSH_VB(ctx, "dlist");
2053 n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
2054 if (n) {
2055 n[1].e = pname;
2056 n[2].f = param;
2057 }
2058 if (ctx->ExecuteFlag) {
2059 (*ctx->Exec->PixelTransferf)( pname, param );
2060 }
2061 }
2062
2063
2064 static void save_PixelTransferi( GLenum pname, GLint param )
2065 {
2066 save_PixelTransferf( pname, (GLfloat) param );
2067 }
2068
2069
2070 static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
2071 {
2072 GET_CURRENT_CONTEXT(ctx);
2073 Node *n;
2074 FLUSH_VB(ctx, "dlist");
2075 n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
2076 if (n) {
2077 n[1].f = xfactor;
2078 n[2].f = yfactor;
2079 }
2080 if (ctx->ExecuteFlag) {
2081 (*ctx->Exec->PixelZoom)( xfactor, yfactor );
2082 }
2083 }
2084
2085
2086 static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
2087 {
2088 GET_CURRENT_CONTEXT(ctx);
2089 Node *n;
2090 FLUSH_VB(ctx, "dlist");
2091 n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
2092 if (n) {
2093 n[1].e = pname;
2094 n[2].f = params[0];
2095 n[3].f = params[1];
2096 n[4].f = params[2];
2097 }
2098 if (ctx->ExecuteFlag) {
2099 (*ctx->Exec->PointParameterfvEXT)( pname, params );
2100 }
2101 }
2102
2103
2104 static void save_PointParameterfEXT( GLenum pname, GLfloat param )
2105 {
2106 save_PointParameterfvEXT(pname, &param);
2107 }
2108
2109
2110 static void save_PointSize( GLfloat size )
2111 {
2112 GET_CURRENT_CONTEXT(ctx);
2113 Node *n;
2114 FLUSH_VB(ctx, "dlist");
2115 n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
2116 if (n) {
2117 n[1].f = size;
2118 }
2119 if (ctx->ExecuteFlag) {
2120 (*ctx->Exec->PointSize)( size );
2121 }
2122 }
2123
2124
2125 static void save_PolygonMode( GLenum face, GLenum mode )
2126 {
2127 GET_CURRENT_CONTEXT(ctx);
2128 Node *n;
2129 FLUSH_VB(ctx, "dlist");
2130 n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
2131 if (n) {
2132 n[1].e = face;
2133 n[2].e = mode;
2134 }
2135 if (ctx->ExecuteFlag) {
2136 (*ctx->Exec->PolygonMode)( face, mode );
2137 }
2138 }
2139
2140
2141 /*
2142 * Polygon stipple must have been upacked already!
2143 */
2144 static void save_PolygonStipple( const GLubyte *pattern )
2145 {
2146 GET_CURRENT_CONTEXT(ctx);
2147 Node *n;
2148 FLUSH_VB(ctx, "dlist");
2149 n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
2150 if (n) {
2151 void *data;
2152 n[1].data = MALLOC( 32 * 4 );
2153 data = n[1].data; /* This needed for Acorn compiler */
2154 MEMCPY( data, pattern, 32 * 4 );
2155 }
2156 if (ctx->ExecuteFlag) {
2157 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern );
2158 }
2159 }
2160
2161
2162 static void save_PolygonOffset( GLfloat factor, GLfloat units )
2163 {
2164 GET_CURRENT_CONTEXT(ctx);
2165 Node *n;
2166 FLUSH_VB(ctx, "dlist");
2167 n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
2168 if (n) {
2169 n[1].f = factor;
2170 n[2].f = units;
2171 }
2172 if (ctx->ExecuteFlag) {
2173 (*ctx->Exec->PolygonOffset)( factor, units );
2174 }
2175 }
2176
2177
2178 static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
2179 {
2180 GET_CURRENT_CONTEXT(ctx);
2181 save_PolygonOffset(factor, ctx->Visual->DepthMaxF * bias);
2182 }
2183
2184
2185 static void save_PopAttrib( void )
2186 {
2187 GET_CURRENT_CONTEXT(ctx);
2188 FLUSH_VB(ctx, "dlist");
2189 (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
2190 if (ctx->ExecuteFlag) {
2191 (*ctx->Exec->PopAttrib)();
2192 }
2193 }
2194
2195
2196 static void save_PopMatrix( void )
2197 {
2198 GET_CURRENT_CONTEXT(ctx);
2199 FLUSH_VB(ctx, "dlist");
2200 (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
2201 if (ctx->ExecuteFlag) {
2202 (*ctx->Exec->PopMatrix)();
2203 }
2204 }
2205
2206
2207 static void save_PopName( void )
2208 {
2209 GET_CURRENT_CONTEXT(ctx);
2210 FLUSH_VB(ctx, "dlist");
2211 (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
2212 if (ctx->ExecuteFlag) {
2213 (*ctx->Exec->PopName)();
2214 }
2215 }
2216
2217
2218 static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
2219 const GLclampf *priorities )
2220 {
2221 GET_CURRENT_CONTEXT(ctx);
2222 GLint i;
2223 FLUSH_VB(ctx, "dlist");
2224
2225 for (i=0;i<num;i++) {
2226 Node *n;
2227 n = alloc_instruction( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
2228 if (n) {
2229 n[1].ui = textures[i];
2230 n[2].f = priorities[i];
2231 }
2232 }
2233 if (ctx->ExecuteFlag) {
2234 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities );
2235 }
2236 }
2237
2238
2239 static void save_PushAttrib( GLbitfield mask )
2240 {
2241 GET_CURRENT_CONTEXT(ctx);
2242 Node *n;
2243 FLUSH_VB(ctx, "dlist");
2244 n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
2245 if (n) {
2246 n[1].bf = mask;
2247 }
2248 if (ctx->ExecuteFlag) {
2249 (*ctx->Exec->PushAttrib)( mask );
2250 }
2251 }
2252
2253
2254 static void save_PushMatrix( void )
2255 {
2256 GET_CURRENT_CONTEXT(ctx);
2257 FLUSH_VB(ctx, "dlist");
2258 (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
2259 if (ctx->ExecuteFlag) {
2260 (*ctx->Exec->PushMatrix)();
2261 }
2262 }
2263
2264
2265 static void save_PushName( GLuint name )
2266 {
2267 GET_CURRENT_CONTEXT(ctx);
2268 Node *n;
2269 FLUSH_VB(ctx, "dlist");
2270 n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
2271 if (n) {
2272 n[1].ui = name;
2273 }
2274 if (ctx->ExecuteFlag) {
2275 (*ctx->Exec->PushName)( name );
2276 }
2277 }
2278
2279
2280 static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2281 {
2282 GET_CURRENT_CONTEXT(ctx);
2283 Node *n;
2284 FLUSH_VB(ctx, "dlist");
2285 n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
2286 if (n) {
2287 n[1].f = x;
2288 n[2].f = y;
2289 n[3].f = z;
2290 n[4].f = w;
2291 }
2292 if (ctx->ExecuteFlag) {
2293 (*ctx->Exec->RasterPos4f)( x, y, z, w );
2294 }
2295 }
2296
2297 static void save_RasterPos2d(GLdouble x, GLdouble y)
2298 {
2299 save_RasterPos4f(x, y, 0.0F, 1.0F);
2300 }
2301
2302 static void save_RasterPos2f(GLfloat x, GLfloat y)
2303 {
2304 save_RasterPos4f(x, y, 0.0F, 1.0F);
2305 }
2306
2307 static void save_RasterPos2i(GLint x, GLint y)
2308 {
2309 save_RasterPos4f(x, y, 0.0F, 1.0F);
2310 }
2311
2312 static void save_RasterPos2s(GLshort x, GLshort y)
2313 {
2314 save_RasterPos4f(x, y, 0.0F, 1.0F);
2315 }
2316
2317 static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
2318 {
2319 save_RasterPos4f(x, y, z, 1.0F);
2320 }
2321
2322 static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
2323 {
2324 save_RasterPos4f(x, y, z, 1.0F);
2325 }
2326
2327 static void save_RasterPos3i(GLint x, GLint y, GLint z)
2328 {
2329 save_RasterPos4f(x, y, z, 1.0F);
2330 }
2331
2332 static void save_RasterPos3s(GLshort x, GLshort y, GLshort z)
2333 {
2334 save_RasterPos4f(x, y, z, 1.0F);
2335 }
2336
2337 static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
2338 {
2339 save_RasterPos4f(x, y, z, w);
2340 }
2341
2342 static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
2343 {
2344 save_RasterPos4f(x, y, z, w);
2345 }
2346
2347 static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
2348 {
2349 save_RasterPos4f(x, y, z, w);
2350 }
2351
2352 static void save_RasterPos2dv(const GLdouble *v)
2353 {
2354 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2355 }
2356
2357 static void save_RasterPos2fv(const GLfloat *v)
2358 {
2359 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2360 }
2361
2362 static void save_RasterPos2iv(const GLint *v)
2363 {
2364 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2365 }
2366
2367 static void save_RasterPos2sv(const GLshort *v)
2368 {
2369 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
2370 }
2371
2372 static void save_RasterPos3dv(const GLdouble *v)
2373 {
2374 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2375 }
2376
2377 static void save_RasterPos3fv(const GLfloat *v)
2378 {
2379 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2380 }
2381
2382 static void save_RasterPos3iv(const GLint *v)
2383 {
2384 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2385 }
2386
2387 static void save_RasterPos3sv(const GLshort *v)
2388 {
2389 save_RasterPos4f(v[0], v[1], v[2], 1.0F);
2390 }
2391
2392 static void save_RasterPos4dv(const GLdouble *v)
2393 {
2394 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2395 }
2396
2397 static void save_RasterPos4fv(const GLfloat *v)
2398 {
2399 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2400 }
2401
2402 static void save_RasterPos4iv(const GLint *v)
2403 {
2404 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2405 }
2406
2407 static void save_RasterPos4sv(const GLshort *v)
2408 {
2409 save_RasterPos4f(v[0], v[1], v[2], v[3]);
2410 }
2411
2412
2413 static void save_PassThrough( GLfloat token )
2414 {
2415 GET_CURRENT_CONTEXT(ctx);
2416 Node *n;
2417 FLUSH_VB(ctx, "dlist");
2418 n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
2419 if (n) {
2420 n[1].f = token;
2421 }
2422 if (ctx->ExecuteFlag) {
2423 (*ctx->Exec->PassThrough)( token );
2424 }
2425 }
2426
2427
2428 static void save_ReadBuffer( GLenum mode )
2429 {
2430 GET_CURRENT_CONTEXT(ctx);
2431 Node *n;
2432 FLUSH_VB(ctx, "dlist");
2433 n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
2434 if (n) {
2435 n[1].e = mode;
2436 }
2437 if (ctx->ExecuteFlag) {
2438 (*ctx->Exec->ReadBuffer)( mode );
2439 }
2440 }
2441
2442
2443 static void save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
2444 {
2445 GET_CURRENT_CONTEXT(ctx);
2446 Node *n;
2447 FLUSH_VB(ctx, "dlist");
2448 n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
2449 if (n) {
2450 n[1].f = x1;
2451 n[2].f = y1;
2452 n[3].f = x2;
2453 n[4].f = y2;
2454 }
2455 if (ctx->ExecuteFlag) {
2456 (*ctx->Exec->Rectf)( x1, y1, x2, y2 );
2457 }
2458 }
2459
2460 static void save_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
2461 {
2462 save_Rectf(x1, y1, x2, y2);
2463 }
2464
2465 static void save_Rectdv(const GLdouble *v1, const GLdouble *v2)
2466 {
2467 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2468 }
2469
2470 static void save_Rectfv( const GLfloat *v1, const GLfloat *v2 )
2471 {
2472 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2473 }
2474
2475 static void save_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
2476 {
2477 save_Rectf(x1, y1, x2, y2);
2478 }
2479
2480 static void save_Rectiv(const GLint *v1, const GLint *v2)
2481 {
2482 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2483 }
2484
2485 static void save_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
2486 {
2487 save_Rectf(x1, y1, x2, y2);
2488 }
2489
2490 static void save_Rectsv(const GLshort *v1, const GLshort *v2)
2491 {
2492 save_Rectf(v1[0], v1[1], v2[0], v2[1]);
2493 }
2494
2495
2496 static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
2497 {
2498 GLfloat m[16];
2499 gl_rotation_matrix( angle, x, y, z, m );
2500 save_MultMatrixf( m ); /* save and maybe execute */
2501 }
2502
2503
2504 static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
2505 {
2506 save_Rotatef(angle, x, y, z);
2507 }
2508
2509
2510 static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
2511 {
2512 GET_CURRENT_CONTEXT(ctx);
2513 Node *n;
2514 FLUSH_VB(ctx, "dlist");
2515 n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
2516 if (n) {
2517 n[1].f = x;
2518 n[2].f = y;
2519 n[3].f = z;
2520 }
2521 if (ctx->ExecuteFlag) {
2522 (*ctx->Exec->Scalef)( x, y, z );
2523 }
2524 }
2525
2526
2527 static void save_Scaled( GLdouble x, GLdouble y, GLdouble z )
2528 {
2529 save_Scalef(x, y, z);
2530 }
2531
2532
2533 static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
2534 {
2535 GET_CURRENT_CONTEXT(ctx);
2536 Node *n;
2537 FLUSH_VB(ctx, "dlist");
2538 n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
2539 if (n) {
2540 n[1].i = x;
2541 n[2].i = y;
2542 n[3].i = width;
2543 n[4].i = height;
2544 }
2545 if (ctx->ExecuteFlag) {
2546 (*ctx->Exec->Scissor)( x, y, width, height );
2547 }
2548 }
2549
2550
2551 static void save_ShadeModel( GLenum mode )
2552 {
2553 GET_CURRENT_CONTEXT(ctx);
2554 Node *n;
2555 FLUSH_VB(ctx, "dlist");
2556 n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
2557 if (n) {
2558 n[1].e = mode;
2559 }
2560 if (ctx->ExecuteFlag) {
2561 (*ctx->Exec->ShadeModel)( mode );
2562 }
2563 }
2564
2565
2566 static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
2567 {
2568 GET_CURRENT_CONTEXT(ctx);
2569 Node *n;
2570 FLUSH_VB(ctx, "dlist");
2571 n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
2572 if (n) {
2573 n[1].e = func;
2574 n[2].i = ref;
2575 n[3].ui = mask;
2576 }
2577 if (ctx->ExecuteFlag) {
2578 (*ctx->Exec->StencilFunc)( func, ref, mask );
2579 }
2580 }
2581
2582
2583 static void save_StencilMask( GLuint mask )
2584 {
2585 GET_CURRENT_CONTEXT(ctx);
2586 Node *n;
2587 FLUSH_VB(ctx, "dlist");
2588 n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
2589 if (n) {
2590 n[1].ui = mask;
2591 }
2592 if (ctx->ExecuteFlag) {
2593 (*ctx->Exec->StencilMask)( mask );
2594 }
2595 }
2596
2597
2598 static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
2599 {
2600 GET_CURRENT_CONTEXT(ctx);
2601 Node *n;
2602 FLUSH_VB(ctx, "dlist");
2603 n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
2604 if (n) {
2605 n[1].e = fail;
2606 n[2].e = zfail;
2607 n[3].e = zpass;
2608 }
2609 if (ctx->ExecuteFlag) {
2610 (*ctx->Exec->StencilOp)( fail, zfail, zpass );
2611 }
2612 }
2613
2614
2615 static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
2616 {
2617 GET_CURRENT_CONTEXT(ctx);
2618 Node *n;
2619 FLUSH_VB(ctx, "dlist");
2620 n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
2621 if (n) {
2622 n[1].e = target;
2623 n[2].e = pname;
2624 n[3].f = params[0];
2625 n[4].f = params[1];
2626 n[5].f = params[2];
2627 n[6].f = params[3];
2628 }
2629 if (ctx->ExecuteFlag) {
2630 (*ctx->Exec->TexEnvfv)( target, pname, params );
2631 }
2632 }
2633
2634
2635 static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
2636 {
2637 save_TexEnvfv( target, pname, &param );
2638 }
2639
2640
2641 static void save_TexEnvi( GLenum target, GLenum pname, GLint param )
2642 {
2643 GLfloat p[4];
2644 p[0] = (GLfloat) param;
2645 p[1] = p[2] = p[3] = 0.0;
2646 save_TexEnvfv( target, pname, p );
2647 }
2648
2649
2650 static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
2651 {
2652 GLfloat p[4];
2653 p[0] = INT_TO_FLOAT( param[0] );
2654 p[1] = INT_TO_FLOAT( param[1] );
2655 p[2] = INT_TO_FLOAT( param[2] );
2656 p[3] = INT_TO_FLOAT( param[3] );
2657 save_TexEnvfv( target, pname, p );
2658 }
2659
2660
2661 static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
2662 {
2663 GET_CURRENT_CONTEXT(ctx);
2664 Node *n;
2665 FLUSH_VB(ctx, "dlist");
2666 n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
2667 if (n) {
2668 n[1].e = coord;
2669 n[2].e = pname;
2670 n[3].f = params[0];
2671 n[4].f = params[1];
2672 n[5].f = params[2];
2673 n[6].f = params[3];
2674 }
2675 if (ctx->ExecuteFlag) {
2676 (*ctx->Exec->TexGenfv)( coord, pname, params );
2677 }
2678 }
2679
2680
2681 static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
2682 {
2683 GLfloat p[4];
2684 p[0] = params[0];
2685 p[1] = params[1];
2686 p[2] = params[2];
2687 p[3] = params[3];
2688 save_TexGenfv(coord, pname, p);
2689 }
2690
2691
2692 static void save_TexGend(GLenum coord, GLenum pname, GLdouble param )
2693 {
2694 GLfloat p = (GLfloat) param;
2695 save_TexGenfv( coord, pname, &p );
2696 }
2697
2698
2699 static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
2700 {
2701 GLfloat p[4];
2702 p[0] = params[0];
2703 p[1] = params[1];
2704 p[2] = params[2];
2705 p[3] = params[3];
2706 save_TexGenfv( coord, pname, p );
2707 }
2708
2709
2710 static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
2711 {
2712 save_TexGenfv(coord, pname, &param);
2713 }
2714
2715
2716 static void save_TexGeni( GLenum coord, GLenum pname, GLint param )
2717 {
2718 save_TexGeniv( coord, pname, &param );
2719 }
2720
2721
2722 static void save_TexParameterfv( GLenum target,
2723 GLenum pname, const GLfloat *params )
2724 {
2725 GET_CURRENT_CONTEXT(ctx);
2726 Node *n;
2727 FLUSH_VB(ctx, "dlist");
2728 n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
2729 if (n) {
2730 n[1].e = target;
2731 n[2].e = pname;
2732 n[3].f = params[0];
2733 n[4].f = params[1];
2734 n[5].f = params[2];
2735 n[6].f = params[3];
2736 }
2737 if (ctx->ExecuteFlag) {
2738 (*ctx->Exec->TexParameterfv)( target, pname, params );
2739 }
2740 }
2741
2742
2743 static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
2744 {
2745 save_TexParameterfv(target, pname, &param);
2746 }
2747
2748
2749 static void save_TexParameteri( GLenum target, GLenum pname, const GLint param )
2750 {
2751 GLfloat fparam[4];
2752 fparam[0] = (GLfloat) param;
2753 fparam[1] = fparam[2] = fparam[3] = 0.0;
2754 save_TexParameterfv(target, pname, fparam);
2755 }
2756
2757
2758 static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
2759 {
2760 GLfloat fparam[4];
2761 fparam[0] = (GLfloat) params[0];
2762 fparam[1] = fparam[2] = fparam[3] = 0.0;
2763 save_TexParameterfv(target, pname, fparam);
2764 }
2765
2766
2767 static void save_TexImage1D( GLenum target,
2768 GLint level, GLint components,
2769 GLsizei width, GLint border,
2770 GLenum format, GLenum type,
2771 const GLvoid *pixels )
2772 {
2773 GET_CURRENT_CONTEXT(ctx);
2774 if (target == GL_PROXY_TEXTURE_1D) {
2775 /* don't compile, execute immediately */
2776 (*ctx->Exec->TexImage1D)( target, level, components, width,
2777 border, format, type, pixels );
2778 }
2779 else {
2780 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
2781 pixels, &ctx->Unpack);
2782 Node *n;
2783 FLUSH_VB(ctx, "dlist");
2784 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
2785 if (n) {
2786 n[1].e = target;
2787 n[2].i = level;
2788 n[3].i = components;
2789 n[4].i = (GLint) width;
2790 n[5].i = border;
2791 n[6].e = format;
2792 n[7].e = type;
2793 n[8].data = image;
2794 }
2795 else if (image) {
2796 FREE(image);
2797 }
2798 if (ctx->ExecuteFlag) {
2799 (*ctx->Exec->TexImage1D)( target, level, components, width,
2800 border, format, type, pixels );
2801 }
2802 }
2803 }
2804
2805
2806 static void save_TexImage2D( GLenum target,
2807 GLint level, GLint components,
2808 GLsizei width, GLsizei height, GLint border,
2809 GLenum format, GLenum type,
2810 const GLvoid *pixels)
2811 {
2812 GET_CURRENT_CONTEXT(ctx);
2813 if (target == GL_PROXY_TEXTURE_2D) {
2814 /* don't compile, execute immediately */
2815 (*ctx->Exec->TexImage2D)( target, level, components, width,
2816 height, border, format, type, pixels );
2817 }
2818 else {
2819 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
2820 pixels, &ctx->Unpack);
2821 Node *n;
2822 FLUSH_VB(ctx, "dlist");
2823 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
2824 if (n) {
2825 n[1].e = target;
2826 n[2].i = level;
2827 n[3].i = components;
2828 n[4].i = (GLint) width;
2829 n[5].i = (GLint) height;
2830 n[6].i = border;
2831 n[7].e = format;
2832 n[8].e = type;
2833 n[9].data = image;
2834 }
2835 else if (image) {
2836 FREE(image);
2837 }
2838 if (ctx->ExecuteFlag) {
2839 (*ctx->Exec->TexImage2D)( target, level, components, width,
2840 height, border, format, type, pixels );
2841 }
2842 }
2843 }
2844
2845
2846 static void save_TexImage3D( GLenum target,
2847 GLint level, GLint components,
2848 GLsizei width, GLsizei height, GLsizei depth,
2849 GLint border,
2850 GLenum format, GLenum type,
2851 const GLvoid *pixels )
2852 {
2853 GET_CURRENT_CONTEXT(ctx);
2854 if (target == GL_PROXY_TEXTURE_3D) {
2855 /* don't compile, execute immediately */
2856 (*ctx->Exec->TexImage3D)( target, level, components, width,
2857 height, depth, border, format, type, pixels );
2858 }
2859 else {
2860 Node *n;
2861 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
2862 pixels, &ctx->Unpack);
2863 FLUSH_VB(ctx, "dlist");
2864 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
2865 if (n) {
2866 n[1].e = target;
2867 n[2].i = level;
2868 n[3].i = components;
2869 n[4].i = (GLint) width;
2870 n[5].i = (GLint) height;
2871 n[6].i = (GLint) depth;
2872 n[7].i = border;
2873 n[8].e = format;
2874 n[9].e = type;
2875 n[10].data = image;
2876 }
2877 else if (image) {
2878 FREE(image);
2879 }
2880 if (ctx->ExecuteFlag) {
2881 (*ctx->Exec->TexImage3D)( target, level, components, width,
2882 height, depth, border, format, type, pixels );
2883 }
2884 }
2885 }
2886
2887
2888 static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
2889 GLsizei width, GLenum format, GLenum type,
2890 const GLvoid *pixels )
2891 {
2892 GET_CURRENT_CONTEXT(ctx);
2893 Node *n;
2894 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
2895 pixels, &ctx->Unpack);
2896 FLUSH_VB(ctx, "dlist");
2897 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
2898 if (n) {
2899 n[1].e = target;
2900 n[2].i = level;
2901 n[3].i = xoffset;
2902 n[4].i = (GLint) width;
2903 n[5].e = format;
2904 n[6].e = type;
2905 n[7].data = image;
2906 }
2907 else if (image) {
2908 FREE(image);
2909 }
2910 if (ctx->ExecuteFlag) {
2911 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width,
2912 format, type, pixels );
2913 }
2914 }
2915
2916
2917 static void save_TexSubImage2D( GLenum target, GLint level,
2918 GLint xoffset, GLint yoffset,
2919 GLsizei width, GLsizei height,
2920 GLenum format, GLenum type,
2921 const GLvoid *pixels )
2922 {
2923 GET_CURRENT_CONTEXT(ctx);
2924 Node *n;
2925 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
2926 pixels, &ctx->Unpack);
2927 FLUSH_VB(ctx, "dlist");
2928 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
2929 if (n) {
2930 n[1].e = target;
2931 n[2].i = level;
2932 n[3].i = xoffset;
2933 n[4].i = yoffset;
2934 n[5].i = (GLint) width;
2935 n[6].i = (GLint) height;
2936 n[7].e = format;
2937 n[8].e = type;
2938 n[9].data = image;
2939 }
2940 else if (image) {
2941 FREE(image);
2942 }
2943 if (ctx->ExecuteFlag) {
2944 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset,
2945 width, height, format, type, pixels );
2946 }
2947 }
2948
2949
2950 static void save_TexSubImage3D( GLenum target, GLint level,
2951 GLint xoffset, GLint yoffset,GLint zoffset,
2952 GLsizei width, GLsizei height, GLsizei depth,
2953 GLenum format, GLenum type,
2954 const GLvoid *pixels )
2955 {
2956 GET_CURRENT_CONTEXT(ctx);
2957 Node *n;
2958 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
2959 pixels, &ctx->Unpack);
2960 FLUSH_VB(ctx, "dlist");
2961 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
2962 if (n) {
2963 n[1].e = target;
2964 n[2].i = level;
2965 n[3].i = xoffset;
2966 n[4].i = yoffset;
2967 n[5].i = zoffset;
2968 n[6].i = (GLint) width;
2969 n[7].i = (GLint) height;
2970 n[8].i = (GLint) depth;
2971 n[9].e = format;
2972 n[10].e = type;
2973 n[11].data = image;
2974 }
2975 else if (image) {
2976 FREE(image);
2977 }
2978 if (ctx->ExecuteFlag) {
2979 (*ctx->Exec->TexSubImage3D)( target, level,
2980 xoffset, yoffset, zoffset,
2981 width, height, depth, format, type, pixels );
2982 }
2983 }
2984
2985
2986 static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
2987 {
2988 GET_CURRENT_CONTEXT(ctx);
2989 Node *n;
2990 FLUSH_VB(ctx, "dlist");
2991 n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 );
2992 if (n) {
2993 n[1].f = x;
2994 n[2].f = y;
2995 n[3].f = z;
2996 }
2997 if (ctx->ExecuteFlag) {
2998 (*ctx->Exec->Translatef)( x, y, z );
2999 }
3000 }
3001
3002
3003 static void save_Translated( GLdouble x, GLdouble y, GLdouble z )
3004 {
3005 save_Translatef(x, y, z);
3006 }
3007
3008
3009
3010 static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
3011 {
3012 GET_CURRENT_CONTEXT(ctx);
3013 Node *n;
3014 FLUSH_VB(ctx, "dlist");
3015 n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 );
3016 if (n) {
3017 n[1].i = x;
3018 n[2].i = y;
3019 n[3].i = (GLint) width;
3020 n[4].i = (GLint) height;
3021 }
3022 if (ctx->ExecuteFlag) {
3023 (*ctx->Exec->Viewport)( x, y, width, height );
3024 }
3025 }
3026
3027
3028 static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
3029 {
3030 GET_CURRENT_CONTEXT(ctx);
3031 Node *n;
3032 FLUSH_VB(ctx, "dlist");
3033 n = alloc_instruction( ctx, OPCODE_WINDOW_POS, 4 );
3034 if (n) {
3035 n[1].f = x;
3036 n[2].f = y;
3037 n[3].f = z;
3038 n[4].f = w;
3039 }
3040 if (ctx->ExecuteFlag) {
3041 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w );
3042 }
3043 }
3044
3045 static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
3046 {
3047 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3048 }
3049
3050 static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
3051 {
3052 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3053 }
3054
3055 static void save_WindowPos2iMESA(GLint x, GLint y)
3056 {
3057 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3058 }
3059
3060 static void save_WindowPos2sMESA(GLshort x, GLshort y)
3061 {
3062 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3063 }
3064
3065 static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3066 {
3067 save_WindowPos4fMESA(x, y, z, 1.0F);
3068 }
3069
3070 static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3071 {
3072 save_WindowPos4fMESA(x, y, z, 1.0F);
3073 }
3074
3075 static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3076 {
3077 save_WindowPos4fMESA(x, y, z, 1.0F);
3078 }
3079
3080 static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3081 {
3082 save_WindowPos4fMESA(x, y, z, 1.0F);
3083 }
3084
3085 static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3086 {
3087 save_WindowPos4fMESA(x, y, z, w);
3088 }
3089
3090 static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3091 {
3092 save_WindowPos4fMESA(x, y, z, w);
3093 }
3094
3095 static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3096 {
3097 save_WindowPos4fMESA(x, y, z, w);
3098 }
3099
3100 static void save_WindowPos2dvMESA(const GLdouble *v)
3101 {
3102 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3103 }
3104
3105 static void save_WindowPos2fvMESA(const GLfloat *v)
3106 {
3107 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3108 }
3109
3110 static void save_WindowPos2ivMESA(const GLint *v)
3111 {
3112 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3113 }
3114
3115 static void save_WindowPos2svMESA(const GLshort *v)
3116 {
3117 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3118 }
3119
3120 static void save_WindowPos3dvMESA(const GLdouble *v)
3121 {
3122 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3123 }
3124
3125 static void save_WindowPos3fvMESA(const GLfloat *v)
3126 {
3127 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3128 }
3129
3130 static void save_WindowPos3ivMESA(const GLint *v)
3131 {
3132 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3133 }
3134
3135 static void save_WindowPos3svMESA(const GLshort *v)
3136 {
3137 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3138 }
3139
3140 static void save_WindowPos4dvMESA(const GLdouble *v)
3141 {
3142 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3143 }
3144
3145 static void save_WindowPos4fvMESA(const GLfloat *v)
3146 {
3147 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3148 }
3149
3150 static void save_WindowPos4ivMESA(const GLint *v)
3151 {
3152 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3153 }
3154
3155 static void save_WindowPos4svMESA(const GLshort *v)
3156 {
3157 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3158 }
3159
3160
3161
3162 /* GL_ARB_multitexture */
3163 static void save_ActiveTextureARB( GLenum target )
3164 {
3165 GET_CURRENT_CONTEXT(ctx);
3166 Node *n;
3167 FLUSH_VB(ctx, "dlist");
3168 n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3169 if (n) {
3170 n[1].e = target;
3171 }
3172 if (ctx->ExecuteFlag) {
3173 (*ctx->Exec->ActiveTextureARB)( target );
3174 }
3175 }
3176
3177
3178 /* GL_ARB_multitexture */
3179 static void save_ClientActiveTextureARB( GLenum target )
3180 {
3181 GET_CURRENT_CONTEXT(ctx);
3182 Node *n;
3183 FLUSH_VB(ctx, "dlist");
3184 n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
3185 if (n) {
3186 n[1].e = target;
3187 }
3188 if (ctx->ExecuteFlag) {
3189 (*ctx->Exec->ClientActiveTextureARB)( target );
3190 }
3191 }
3192
3193
3194
3195 static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3196 {
3197 GLdouble tm[16];
3198 gl_matrix_transposed(tm, m);
3199 save_LoadMatrixd(tm);
3200 }
3201
3202
3203 static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3204 {
3205 GLfloat tm[16];
3206 gl_matrix_transposef(tm, m);
3207 save_LoadMatrixf(tm);
3208 }
3209
3210
3211 static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
3212 {
3213 GLdouble tm[16];
3214 gl_matrix_transposed(tm, m);
3215 save_MultMatrixd(tm);
3216 }
3217
3218
3219 static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
3220 {
3221 GLfloat tm[16];
3222 gl_matrix_transposef(tm, m);
3223 save_MultMatrixf(tm);
3224 }
3225
3226
3227
3228 void gl_compile_cassette( GLcontext *ctx )
3229 {
3230 Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 8 );
3231 struct immediate *im = ctx->input;
3232
3233 if (!n)
3234 return;
3235
3236
3237 /* Do some easy optimizations of the cassette.
3238 */
3239 #if 0
3240 if (0 && im->v.Obj.size < 4 && im->Count > 15) {
3241 im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat));
3242 (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj );
3243 }
3244 #endif
3245
3246 n[1].data = (void *)im;
3247 n[2].ui = im->Start;
3248 n[3].ui = im->Count;
3249 n[4].ui = im->BeginState;
3250 n[5].ui = im->OrFlag;
3251 n[6].ui = im->AndFlag;
3252 n[7].ui = im->LastData;
3253 n[8].ui = im->LastPrimitive;
3254
3255 if (im->Count > VB_MAX - 4) {
3256
3257 struct immediate *new_im = gl_immediate_alloc(ctx);
3258 if (!new_im) return;
3259 SET_IMMEDIATE( ctx, new_im );
3260 gl_reset_input( ctx );
3261
3262 } else {
3263 im->Count++;;
3264 im->Start = im->Count; /* don't clear anything in reset_input */
3265 im->ref_count++;
3266
3267 im->Primitive[im->Start] = ctx->Current.Primitive;
3268 im->LastPrimitive = im->Start;
3269 im->BeginState = VERT_BEGIN_0;
3270 im->OrFlag = 0;
3271 im->AndFlag = ~0;
3272
3273 if (0)
3274 fprintf(stderr, "in compile_cassette, BeginState is %x\n",
3275 im->BeginState);
3276 }
3277 }
3278
3279 /* KW: Compile commands
3280 *
3281 * Will appear in the list before the vertex buffer containing the
3282 * command that provoked the error. I don't see this as a problem.
3283 */
3284 void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
3285 {
3286 Node *n;
3287 n = alloc_instruction( ctx, OPCODE_ERROR, 2 );
3288 if (n) {
3289 n[1].e = error;
3290 n[2].data = (void *) s;
3291 }
3292 /* execute already done */
3293 }
3294
3295
3296 static GLboolean
3297 islist(GLcontext *ctx, GLuint list)
3298 {
3299 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
3300 return GL_TRUE;
3301 }
3302 else {
3303 return GL_FALSE;
3304 }
3305 }
3306
3307
3308
3309 /**********************************************************************/
3310 /* Display list execution */
3311 /**********************************************************************/
3312
3313
3314 /*
3315 * Execute a display list. Note that the ListBase offset must have already
3316 * been added before calling this function. I.e. the list argument is
3317 * the absolute list number, not relative to ListBase.
3318 * Input: list - display list number
3319 */
3320 static void execute_list( GLcontext *ctx, GLuint list )
3321 {
3322 Node *n;
3323 GLboolean done;
3324 OpCode opcode;
3325
3326 if (!islist(ctx,list))
3327 return;
3328
3329 /* mesa_print_display_list( list ); */
3330
3331 ctx->CallDepth++;
3332
3333 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
3334
3335 done = GL_FALSE;
3336 while (!done) {
3337 opcode = n[0].opcode;
3338
3339 switch (opcode) {
3340 case OPCODE_ERROR:
3341 gl_error( ctx, n[1].e, (const char *) n[2].data );
3342 break;
3343 case OPCODE_VERTEX_CASSETTE: {
3344 struct immediate *IM;
3345
3346 if (ctx->NewState)
3347 gl_update_state(ctx);
3348 if (ctx->CompileCVAFlag) {
3349 ctx->CompileCVAFlag = 0;
3350 ctx->CVA.elt.pipeline_valid = 0;
3351 }
3352 if (!ctx->CVA.elt.pipeline_valid)
3353 gl_build_immediate_pipeline( ctx );
3354
3355
3356 IM = (struct immediate *) n[1].data;
3357 IM->Start = n[2].ui;
3358 IM->Count = n[3].ui;
3359 IM->BeginState = n[4].ui;
3360 IM->OrFlag = n[5].ui;
3361 IM->AndFlag = n[6].ui;
3362 IM->LastData = n[7].ui;
3363 IM->LastPrimitive = n[8].ui;
3364
3365 if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
3366 (MESA_VERBOSE & VERBOSE_IMMEDIATE))
3367 gl_print_cassette( (struct immediate *) n[1].data );
3368
3369 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) {
3370 fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ",
3371 IM->id,
3372 IM->Start, IM->Count, IM->BeginState);
3373 gl_print_vert_flags("orflag", IM->OrFlag);
3374 }
3375
3376 gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
3377 gl_execute_cassette( ctx, (struct immediate *) n[1].data );
3378 break;
3379 }
3380 case OPCODE_ACCUM:
3381 (*ctx->Exec->Accum)( n[1].e, n[2].f );
3382 break;
3383 case OPCODE_ALPHA_FUNC:
3384 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f );
3385 break;
3386 case OPCODE_BIND_TEXTURE:
3387 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui );
3388 break;
3389 case OPCODE_BITMAP:
3390 {
3391 struct gl_pixelstore_attrib save = ctx->Unpack;
3392 ctx->Unpack = _mesa_native_packing;
3393 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
3394 n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
3395 ctx->Unpack = save; /* restore */
3396 }
3397 break;
3398 case OPCODE_BLEND_COLOR:
3399 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f );
3400 break;
3401 case OPCODE_BLEND_EQUATION:
3402 (*ctx->Exec->BlendEquation)( n[1].e );
3403 break;
3404 case OPCODE_BLEND_FUNC:
3405 (*ctx->Exec->BlendFunc)( n[1].e, n[2].e );
3406 break;
3407 case OPCODE_BLEND_FUNC_SEPARATE:
3408 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e);
3409 break;
3410 case OPCODE_CALL_LIST:
3411 /* Generated by glCallList(), don't add ListBase */
3412 if (ctx->CallDepth<MAX_LIST_NESTING) {
3413 execute_list( ctx, n[1].ui );
3414 }
3415 break;
3416 case OPCODE_CALL_LIST_OFFSET:
3417 /* Generated by glCallLists() so we must add ListBase */
3418 if (ctx->CallDepth<MAX_LIST_NESTING) {
3419 execute_list( ctx, ctx->List.ListBase + n[1].ui );
3420 }
3421 break;
3422 case OPCODE_CLEAR:
3423 (*ctx->Exec->Clear)( n[1].bf );
3424 break;
3425 case OPCODE_CLEAR_COLOR:
3426 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
3427 break;
3428 case OPCODE_CLEAR_ACCUM:
3429 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
3430 break;
3431 case OPCODE_CLEAR_DEPTH:
3432 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f );
3433 break;
3434 case OPCODE_CLEAR_INDEX:
3435 (*ctx->Exec->ClearIndex)( n[1].ui );
3436 break;
3437 case OPCODE_CLEAR_STENCIL:
3438 (*ctx->Exec->ClearStencil)( n[1].i );
3439 break;
3440 case OPCODE_CLIP_PLANE:
3441 {
3442 GLdouble eq[4];
3443 eq[0] = n[2].f;
3444 eq[1] = n[3].f;
3445 eq[2] = n[4].f;
3446 eq[3] = n[5].f;
3447 (*ctx->Exec->ClipPlane)( n[1].e, eq );
3448 }
3449 break;
3450 case OPCODE_COLOR_MASK:
3451 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
3452 break;
3453 case OPCODE_COLOR_MATERIAL:
3454 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e );
3455 break;
3456 case OPCODE_COLOR_TABLE:
3457 {
3458 struct gl_pixelstore_attrib save = ctx->Unpack;
3459 ctx->Unpack = _mesa_native_packing;
3460 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e,
3461 n[5].e, n[6].data );
3462 ctx->Unpack = save; /* restore */
3463 }
3464 break;
3465 case OPCODE_COLOR_SUB_TABLE:
3466 {
3467 struct gl_pixelstore_attrib save = ctx->Unpack;
3468 ctx->Unpack = _mesa_native_packing;
3469 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i,
3470 n[4].e, n[5].e, n[6].data );
3471 ctx->Unpack = save; /* restore */
3472 }
3473 break;
3474 case OPCODE_COPY_PIXELS:
3475 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i,
3476 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
3477 break;
3478 case OPCODE_COPY_TEX_IMAGE1D:
3479 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
3480 n[5].i, n[6].i, n[7].i );
3481 break;
3482 case OPCODE_COPY_TEX_IMAGE2D:
3483 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
3484 n[5].i, n[6].i, n[7].i, n[8].i );
3485 break;
3486 case OPCODE_COPY_TEX_SUB_IMAGE1D:
3487 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
3488 n[4].i, n[5].i, n[6].i );
3489 break;
3490 case OPCODE_COPY_TEX_SUB_IMAGE2D:
3491 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
3492 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
3493 break;
3494 case OPCODE_COPY_TEX_SUB_IMAGE3D:
3495 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
3496 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
3497 break;
3498 case OPCODE_CULL_FACE:
3499 (*ctx->Exec->CullFace)( n[1].e );
3500 break;
3501 case OPCODE_DEPTH_FUNC:
3502 (*ctx->Exec->DepthFunc)( n[1].e );
3503 break;
3504 case OPCODE_DEPTH_MASK:
3505 (*ctx->Exec->DepthMask)( n[1].b );
3506 break;
3507 case OPCODE_DEPTH_RANGE:
3508 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
3509 break;
3510 case OPCODE_DISABLE:
3511 (*ctx->Exec->Disable)( n[1].e );
3512 break;
3513 case OPCODE_DRAW_BUFFER:
3514 (*ctx->Exec->DrawBuffer)( n[1].e );
3515 break;
3516 case OPCODE_DRAW_PIXELS:
3517 {
3518 struct gl_pixelstore_attrib save = ctx->Unpack;
3519 ctx->Unpack = _mesa_native_packing;
3520 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
3521 n[5].data );
3522 ctx->Unpack = save; /* restore */
3523 }
3524 break;
3525 case OPCODE_ENABLE:
3526 (*ctx->Exec->Enable)( n[1].e );
3527 break;
3528 case OPCODE_EVALMESH1:
3529 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i );
3530 break;
3531 case OPCODE_EVALMESH2:
3532 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
3533 break;
3534 case OPCODE_FOG:
3535 {
3536 GLfloat p[4];
3537 p[0] = n[2].f;
3538 p[1] = n[3].f;
3539 p[2] = n[4].f;
3540 p[3] = n[5].f;
3541 (*ctx->Exec->Fogfv)( n[1].e, p );
3542 }
3543 break;
3544 case OPCODE_FRONT_FACE:
3545 (*ctx->Exec->FrontFace)( n[1].e );
3546 break;
3547 case OPCODE_FRUSTUM:
3548 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
3549 break;
3550 case OPCODE_HINT:
3551 (*ctx->Exec->Hint)( n[1].e, n[2].e );
3552 break;
3553 case OPCODE_HINT_PGI:
3554 (*ctx->Exec->HintPGI)( n[1].e, n[2].i );
3555 break;
3556 case OPCODE_INDEX_MASK:
3557 (*ctx->Exec->IndexMask)( n[1].ui );
3558 break;
3559 case OPCODE_INIT_NAMES:
3560 (*ctx->Exec->InitNames)();
3561 break;
3562 case OPCODE_LIGHT:
3563 {
3564 GLfloat p[4];
3565 p[0] = n[3].f;
3566 p[1] = n[4].f;
3567 p[2] = n[5].f;
3568 p[3] = n[6].f;
3569 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p );
3570 }
3571 break;
3572 case OPCODE_LIGHT_MODEL:
3573 {
3574 GLfloat p[4];
3575 p[0] = n[2].f;
3576 p[1] = n[3].f;
3577 p[2] = n[4].f;
3578 p[3] = n[5].f;
3579 (*ctx->Exec->LightModelfv)( n[1].e, p );
3580 }
3581 break;
3582 case OPCODE_LINE_STIPPLE:
3583 (*ctx->Exec->LineStipple)( n[1].i, n[2].us );
3584 break;
3585 case OPCODE_LINE_WIDTH:
3586 (*ctx->Exec->LineWidth)( n[1].f );
3587 break;
3588 case OPCODE_LIST_BASE:
3589 (*ctx->Exec->ListBase)( n[1].ui );
3590 break;
3591 case OPCODE_LOAD_IDENTITY:
3592 (*ctx->Exec->LoadIdentity)();
3593 break;
3594 case OPCODE_LOAD_MATRIX:
3595 if (sizeof(Node)==sizeof(GLfloat)) {
3596 (*ctx->Exec->LoadMatrixf)( &n[1].f );
3597 }
3598 else {
3599 GLfloat m[16];
3600 GLuint i;
3601 for (i=0;i<16;i++) {
3602 m[i] = n[1+i].f;
3603 }
3604 (*ctx->Exec->LoadMatrixf)( m );
3605 }
3606 break;
3607 case OPCODE_LOAD_NAME:
3608 (*ctx->Exec->LoadName)( n[1].ui );
3609 break;
3610 case OPCODE_LOGIC_OP:
3611 (*ctx->Exec->LogicOp)( n[1].e );
3612 break;
3613 case OPCODE_MAP1:
3614 {
3615 GLenum target = n[1].e;
3616 GLint ustride = _mesa_evaluator_components(target);
3617 GLint uorder = n[5].i;
3618 GLfloat u1 = n[2].f;
3619 GLfloat u2 = n[3].f;
3620 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder,
3621 (GLfloat *) n[6].data );
3622 }
3623 break;
3624 case OPCODE_MAP2:
3625 {
3626 GLenum target = n[1].e;
3627 GLfloat u1 = n[2].f;
3628 GLfloat u2 = n[3].f;
3629 GLfloat v1 = n[4].f;
3630 GLfloat v2 = n[5].f;
3631 GLint ustride = n[6].i;
3632 GLint vstride = n[7].i;
3633 GLint uorder = n[8].i;
3634 GLint vorder = n[9].i;
3635 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder,
3636 v1, v2, vstride, vorder,
3637 (GLfloat *) n[10].data );
3638 }
3639 break;
3640 case OPCODE_MAPGRID1:
3641 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f );
3642 break;
3643 case OPCODE_MAPGRID2:
3644 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
3645 break;
3646 case OPCODE_MATRIX_MODE:
3647 (*ctx->Exec->MatrixMode)( n[1].e );
3648 break;
3649 case OPCODE_MULT_MATRIX:
3650 if (sizeof(Node)==sizeof(GLfloat)) {
3651 (*ctx->Exec->MultMatrixf)( &n[1].f );
3652 }
3653 else {
3654 GLfloat m[16];
3655 GLuint i;
3656 for (i=0;i<16;i++) {
3657 m[i] = n[1+i].f;
3658 }
3659 (*ctx->Exec->MultMatrixf)( m );
3660 }
3661 break;
3662 case OPCODE_ORTHO:
3663 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
3664 break;
3665 case OPCODE_PASSTHROUGH:
3666 (*ctx->Exec->PassThrough)( n[1].f );
3667 break;
3668 case OPCODE_PIXEL_MAP:
3669 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
3670 break;
3671 case OPCODE_PIXEL_TRANSFER:
3672 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f );
3673 break;
3674 case OPCODE_PIXEL_ZOOM:
3675 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f );
3676 break;
3677 case OPCODE_POINT_SIZE:
3678 (*ctx->Exec->PointSize)( n[1].f );
3679 break;
3680 case OPCODE_POINT_PARAMETERS:
3681 {
3682 GLfloat params[3];
3683 params[0] = n[2].f;
3684 params[1] = n[3].f;
3685 params[2] = n[4].f;
3686 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params );
3687 }
3688 break;
3689 case OPCODE_POLYGON_MODE:
3690 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e );
3691 break;
3692 case OPCODE_POLYGON_STIPPLE:
3693 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data );
3694 break;
3695 case OPCODE_POLYGON_OFFSET:
3696 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f );
3697 break;
3698 case OPCODE_POP_ATTRIB:
3699 (*ctx->Exec->PopAttrib)();
3700 break;
3701 case OPCODE_POP_MATRIX:
3702 (*ctx->Exec->PopMatrix)();
3703 break;
3704 case OPCODE_POP_NAME:
3705 (*ctx->Exec->PopName)();
3706 break;
3707 case OPCODE_PRIORITIZE_TEXTURE:
3708 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
3709 break;
3710 case OPCODE_PUSH_ATTRIB:
3711 (*ctx->Exec->PushAttrib)( n[1].bf );
3712 break;
3713 case OPCODE_PUSH_MATRIX:
3714 (*ctx->Exec->PushMatrix)();
3715 break;
3716 case OPCODE_PUSH_NAME:
3717 (*ctx->Exec->PushName)( n[1].ui );
3718 break;
3719 case OPCODE_RASTER_POS:
3720 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
3721 break;
3722 case OPCODE_READ_BUFFER:
3723 (*ctx->Exec->ReadBuffer)( n[1].e );
3724 break;
3725 case OPCODE_RECTF:
3726 (*ctx->Exec->Rectf)( n[1].f, n[2].f, n[3].f, n[4].f );
3727 break;
3728 case OPCODE_SCALE:
3729 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
3730 break;
3731 case OPCODE_SCISSOR:
3732 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
3733 break;
3734 case OPCODE_SHADE_MODEL:
3735 (*ctx->Exec->ShadeModel)( n[1].e );
3736 break;
3737 case OPCODE_STENCIL_FUNC:
3738 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui );
3739 break;
3740 case OPCODE_STENCIL_MASK:
3741 (*ctx->Exec->StencilMask)( n[1].ui );
3742 break;
3743 case OPCODE_STENCIL_OP:
3744 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e );
3745 break;
3746 case OPCODE_TEXENV:
3747 {
3748 GLfloat params[4];
3749 params[0] = n[3].f;
3750 params[1] = n[4].f;
3751 params[2] = n[5].f;
3752 params[3] = n[6].f;
3753 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params );
3754 }
3755 break;
3756 case OPCODE_TEXGEN:
3757 {
3758 GLfloat params[4];
3759 params[0] = n[3].f;
3760 params[1] = n[4].f;
3761 params[2] = n[5].f;
3762 params[3] = n[6].f;
3763 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params );
3764 }
3765 break;
3766 case OPCODE_TEXPARAMETER:
3767 {
3768 GLfloat params[4];
3769 params[0] = n[3].f;
3770 params[1] = n[4].f;
3771 params[2] = n[5].f;
3772 params[3] = n[6].f;
3773 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params );
3774 }
3775 break;
3776 case OPCODE_TEX_IMAGE1D:
3777 {
3778 struct gl_pixelstore_attrib save = ctx->Unpack;
3779 ctx->Unpack = _mesa_native_packing;
3780 (*ctx->Exec->TexImage1D)(
3781 n[1].e, /* target */
3782 n[2].i, /* level */
3783 n[3].i, /* components */
3784 n[4].i, /* width */
3785 n[5].e, /* border */
3786 n[6].e, /* format */
3787 n[7].e, /* type */
3788 n[8].data );
3789 ctx->Unpack = save; /* restore */
3790 }
3791 break;
3792 case OPCODE_TEX_IMAGE2D:
3793 {
3794 struct gl_pixelstore_attrib save = ctx->Unpack;
3795 ctx->Unpack = _mesa_native_packing;
3796 (*ctx->Exec->TexImage2D)(
3797 n[1].e, /* target */
3798 n[2].i, /* level */
3799 n[3].i, /* components */
3800 n[4].i, /* width */
3801 n[5].i, /* height */
3802 n[6].e, /* border */
3803 n[7].e, /* format */
3804 n[8].e, /* type */
3805 n[9].data );
3806 ctx->Unpack = save; /* restore */
3807 }
3808 break;
3809 case OPCODE_TEX_IMAGE3D:
3810 {
3811 struct gl_pixelstore_attrib save = ctx->Unpack;
3812 ctx->Unpack = _mesa_native_packing;
3813 (*ctx->Exec->TexImage3D)(
3814 n[1].e, /* target */
3815 n[2].i, /* level */
3816 n[3].i, /* components */
3817 n[4].i, /* width */
3818 n[5].i, /* height */
3819 n[6].i, /* depth */
3820 n[7].e, /* border */
3821 n[8].e, /* format */
3822 n[9].e, /* type */
3823 n[10].data );
3824 ctx->Unpack = save; /* restore */
3825 }
3826 break;
3827 case OPCODE_TEX_SUB_IMAGE1D:
3828 {
3829 struct gl_pixelstore_attrib save = ctx->Unpack;
3830 ctx->Unpack = _mesa_native_packing;
3831 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i,
3832 n[4].i, n[5].e,
3833 n[6].e, n[7].data );
3834 ctx->Unpack = save; /* restore */
3835 }
3836 break;
3837 case OPCODE_TEX_SUB_IMAGE2D:
3838 {
3839 struct gl_pixelstore_attrib save = ctx->Unpack;
3840 ctx->Unpack = _mesa_native_packing;
3841 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i,
3842 n[4].i, n[5].e,
3843 n[6].i, n[7].e, n[8].e, n[9].data );
3844 ctx->Unpack = save; /* restore */
3845 }
3846 break;
3847 case OPCODE_TEX_SUB_IMAGE3D:
3848 {
3849 struct gl_pixelstore_attrib save = ctx->Unpack;
3850 ctx->Unpack = _mesa_native_packing;
3851 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i,
3852 n[4].i, n[5].i, n[6].i, n[7].i,
3853 n[8].i, n[9].e, n[10].e,
3854 n[11].data );
3855 ctx->Unpack = save; /* restore */
3856 }
3857 break;
3858 case OPCODE_TRANSLATE:
3859 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f );
3860 break;
3861 case OPCODE_VIEWPORT:
3862 (*ctx->Exec->Viewport)(n[1].i, n[2].i,
3863 (GLsizei) n[3].i, (GLsizei) n[4].i);
3864 break;
3865 case OPCODE_WINDOW_POS:
3866 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
3867 break;
3868 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
3869 (*ctx->Exec->ActiveTextureARB)( n[1].e );
3870 break;
3871 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
3872 (*ctx->Exec->ClientActiveTextureARB)( n[1].e );
3873 break;
3874 case OPCODE_CONTINUE:
3875 n = (Node *) n[1].next;
3876 break;
3877 case OPCODE_END_OF_LIST:
3878 done = GL_TRUE;
3879 break;
3880 default:
3881 {
3882 char msg[1000];
3883 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
3884 gl_problem( ctx, msg );
3885 }
3886 done = GL_TRUE;
3887 }
3888
3889 /* increment n to point to next compiled command */
3890 if (opcode!=OPCODE_CONTINUE) {
3891 n += InstSize[opcode];
3892 }
3893
3894 }
3895 ctx->CallDepth--;
3896 }
3897
3898
3899
3900
3901
3902 /**********************************************************************/
3903 /* GL functions */
3904 /**********************************************************************/
3905
3906
3907
3908
3909 /*
3910 * Test if a display list number is valid.
3911 */
3912 GLboolean
3913 _mesa_IsList( GLuint list )
3914 {
3915 GET_CURRENT_CONTEXT(ctx);
3916 return islist(ctx, list);
3917 }
3918
3919
3920 /*
3921 * Delete a sequence of consecutive display lists.
3922 */
3923 void
3924 _mesa_DeleteLists( GLuint list, GLsizei range )
3925 {
3926 GET_CURRENT_CONTEXT(ctx);
3927 GLuint i;
3928
3929 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists");
3930 if (range<0) {
3931 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
3932 return;
3933 }
3934 for (i=list;i<list+range;i++) {
3935 gl_destroy_list( ctx, i );
3936 }
3937 }
3938
3939
3940
3941 /*
3942 * Return a display list number, n, such that lists n through n+range-1
3943 * are free.
3944 */
3945 GLuint
3946 _mesa_GenLists(GLsizei range )
3947 {
3948 GET_CURRENT_CONTEXT(ctx);
3949 GLuint base;
3950
3951 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0);
3952 if (range<0) {
3953 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
3954 return 0;
3955 }
3956 if (range==0) {
3957 return 0;
3958 }
3959
3960 /*
3961 * Make this an atomic operation
3962 */
3963 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
3964
3965 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
3966 if (base) {
3967 /* reserve the list IDs by with empty/dummy lists */
3968 GLint i;
3969 for (i=0; i<range; i++) {
3970 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
3971 }
3972 }
3973
3974 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
3975
3976 return base;
3977 }
3978
3979
3980
3981 /*
3982 * Begin a new display list.
3983 */
3984 void
3985 _mesa_NewList( GLuint list, GLenum mode )
3986 {
3987 GET_CURRENT_CONTEXT(ctx);
3988 struct immediate *IM;
3989 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");
3990
3991 if (MESA_VERBOSE&VERBOSE_API)
3992 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
3993
3994 if (list==0) {
3995 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
3996 return;
3997 }
3998
3999 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
4000 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
4001 return;
4002 }
4003
4004 if (ctx->CurrentListPtr) {
4005 /* already compiling a display list */
4006 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
4007 return;
4008 }
4009
4010 /* Allocate new display list */
4011 ctx->CurrentListNum = list;
4012 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
4013 ctx->CurrentListPtr = ctx->CurrentBlock;
4014 ctx->CurrentPos = 0;
4015
4016 IM = gl_immediate_alloc( ctx );
4017 SET_IMMEDIATE( ctx, IM );
4018 gl_reset_input( ctx );
4019
4020 ctx->CompileFlag = GL_TRUE;
4021 ctx->CompileCVAFlag = GL_FALSE;
4022 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
4023
4024 ctx->CurrentDispatch = ctx->Save;
4025 _glapi_set_dispatch( ctx->CurrentDispatch );
4026 }
4027
4028
4029
4030 /*
4031 * End definition of current display list.
4032 */
4033 void
4034 _mesa_EndList( void )
4035 {
4036 GET_CURRENT_CONTEXT(ctx);
4037 if (MESA_VERBOSE&VERBOSE_API)
4038 fprintf(stderr, "glEndList\n");
4039
4040 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );
4041
4042 /* Check that a list is under construction */
4043 if (!ctx->CurrentListPtr) {
4044 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
4045 return;
4046 }
4047
4048 (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
4049
4050 /* Destroy old list, if any */
4051 gl_destroy_list(ctx, ctx->CurrentListNum);
4052 /* Install the list */
4053 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
4054
4055
4056 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
4057 mesa_print_display_list(ctx->CurrentListNum);
4058
4059 ctx->CurrentListNum = 0;
4060 ctx->CurrentListPtr = NULL;
4061 ctx->ExecuteFlag = GL_TRUE;
4062 ctx->CompileFlag = GL_FALSE;
4063 /* ctx->CompileCVAFlag = ...; */
4064
4065 /* KW: Put back the old input pointer.
4066 */
4067 if (--ctx->input->ref_count == 0)
4068 gl_immediate_free( ctx->input );
4069
4070 SET_IMMEDIATE( ctx, ctx->VB->IM );
4071 gl_reset_input( ctx );
4072
4073 /* Haven't tracked down why this is needed.
4074 */
4075 ctx->NewState = ~0;
4076
4077 ctx->CurrentDispatch = ctx->Exec;
4078 _glapi_set_dispatch( ctx->CurrentDispatch );
4079 }
4080
4081
4082
4083 void
4084 _mesa_CallList( GLuint list )
4085 {
4086 GET_CURRENT_CONTEXT(ctx);
4087 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
4088 /* execute the display list, and restore the CompileFlag. */
4089 GLboolean save_compile_flag;
4090
4091 if (MESA_VERBOSE&VERBOSE_API) {
4092 fprintf(stderr, "glCallList %u\n", list);
4093 mesa_print_display_list( list );
4094 }
4095
4096 save_compile_flag = ctx->CompileFlag;
4097 ctx->CompileFlag = GL_FALSE;
4098
4099 FLUSH_VB( ctx, "call list" );
4100 execute_list( ctx, list );
4101 ctx->CompileFlag = save_compile_flag;
4102
4103 /* also restore API function pointers to point to "save" versions */
4104 if (save_compile_flag) {
4105 ctx->CurrentDispatch = ctx->Save;
4106 _glapi_set_dispatch( ctx->CurrentDispatch );
4107 }
4108 }
4109
4110
4111
4112 /*
4113 * Execute glCallLists: call multiple display lists.
4114 */
4115 void
4116 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
4117 {
4118 GET_CURRENT_CONTEXT(ctx);
4119 GLuint list;
4120 GLint i;
4121 GLboolean save_compile_flag;
4122
4123 /* Save the CompileFlag status, turn it off, execute display list,
4124 * and restore the CompileFlag.
4125 */
4126 save_compile_flag = ctx->CompileFlag;
4127 ctx->CompileFlag = GL_FALSE;
4128
4129 FLUSH_VB( ctx, "call lists" );
4130
4131 for (i=0;i<n;i++) {
4132 list = translate_id( i, type, lists );
4133 execute_list( ctx, ctx->List.ListBase + list );
4134 }
4135
4136 ctx->CompileFlag = save_compile_flag;
4137
4138 /* also restore API function pointers to point to "save" versions */
4139 if (save_compile_flag) {
4140 ctx->CurrentDispatch = ctx->Save;
4141 _glapi_set_dispatch( ctx->CurrentDispatch );
4142 }
4143
4144 /* RESET_IMMEDIATE( ctx ); */
4145 }
4146
4147
4148
4149 /*
4150 * Set the offset added to list numbers in glCallLists.
4151 */
4152 void
4153 _mesa_ListBase( GLuint base )
4154 {
4155 GET_CURRENT_CONTEXT(ctx);
4156 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase");
4157 ctx->List.ListBase = base;
4158 }
4159
4160
4161
4162
4163 /*
4164 * Assign all the pointers in 'table' to point to Mesa's display list
4165 * building functions.
4166 */
4167 void
4168 _mesa_init_dlist_table( struct _glapi_table *table )
4169 {
4170 _mesa_init_no_op_table(table);
4171
4172 /* GL 1.0 */
4173 table->Accum = save_Accum;
4174 table->AlphaFunc = save_AlphaFunc;
4175 table->Begin = save_Begin;
4176 table->Bitmap = save_Bitmap;
4177 table->BlendFunc = save_BlendFunc;
4178 table->CallList = save_CallList;
4179 table->CallLists = save_CallLists;
4180 table->Clear = save_Clear;
4181 table->ClearAccum = save_ClearAccum;
4182 table->ClearColor = save_ClearColor;
4183 table->ClearDepth = save_ClearDepth;
4184 table->ClearIndex = save_ClearIndex;
4185 table->ClearStencil = save_ClearStencil;
4186 table->ClipPlane = save_ClipPlane;
4187 table->Color3b = _mesa_Color3b;
4188 table->Color3bv = _mesa_Color3bv;
4189 table->Color3d = _mesa_Color3d;
4190 table->Color3dv = _mesa_Color3dv;
4191 table->Color3f = _mesa_Color3f;
4192 table->Color3fv = _mesa_Color3fv;
4193 table->Color3i = _mesa_Color3i;
4194 table->Color3iv = _mesa_Color3iv;
4195 table->Color3s = _mesa_Color3s;
4196 table->Color3sv = _mesa_Color3sv;
4197 table->Color3ub = _mesa_Color3ub;
4198 table->Color3ubv = _mesa_Color3ubv;
4199 table->Color3ui = _mesa_Color3ui;
4200 table->Color3uiv = _mesa_Color3uiv;
4201 table->Color3us = _mesa_Color3us;
4202 table->Color3usv = _mesa_Color3usv;
4203 table->Color4b = _mesa_Color4b;
4204 table->Color4bv = _mesa_Color4bv;
4205 table->Color4d = _mesa_Color4d;
4206 table->Color4dv = _mesa_Color4dv;
4207 table->Color4f = _mesa_Color4f;
4208 table->Color4fv = _mesa_Color4fv;
4209 table->Color4i = _mesa_Color4i;
4210 table->Color4iv = _mesa_Color4iv;
4211 table->Color4s = _mesa_Color4s;
4212 table->Color4sv = _mesa_Color4sv;
4213 table->Color4ub = _mesa_Color4ub;
4214 table->Color4ubv = _mesa_Color4ubv;
4215 table->Color4ui = _mesa_Color4ui;
4216 table->Color4uiv = _mesa_Color4uiv;
4217 table->Color4us = _mesa_Color4us;
4218 table->Color4usv = _mesa_Color4usv;
4219 table->ColorMask = save_ColorMask;
4220 table->ColorMaterial = save_ColorMaterial;
4221 table->CopyPixels = save_CopyPixels;
4222 table->CullFace = save_CullFace;
4223 table->DeleteLists = _mesa_DeleteLists;
4224 table->DepthFunc = save_DepthFunc;
4225 table->DepthMask = save_DepthMask;
4226 table->DepthRange = save_DepthRange;
4227 table->Disable = save_Disable;
4228 table->DrawBuffer = save_DrawBuffer;
4229 table->DrawPixels = save_DrawPixels;
4230 table->EdgeFlag = _mesa_EdgeFlag;
4231 table->EdgeFlagv = _mesa_EdgeFlagv;
4232 table->Enable = save_Enable;
4233 table->End = _mesa_End;
4234 table->EndList = _mesa_EndList;
4235 table->EvalCoord1d = _mesa_EvalCoord1d;
4236 table->EvalCoord1dv = _mesa_EvalCoord1dv;
4237 table->EvalCoord1f = _mesa_EvalCoord1f;
4238 table->EvalCoord1fv = _mesa_EvalCoord1fv;
4239 table->EvalCoord2d = _mesa_EvalCoord2d;
4240 table->EvalCoord2dv = _mesa_EvalCoord2dv;
4241 table->EvalCoord2f = _mesa_EvalCoord2f;
4242 table->EvalCoord2fv = _mesa_EvalCoord2fv;
4243 table->EvalMesh1 = save_EvalMesh1;
4244 table->EvalMesh2 = save_EvalMesh2;
4245 table->EvalPoint1 = _mesa_EvalPoint1;
4246 table->EvalPoint2 = _mesa_EvalPoint2;
4247 table->FeedbackBuffer = _mesa_FeedbackBuffer;
4248 table->Finish = _mesa_Finish;
4249 table->Flush = _mesa_Flush;
4250 table->Fogf = save_Fogf;
4251 table->Fogfv = save_Fogfv;
4252 table->Fogi = save_Fogi;
4253 table->Fogiv = save_Fogiv;
4254 table->FrontFace = save_FrontFace;
4255 table->Frustum = save_Frustum;
4256 table->GenLists = _mesa_GenLists;
4257 table->GetBooleanv = _mesa_GetBooleanv;
4258 table->GetClipPlane = _mesa_GetClipPlane;
4259 table->GetDoublev = _mesa_GetDoublev;
4260 table->GetError = _mesa_GetError;
4261 table->GetFloatv = _mesa_GetFloatv;
4262 table->GetIntegerv = _mesa_GetIntegerv;
4263 table->GetLightfv = _mesa_GetLightfv;
4264 table->GetLightiv = _mesa_GetLightiv;
4265 table->GetMapdv = _mesa_GetMapdv;
4266 table->GetMapfv = _mesa_GetMapfv;
4267 table->GetMapiv = _mesa_GetMapiv;
4268 table->GetMaterialfv = _mesa_GetMaterialfv;
4269 table->GetMaterialiv = _mesa_GetMaterialiv;
4270 table->GetPixelMapfv = _mesa_GetPixelMapfv;
4271 table->GetPixelMapuiv = _mesa_GetPixelMapuiv;
4272 table->GetPixelMapusv = _mesa_GetPixelMapusv;
4273 table->GetPolygonStipple = _mesa_GetPolygonStipple;
4274 table->GetString = _mesa_GetString;
4275 table->GetTexEnvfv = _mesa_GetTexEnvfv;
4276 table->GetTexEnviv = _mesa_GetTexEnviv;
4277 table->GetTexGendv = _mesa_GetTexGendv;
4278 table->GetTexGenfv = _mesa_GetTexGenfv;
4279 table->GetTexGeniv = _mesa_GetTexGeniv;
4280 table->GetTexImage = _mesa_GetTexImage;
4281 table->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv;
4282 table->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv;
4283 table->GetTexParameterfv = _mesa_GetTexParameterfv;
4284 table->GetTexParameteriv = _mesa_GetTexParameteriv;
4285 table->Hint = save_Hint;
4286 table->IndexMask = save_IndexMask;
4287 table->Indexd = _mesa_Indexd;
4288 table->Indexdv = _mesa_Indexdv;
4289 table->Indexf = _mesa_Indexf;
4290 table->Indexfv = _mesa_Indexfv;
4291 table->Indexi = _mesa_Indexi;
4292 table->Indexiv = _mesa_Indexiv;
4293 table->Indexs = _mesa_Indexs;
4294 table->Indexsv = _mesa_Indexsv;
4295 table->InitNames = save_InitNames;
4296 table->IsEnabled = _mesa_IsEnabled;
4297 table->IsList = _mesa_IsList;
4298 table->LightModelf = save_LightModelf;
4299 table->LightModelfv = save_LightModelfv;
4300 table->LightModeli = save_LightModeli;
4301 table->LightModeliv = save_LightModeliv;
4302 table->Lightf = save_Lightf;
4303 table->Lightfv = save_Lightfv;
4304 table->Lighti = save_Lighti;
4305 table->Lightiv = save_Lightiv;
4306 table->LineStipple = save_LineStipple;
4307 table->LineWidth = save_LineWidth;
4308 table->ListBase = save_ListBase;
4309 table->LoadIdentity = save_LoadIdentity;
4310 table->LoadMatrixd = save_LoadMatrixd;
4311 table->LoadMatrixf = save_LoadMatrixf;
4312 table->LoadName = save_LoadName;
4313 table->LogicOp = save_LogicOp;
4314 table->Map1d = save_Map1d;
4315 table->Map1f = save_Map1f;
4316 table->Map2d = save_Map2d;
4317 table->Map2f = save_Map2f;
4318 table->MapGrid1d = save_MapGrid1d;
4319 table->MapGrid1f = save_MapGrid1f;
4320 table->MapGrid2d = save_MapGrid2d;
4321 table->MapGrid2f = save_MapGrid2f;
4322 table->Materialf = _mesa_Materialf;
4323 table->Materialfv = _mesa_Materialfv;
4324 table->Materiali = _mesa_Materiali;
4325 table->Materialiv = _mesa_Materialiv;
4326 table->MatrixMode = save_MatrixMode;
4327 table->MultMatrixd = save_MultMatrixd;
4328 table->MultMatrixf = save_MultMatrixf;
4329 table->NewList = save_NewList;
4330 table->Normal3b = _mesa_Normal3b;
4331 table->Normal3bv = _mesa_Normal3bv;
4332 table->Normal3d = _mesa_Normal3d;
4333 table->Normal3dv = _mesa_Normal3dv;
4334 table->Normal3f = _mesa_Normal3f;
4335 table->Normal3fv = _mesa_Normal3fv;
4336 table->Normal3i = _mesa_Normal3i;
4337 table->Normal3iv = _mesa_Normal3iv;
4338 table->Normal3s = _mesa_Normal3s;
4339 table->Normal3sv = _mesa_Normal3sv;
4340 table->Ortho = save_Ortho;
4341 table->PassThrough = save_PassThrough;
4342 table->PixelMapfv = save_PixelMapfv;
4343 table->PixelMapuiv = save_PixelMapuiv;
4344 table->PixelMapusv = save_PixelMapusv;
4345 table->PixelStoref = _mesa_PixelStoref;
4346 table->PixelStorei = _mesa_PixelStorei;
4347 table->PixelTransferf = save_PixelTransferf;
4348 table->PixelTransferi = save_PixelTransferi;
4349 table->PixelZoom = save_PixelZoom;
4350 table->PointSize = save_PointSize;
4351 table->PolygonMode = save_PolygonMode;
4352 table->PolygonOffset = save_PolygonOffset;
4353 table->PolygonStipple = save_PolygonStipple;
4354 table->PopAttrib = save_PopAttrib;
4355 table->PopMatrix = save_PopMatrix;
4356 table->PopName = save_PopName;
4357 table->PushAttrib = save_PushAttrib;
4358 table->PushMatrix = save_PushMatrix;
4359 table->PushName = save_PushName;
4360 table->RasterPos2d = save_RasterPos2d;
4361 table->RasterPos2dv = save_RasterPos2dv;
4362 table->RasterPos2f = save_RasterPos2f;
4363 table->RasterPos2fv = save_RasterPos2fv;
4364 table->RasterPos2i = save_RasterPos2i;
4365 table->RasterPos2iv = save_RasterPos2iv;
4366 table->RasterPos2s = save_RasterPos2s;
4367 table->RasterPos2sv = save_RasterPos2sv;
4368 table->RasterPos3d = save_RasterPos3d;
4369 table->RasterPos3dv = save_RasterPos3dv;
4370 table->RasterPos3f = save_RasterPos3f;
4371 table->RasterPos3fv = save_RasterPos3fv;
4372 table->RasterPos3i = save_RasterPos3i;
4373 table->RasterPos3iv = save_RasterPos3iv;
4374 table->RasterPos3s = save_RasterPos3s;
4375 table->RasterPos3sv = save_RasterPos3sv;
4376 table->RasterPos4d = save_RasterPos4d;
4377 table->RasterPos4dv = save_RasterPos4dv;
4378 table->RasterPos4f = save_RasterPos4f;
4379 table->RasterPos4fv = save_RasterPos4fv;
4380 table->RasterPos4i = save_RasterPos4i;
4381 table->RasterPos4iv = save_RasterPos4iv;
4382 table->RasterPos4s = save_RasterPos4s;
4383 table->RasterPos4sv = save_RasterPos4sv;
4384 table->ReadBuffer = save_ReadBuffer;
4385 table->ReadPixels = _mesa_ReadPixels;
4386 table->Rectd = save_Rectd;
4387 table->Rectdv = save_Rectdv;
4388 table->Rectf = save_Rectf;
4389 table->Rectfv = save_Rectfv;
4390 table->Recti = save_Recti;
4391 table->Rectiv = save_Rectiv;
4392 table->Rects = save_Rects;
4393 table->Rectsv = save_Rectsv;
4394 table->RenderMode = _mesa_RenderMode;
4395 table->Rotated = save_Rotated;
4396 table->Rotatef = save_Rotatef;
4397 table->Scaled = save_Scaled;
4398 table->Scalef = save_Scalef;
4399 table->Scissor = save_Scissor;
4400 table->SelectBuffer = _mesa_SelectBuffer;
4401 table->ShadeModel = save_ShadeModel;
4402 table->StencilFunc = save_StencilFunc;
4403 table->StencilMask = save_StencilMask;
4404 table->StencilOp = save_StencilOp;
4405 table->TexCoord1d = _mesa_TexCoord1d;
4406 table->TexCoord1dv = _mesa_TexCoord1dv;
4407 table->TexCoord1f = _mesa_TexCoord1f;
4408 table->TexCoord1fv = _mesa_TexCoord1fv;
4409 table->TexCoord1i = _mesa_TexCoord1i;
4410 table->TexCoord1iv = _mesa_TexCoord1iv;
4411 table->TexCoord1s = _mesa_TexCoord1s;
4412 table->TexCoord1sv = _mesa_TexCoord1sv;
4413 table->TexCoord2d = _mesa_TexCoord2d;
4414 table->TexCoord2dv = _mesa_TexCoord2dv;
4415 table->TexCoord2f = _mesa_TexCoord2f;
4416 table->TexCoord2fv = _mesa_TexCoord2fv;
4417 table->TexCoord2i = _mesa_TexCoord2i;
4418 table->TexCoord2iv = _mesa_TexCoord2iv;
4419 table->TexCoord2s = _mesa_TexCoord2s;
4420 table->TexCoord2sv = _mesa_TexCoord2sv;
4421 table->TexCoord3d = _mesa_TexCoord3d;
4422 table->TexCoord3dv = _mesa_TexCoord3dv;
4423 table->TexCoord3f = _mesa_TexCoord3f;
4424 table->TexCoord3fv = _mesa_TexCoord3fv;
4425 table->TexCoord3i = _mesa_TexCoord3i;
4426 table->TexCoord3iv = _mesa_TexCoord3iv;
4427 table->TexCoord3s = _mesa_TexCoord3s;
4428 table->TexCoord3sv = _mesa_TexCoord3sv;
4429 table->TexCoord4d = _mesa_TexCoord4d;
4430 table->TexCoord4dv = _mesa_TexCoord4dv;
4431 table->TexCoord4f = _mesa_TexCoord4f;
4432 table->TexCoord4fv = _mesa_TexCoord4fv;
4433 table->TexCoord4i = _mesa_TexCoord4i;
4434 table->TexCoord4iv = _mesa_TexCoord4iv;
4435 table->TexCoord4s = _mesa_TexCoord4s;
4436 table->TexCoord4sv = _mesa_TexCoord4sv;
4437 table->TexEnvf = save_TexEnvf;
4438 table->TexEnvfv = save_TexEnvfv;
4439 table->TexEnvi = save_TexEnvi;
4440 table->TexEnviv = save_TexEnviv;
4441 table->TexGend = save_TexGend;
4442 table->TexGendv = save_TexGendv;
4443 table->TexGenf = save_TexGenf;
4444 table->TexGenfv = save_TexGenfv;
4445 table->TexGeni = save_TexGeni;
4446 table->TexGeniv = save_TexGeniv;
4447 table->TexImage1D = save_TexImage1D;
4448 table->TexImage2D = save_TexImage2D;
4449 table->TexParameterf = save_TexParameterf;
4450 table->TexParameterfv = save_TexParameterfv;
4451 table->TexParameteri = save_TexParameteri;
4452 table->TexParameteriv = save_TexParameteriv;
4453 table->Translated = save_Translated;
4454 table->Translatef = save_Translatef;
4455 table->Vertex2d = _mesa_Vertex2d;
4456 table->Vertex2dv = _mesa_Vertex2dv;
4457 table->Vertex2f = _mesa_Vertex2f;
4458 table->Vertex2fv = _mesa_Vertex2fv;
4459 table->Vertex2i = _mesa_Vertex2i;
4460 table->Vertex2iv = _mesa_Vertex2iv;
4461 table->Vertex2s = _mesa_Vertex2s;
4462 table->Vertex2sv = _mesa_Vertex2sv;
4463 table->Vertex3d = _mesa_Vertex3d;
4464 table->Vertex3dv = _mesa_Vertex3dv;
4465 table->Vertex3f = _mesa_Vertex3f;
4466 table->Vertex3fv = _mesa_Vertex3fv;
4467 table->Vertex3i = _mesa_Vertex3i;
4468 table->Vertex3iv = _mesa_Vertex3iv;
4469 table->Vertex3s = _mesa_Vertex3s;
4470 table->Vertex3sv = _mesa_Vertex3sv;
4471 table->Vertex4d = _mesa_Vertex4d;
4472 table->Vertex4dv = _mesa_Vertex4dv;
4473 table->Vertex4f = _mesa_Vertex4f;
4474 table->Vertex4fv = _mesa_Vertex4fv;
4475 table->Vertex4i = _mesa_Vertex4i;
4476 table->Vertex4iv = _mesa_Vertex4iv;
4477 table->Vertex4s = _mesa_Vertex4s;
4478 table->Vertex4sv = _mesa_Vertex4sv;
4479 table->Viewport = save_Viewport;
4480
4481 /* GL 1.1 */
4482 table->AreTexturesResident = _mesa_AreTexturesResident;
4483 table->ArrayElement = _mesa_ArrayElement;
4484 table->BindTexture = save_BindTexture;
4485 table->ColorPointer = _mesa_ColorPointer;
4486 table->CopyTexImage1D = save_CopyTexImage1D;
4487 table->CopyTexImage2D = save_CopyTexImage2D;
4488 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
4489 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
4490 table->DeleteTextures = _mesa_DeleteTextures;
4491 table->DisableClientState = _mesa_DisableClientState;
4492 table->DrawArrays = _mesa_DrawArrays;
4493 table->DrawElements = _mesa_DrawElements;
4494 table->EdgeFlagPointer = _mesa_EdgeFlagPointer;
4495 table->EnableClientState = _mesa_EnableClientState;
4496 table->GenTextures = _mesa_GenTextures;
4497 table->GetPointerv = _mesa_GetPointerv;
4498 table->IndexPointer = _mesa_IndexPointer;
4499 table->Indexub = _mesa_Indexub;
4500 table->Indexubv = _mesa_Indexubv;
4501 table->InterleavedArrays = _mesa_InterleavedArrays;
4502 table->IsTexture = _mesa_IsTexture;
4503 table->NormalPointer = _mesa_NormalPointer;
4504 table->PopClientAttrib = _mesa_PopClientAttrib;
4505 table->PrioritizeTextures = save_PrioritizeTextures;
4506 table->PushClientAttrib = _mesa_PushClientAttrib;
4507 table->TexCoordPointer = _mesa_TexCoordPointer;
4508 table->TexSubImage1D = save_TexSubImage1D;
4509 table->TexSubImage2D = save_TexSubImage2D;
4510 table->VertexPointer = _mesa_VertexPointer;
4511
4512 /* GL 1.2 */
4513 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
4514 table->DrawRangeElements = _mesa_DrawRangeElements;
4515 table->TexImage3D = save_TexImage3D;
4516 table->TexSubImage3D = save_TexSubImage3D;
4517
4518 /* GL_ARB_imaging */
4519 /* Not all are supported */
4520 table->BlendColor = save_BlendColor;
4521 table->BlendEquation = save_BlendEquation;
4522 table->ColorSubTable = save_ColorSubTable;
4523 table->ColorTable = save_ColorTable;
4524 table->ColorTableParameterfv = _mesa_ColorTableParameterfv;
4525 table->ColorTableParameteriv = _mesa_ColorTableParameteriv;
4526 table->ConvolutionFilter1D = _mesa_ConvolutionFilter1D;
4527 table->ConvolutionFilter2D = _mesa_ConvolutionFilter2D;
4528 table->ConvolutionParameterf = _mesa_ConvolutionParameterf;
4529 table->ConvolutionParameterfv = _mesa_ConvolutionParameterfv;
4530 table->ConvolutionParameteri = _mesa_ConvolutionParameteri;
4531 table->ConvolutionParameteriv = _mesa_ConvolutionParameteriv;
4532 table->CopyColorSubTable = _mesa_CopyColorSubTable;
4533 table->CopyColorTable = _mesa_CopyColorTable;
4534 table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D;
4535 table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D;
4536 table->GetColorTable = _mesa_GetColorTable;
4537 table->GetColorTableParameterfv = _mesa_GetColorTableParameterfv;
4538 table->GetColorTableParameteriv = _mesa_GetColorTableParameteriv;
4539 table->GetConvolutionFilter = _mesa_GetConvolutionFilter;
4540 table->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv;
4541 table->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv;
4542 table->GetHistogram = _mesa_GetHistogram;
4543 table->GetHistogramParameterfv = _mesa_GetHistogramParameterfv;
4544 table->GetHistogramParameteriv = _mesa_GetHistogramParameteriv;
4545 table->GetMinmax = _mesa_GetMinmax;
4546 table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv;
4547 table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv;
4548 table->GetSeparableFilter = _mesa_GetSeparableFilter;
4549 table->Histogram = _mesa_Histogram;
4550 table->Minmax = _mesa_Minmax;
4551 table->ResetHistogram = _mesa_ResetHistogram;
4552 table->ResetMinmax = _mesa_ResetMinmax;
4553 table->SeparableFilter2D = _mesa_SeparableFilter2D;
4554
4555 /* GL_EXT_texture3d */
4556 #if 0
4557 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
4558 table->TexImage3DEXT = save_TexImage3DEXT;
4559 table->TexSubImage3DEXT = save_TexSubImage3D;
4560 #endif
4561
4562 /* GL_EXT_paletted_texture */
4563 #if 0
4564 table->ColorTableEXT = save_ColorTable;
4565 table->ColorSubTableEXT = save_ColorSubTable;
4566 #endif
4567 table->GetColorTableEXT = _mesa_GetColorTable;
4568 table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv;
4569 table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv;
4570
4571 /* GL_EXT_compiled_vertex_array */
4572 table->LockArraysEXT = _mesa_LockArraysEXT;
4573 table->UnlockArraysEXT = _mesa_UnlockArraysEXT;
4574
4575 /* GL_EXT_point_parameters */
4576 table->PointParameterfEXT = save_PointParameterfEXT;
4577 table->PointParameterfvEXT = save_PointParameterfvEXT;
4578
4579 /* GL_PGI_misc_hints */
4580 table->HintPGI = save_HintPGI;
4581
4582 /* GL_EXT_polygon_offset */
4583 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
4584
4585 /* GL_EXT_blend_minmax */
4586 #if 0
4587 table->BlendEquationEXT = save_BlendEquationEXT;
4588 #endif
4589
4590 /* GL_EXT_blend_color */
4591 #if 0
4592 table->BlendColorEXT = save_BlendColorEXT;
4593 #endif
4594
4595 /* GL_ARB_multitexture */
4596 table->ActiveTextureARB = save_ActiveTextureARB;
4597 table->ClientActiveTextureARB = save_ClientActiveTextureARB;
4598 table->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB;
4599 table->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB;
4600 table->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB;
4601 table->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB;
4602 table->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB;
4603 table->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB;
4604 table->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB;
4605 table->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB;
4606 table->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB;
4607 table->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB;
4608 table->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB;
4609 table->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB;
4610 table->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB;
4611 table->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB;
4612 table->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB;
4613 table->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB;
4614 table->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB;
4615 table->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB;
4616 table->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB;
4617 table->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB;
4618 table->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB;
4619 table->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB;
4620 table->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB;
4621 table->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB;
4622 table->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB;
4623 table->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB;
4624 table->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB;
4625 table->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB;
4626 table->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB;
4627 table->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB;
4628 table->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB;
4629 table->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB;
4630
4631 /* GL_EXT_blend_func_separate */
4632 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT;
4633
4634 /* GL_MESA_window_pos */
4635 table->WindowPos2dMESA = save_WindowPos2dMESA;
4636 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
4637 table->WindowPos2fMESA = save_WindowPos2fMESA;
4638 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
4639 table->WindowPos2iMESA = save_WindowPos2iMESA;
4640 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
4641 table->WindowPos2sMESA = save_WindowPos2sMESA;
4642 table->WindowPos2svMESA = save_WindowPos2svMESA;
4643 table->WindowPos3dMESA = save_WindowPos3dMESA;
4644 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
4645 table->WindowPos3fMESA = save_WindowPos3fMESA;
4646 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
4647 table->WindowPos3iMESA = save_WindowPos3iMESA;
4648 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
4649 table->WindowPos3sMESA = save_WindowPos3sMESA;
4650 table->WindowPos3svMESA = save_WindowPos3svMESA;
4651 table->WindowPos4dMESA = save_WindowPos4dMESA;
4652 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
4653 table->WindowPos4fMESA = save_WindowPos4fMESA;
4654 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
4655 table->WindowPos4iMESA = save_WindowPos4iMESA;
4656 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
4657 table->WindowPos4sMESA = save_WindowPos4sMESA;
4658 table->WindowPos4svMESA = save_WindowPos4svMESA;
4659
4660 /* GL_MESA_resize_buffers */
4661 table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA;
4662
4663 /* GL_ARB_transpose_matrix */
4664 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
4665 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
4666 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
4667 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
4668
4669 }
4670
4671
4672
4673 /***
4674 *** Debugging code
4675 ***/
4676 static const char *enum_string( GLenum k )
4677 {
4678 return gl_lookup_enum_by_nr( k );
4679 }
4680
4681
4682 /*
4683 * Print the commands in a display list. For debugging only.
4684 * TODO: many commands aren't handled yet.
4685 */
4686 static void print_list( GLcontext *ctx, FILE *f, GLuint list )
4687 {
4688 Node *n;
4689 GLboolean done;
4690 OpCode opcode;
4691
4692 if (!glIsList(list)) {
4693 fprintf(f,"%u is not a display list ID\n",list);
4694 return;
4695 }
4696
4697 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
4698
4699 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
4700
4701 done = n ? GL_FALSE : GL_TRUE;
4702 while (!done) {
4703 opcode = n[0].opcode;
4704
4705 switch (opcode) {
4706 case OPCODE_ACCUM:
4707 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
4708 break;
4709 case OPCODE_BITMAP:
4710 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
4711 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
4712 break;
4713 case OPCODE_CALL_LIST:
4714 fprintf(f,"CallList %d\n", (int) n[1].ui );
4715 break;
4716 case OPCODE_CALL_LIST_OFFSET:
4717 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
4718 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
4719 break;
4720 case OPCODE_DISABLE:
4721 fprintf(f,"Disable %s\n", enum_string(n[1].e));
4722 break;
4723 case OPCODE_ENABLE:
4724 fprintf(f,"Enable %s\n", enum_string(n[1].e));
4725 break;
4726 case OPCODE_FRUSTUM:
4727 fprintf(f,"Frustum %g %g %g %g %g %g\n",
4728 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4729 break;
4730 case OPCODE_LINE_STIPPLE:
4731 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
4732 break;
4733 case OPCODE_LOAD_IDENTITY:
4734 fprintf(f,"LoadIdentity\n");
4735 break;
4736 case OPCODE_LOAD_MATRIX:
4737 fprintf(f,"LoadMatrix\n");
4738 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
4739 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
4740 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
4741 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
4742 break;
4743 case OPCODE_MULT_MATRIX:
4744 fprintf(f,"MultMatrix (or Rotate)\n");
4745 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
4746 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
4747 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
4748 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
4749 break;
4750 case OPCODE_ORTHO:
4751 fprintf(f,"Ortho %g %g %g %g %g %g\n",
4752 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4753 break;
4754 case OPCODE_POP_ATTRIB:
4755 fprintf(f,"PopAttrib\n");
4756 break;
4757 case OPCODE_POP_MATRIX:
4758 fprintf(f,"PopMatrix\n");
4759 break;
4760 case OPCODE_POP_NAME:
4761 fprintf(f,"PopName\n");
4762 break;
4763 case OPCODE_PUSH_ATTRIB:
4764 fprintf(f,"PushAttrib %x\n", n[1].bf );
4765 break;
4766 case OPCODE_PUSH_MATRIX:
4767 fprintf(f,"PushMatrix\n");
4768 break;
4769 case OPCODE_PUSH_NAME:
4770 fprintf(f,"PushName %d\n", (int) n[1].ui );
4771 break;
4772 case OPCODE_RASTER_POS:
4773 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
4774 break;
4775 case OPCODE_RECTF:
4776 fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
4777 break;
4778 case OPCODE_SCALE:
4779 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
4780 break;
4781 case OPCODE_TRANSLATE:
4782 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
4783 break;
4784 case OPCODE_BIND_TEXTURE:
4785 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
4786 n[2].ui);
4787 break;
4788 case OPCODE_SHADE_MODEL:
4789 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
4790 break;
4791
4792 /*
4793 * meta opcodes/commands
4794 */
4795 case OPCODE_ERROR:
4796 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
4797 break;
4798 case OPCODE_VERTEX_CASSETTE:
4799 fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
4800 ((struct immediate *) n[1].data)->id,
4801 n[2].ui,
4802 n[3].ui);
4803 gl_print_cassette( (struct immediate *) n[1].data );
4804 break;
4805 case OPCODE_CONTINUE:
4806 fprintf(f,"DISPLAY-LIST-CONTINUE\n");
4807 n = (Node *) n[1].next;
4808 break;
4809 case OPCODE_END_OF_LIST:
4810 fprintf(f,"END-LIST %u\n", list);
4811 done = GL_TRUE;
4812 break;
4813 default:
4814 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
4815 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
4816 opcode, (void*) n);
4817 return;
4818 }
4819 else {
4820 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
4821 }
4822 }
4823
4824 /* increment n to point to next compiled command */
4825 if (opcode!=OPCODE_CONTINUE) {
4826 n += InstSize[opcode];
4827 }
4828 }
4829 }
4830
4831
4832
4833 /*
4834 * Clients may call this function to help debug display list problems.
4835 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
4836 * changed, or break in the future without notice.
4837 */
4838 void mesa_print_display_list( GLuint list )
4839 {
4840 GET_CURRENT_CONTEXT(ctx);
4841 print_list( ctx, stderr, list );
4842 }