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