added code for all GL_MESA_window_pos functions
[mesa.git] / src / mesa / main / dlist.c
1 /* $Id: dlist.c,v 1.29 2000/02/11 21:14:27 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "accum.h"
33 #include "attrib.h"
34 #include "bitmap.h"
35 #include "bbox.h"
36 #include "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 static void save_WindowPos2dMESA(GLdouble x, GLdouble y)
3055 {
3056 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3057 }
3058
3059 static void save_WindowPos2fMESA(GLfloat x, GLfloat y)
3060 {
3061 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3062 }
3063
3064 static void save_WindowPos2iMESA(GLint x, GLint y)
3065 {
3066 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3067 }
3068
3069 static void save_WindowPos2sMESA(GLshort x, GLshort y)
3070 {
3071 save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
3072 }
3073
3074 static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
3075 {
3076 save_WindowPos4fMESA(x, y, z, 1.0F);
3077 }
3078
3079 static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
3080 {
3081 save_WindowPos4fMESA(x, y, z, 1.0F);
3082 }
3083
3084 static void save_WindowPos3iMESA(GLint x, GLint y, GLint z)
3085 {
3086 save_WindowPos4fMESA(x, y, z, 1.0F);
3087 }
3088
3089 static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
3090 {
3091 save_WindowPos4fMESA(x, y, z, 1.0F);
3092 }
3093
3094 static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
3095 {
3096 save_WindowPos4fMESA(x, y, z, w);
3097 }
3098
3099 static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
3100 {
3101 save_WindowPos4fMESA(x, y, z, w);
3102 }
3103
3104 static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
3105 {
3106 save_WindowPos4fMESA(x, y, z, w);
3107 }
3108
3109 static void save_WindowPos2dvMESA(const GLdouble *v)
3110 {
3111 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3112 }
3113
3114 static void save_WindowPos2fvMESA(const GLfloat *v)
3115 {
3116 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3117 }
3118
3119 static void save_WindowPos2ivMESA(const GLint *v)
3120 {
3121 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3122 }
3123
3124 static void save_WindowPos2svMESA(const GLshort *v)
3125 {
3126 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
3127 }
3128
3129 static void save_WindowPos3dvMESA(const GLdouble *v)
3130 {
3131 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3132 }
3133
3134 static void save_WindowPos3fvMESA(const GLfloat *v)
3135 {
3136 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3137 }
3138
3139 static void save_WindowPos3ivMESA(const GLint *v)
3140 {
3141 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3142 }
3143
3144 static void save_WindowPos3svMESA(const GLshort *v)
3145 {
3146 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
3147 }
3148
3149 static void save_WindowPos4dvMESA(const GLdouble *v)
3150 {
3151 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3152 }
3153
3154 static void save_WindowPos4fvMESA(const GLfloat *v)
3155 {
3156 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3157 }
3158
3159 static void save_WindowPos4ivMESA(const GLint *v)
3160 {
3161 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3162 }
3163
3164 static void save_WindowPos4svMESA(const GLshort *v)
3165 {
3166 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
3167 }
3168
3169
3170
3171 /* GL_ARB_multitexture */
3172 static void save_ActiveTextureARB( GLenum target )
3173 {
3174 GET_CURRENT_CONTEXT(ctx);
3175 Node *n;
3176 FLUSH_VB(ctx, "dlist");
3177 n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
3178 if (n) {
3179 n[1].e = target;
3180 }
3181 if (ctx->ExecuteFlag) {
3182 (*ctx->Exec.ActiveTextureARB)( target );
3183 }
3184 }
3185
3186
3187 /* GL_ARB_multitexture */
3188 static void save_ClientActiveTextureARB( GLenum target )
3189 {
3190 GET_CURRENT_CONTEXT(ctx);
3191 Node *n;
3192 FLUSH_VB(ctx, "dlist");
3193 n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
3194 if (n) {
3195 n[1].e = target;
3196 }
3197 if (ctx->ExecuteFlag) {
3198 (*ctx->Exec.ClientActiveTextureARB)( target );
3199 }
3200 }
3201
3202
3203
3204 static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
3205 {
3206 GLdouble tm[16];
3207 gl_matrix_transposed(tm, m);
3208 save_LoadMatrixd(tm);
3209 }
3210
3211
3212 static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
3213 {
3214 GLfloat tm[16];
3215 gl_matrix_transposef(tm, m);
3216 save_LoadMatrixf(tm);
3217 }
3218
3219
3220 static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
3221 {
3222 GLdouble tm[16];
3223 gl_matrix_transposed(tm, m);
3224 save_MultMatrixd(tm);
3225 }
3226
3227
3228 static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
3229 {
3230 GLfloat tm[16];
3231 gl_matrix_transposef(tm, m);
3232 save_MultMatrixf(tm);
3233 }
3234
3235
3236
3237 void gl_compile_cassette( GLcontext *ctx )
3238 {
3239 Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 8 );
3240 struct immediate *im = ctx->input;
3241
3242 if (!n)
3243 return;
3244
3245
3246 /* Do some easy optimizations of the cassette.
3247 */
3248 #if 0
3249 if (0 && im->v.Obj.size < 4 && im->Count > 15) {
3250 im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat));
3251 (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj );
3252 }
3253 #endif
3254
3255 n[1].data = (void *)im;
3256 n[2].ui = im->Start;
3257 n[3].ui = im->Count;
3258 n[4].ui = im->BeginState;
3259 n[5].ui = im->OrFlag;
3260 n[6].ui = im->AndFlag;
3261 n[7].ui = im->LastData;
3262 n[8].ui = im->LastPrimitive;
3263
3264 if (im->Count > VB_MAX - 4) {
3265
3266 struct immediate *new_im = gl_immediate_alloc(ctx);
3267 if (!new_im) return;
3268 SET_IMMEDIATE( ctx, new_im );
3269 gl_reset_input( ctx );
3270
3271 } else {
3272 im->Count++;;
3273 im->Start = im->Count; /* don't clear anything in reset_input */
3274 im->ref_count++;
3275
3276 im->Primitive[im->Start] = ctx->Current.Primitive;
3277 im->LastPrimitive = im->Start;
3278 im->BeginState = VERT_BEGIN_0;
3279 im->OrFlag = 0;
3280 im->AndFlag = ~0;
3281
3282 if (0)
3283 fprintf(stderr, "in compile_cassette, BeginState is %x\n",
3284 im->BeginState);
3285 }
3286 }
3287
3288 /* KW: Compile commands
3289 *
3290 * Will appear in the list before the vertex buffer containing the
3291 * command that provoked the error. I don't see this as a problem.
3292 */
3293 void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
3294 {
3295 Node *n;
3296 n = alloc_instruction( ctx, OPCODE_ERROR, 2 );
3297 if (n) {
3298 n[1].e = error;
3299 n[2].data = (void *) s;
3300 }
3301 /* execute already done */
3302 }
3303
3304
3305 static GLboolean
3306 islist(GLcontext *ctx, GLuint list)
3307 {
3308 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
3309 return GL_TRUE;
3310 }
3311 else {
3312 return GL_FALSE;
3313 }
3314 }
3315
3316
3317
3318 /**********************************************************************/
3319 /* Display list execution */
3320 /**********************************************************************/
3321
3322
3323 /*
3324 * Execute a display list. Note that the ListBase offset must have already
3325 * been added before calling this function. I.e. the list argument is
3326 * the absolute list number, not relative to ListBase.
3327 * Input: list - display list number
3328 */
3329 static void execute_list( GLcontext *ctx, GLuint list )
3330 {
3331 Node *n;
3332 GLboolean done;
3333 OpCode opcode;
3334
3335 if (!islist(ctx,list))
3336 return;
3337
3338 /* mesa_print_display_list( list ); */
3339
3340 ctx->CallDepth++;
3341
3342 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
3343
3344 done = GL_FALSE;
3345 while (!done) {
3346 opcode = n[0].opcode;
3347
3348 switch (opcode) {
3349 case OPCODE_ERROR:
3350 gl_error( ctx, n[1].e, (const char *) n[2].data );
3351 break;
3352 case OPCODE_VERTEX_CASSETTE: {
3353 struct immediate *IM;
3354
3355 if (ctx->NewState)
3356 gl_update_state(ctx);
3357 if (ctx->CompileCVAFlag) {
3358 ctx->CompileCVAFlag = 0;
3359 ctx->CVA.elt.pipeline_valid = 0;
3360 }
3361 if (!ctx->CVA.elt.pipeline_valid)
3362 gl_build_immediate_pipeline( ctx );
3363
3364
3365 IM = (struct immediate *) n[1].data;
3366 IM->Start = n[2].ui;
3367 IM->Count = n[3].ui;
3368 IM->BeginState = n[4].ui;
3369 IM->OrFlag = n[5].ui;
3370 IM->AndFlag = n[6].ui;
3371 IM->LastData = n[7].ui;
3372 IM->LastPrimitive = n[8].ui;
3373
3374 if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
3375 (MESA_VERBOSE & VERBOSE_IMMEDIATE))
3376 gl_print_cassette( (struct immediate *) n[1].data );
3377
3378 if (0)
3379 fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x\n",
3380 IM->id,
3381 IM->Start, IM->Count, IM->BeginState);
3382
3383 gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
3384 gl_execute_cassette( ctx, (struct immediate *) n[1].data );
3385 break;
3386 }
3387 case OPCODE_ACCUM:
3388 (*ctx->Exec.Accum)( n[1].e, n[2].f );
3389 break;
3390 case OPCODE_ALPHA_FUNC:
3391 (*ctx->Exec.AlphaFunc)( n[1].e, n[2].f );
3392 break;
3393 case OPCODE_BIND_TEXTURE:
3394 (*ctx->Exec.BindTexture)( n[1].e, n[2].ui );
3395 break;
3396 case OPCODE_BITMAP:
3397 {
3398 struct gl_pixelstore_attrib save = ctx->Unpack;
3399 ctx->Unpack = _mesa_native_packing;
3400 (*ctx->Exec.Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
3401 n[3].f, n[4].f, n[5].f, n[6].f, n[7].data );
3402 ctx->Unpack = save; /* restore */
3403 }
3404 break;
3405 case OPCODE_BLEND_COLOR:
3406 (*ctx->Exec.BlendColorEXT)( n[1].f, n[2].f, n[3].f, n[4].f );
3407 break;
3408 case OPCODE_BLEND_EQUATION:
3409 (*ctx->Exec.BlendEquationEXT)( n[1].e );
3410 break;
3411 case OPCODE_BLEND_FUNC:
3412 (*ctx->Exec.BlendFunc)( n[1].e, n[2].e );
3413 break;
3414 case OPCODE_BLEND_FUNC_SEPARATE:
3415 (*ctx->Exec.BlendFuncSeparateINGR)(n[1].e, n[2].e, n[3].e, n[4].e);
3416 break;
3417 case OPCODE_CALL_LIST:
3418 /* Generated by glCallList(), don't add ListBase */
3419 if (ctx->CallDepth<MAX_LIST_NESTING) {
3420 execute_list( ctx, n[1].ui );
3421 }
3422 break;
3423 case OPCODE_CALL_LIST_OFFSET:
3424 /* Generated by glCallLists() so we must add ListBase */
3425 if (ctx->CallDepth<MAX_LIST_NESTING) {
3426 execute_list( ctx, ctx->List.ListBase + n[1].ui );
3427 }
3428 break;
3429 case OPCODE_CLEAR:
3430 (*ctx->Exec.Clear)( n[1].bf );
3431 break;
3432 case OPCODE_CLEAR_COLOR:
3433 (*ctx->Exec.ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f );
3434 break;
3435 case OPCODE_CLEAR_ACCUM:
3436 (*ctx->Exec.ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f );
3437 break;
3438 case OPCODE_CLEAR_DEPTH:
3439 (*ctx->Exec.ClearDepth)( (GLclampd) n[1].f );
3440 break;
3441 case OPCODE_CLEAR_INDEX:
3442 (*ctx->Exec.ClearIndex)( n[1].ui );
3443 break;
3444 case OPCODE_CLEAR_STENCIL:
3445 (*ctx->Exec.ClearStencil)( n[1].i );
3446 break;
3447 case OPCODE_CLIP_PLANE:
3448 {
3449 GLdouble eq[4];
3450 eq[0] = n[2].f;
3451 eq[1] = n[3].f;
3452 eq[2] = n[4].f;
3453 eq[3] = n[5].f;
3454 (*ctx->Exec.ClipPlane)( n[1].e, eq );
3455 }
3456 break;
3457 case OPCODE_COLOR_MASK:
3458 (*ctx->Exec.ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b );
3459 break;
3460 case OPCODE_COLOR_MATERIAL:
3461 (*ctx->Exec.ColorMaterial)( n[1].e, n[2].e );
3462 break;
3463 case OPCODE_COLOR_TABLE:
3464 {
3465 struct gl_pixelstore_attrib save = ctx->Unpack;
3466 ctx->Unpack = _mesa_native_packing;
3467 (*ctx->Exec.ColorTableEXT)( n[1].e, n[2].e, n[3].i, n[4].e,
3468 n[5].e, n[6].data );
3469 ctx->Unpack = save; /* restore */
3470 }
3471 break;
3472 case OPCODE_COLOR_SUB_TABLE:
3473 {
3474 struct gl_pixelstore_attrib save = ctx->Unpack;
3475 ctx->Unpack = _mesa_native_packing;
3476 (*ctx->Exec.ColorSubTableEXT)( n[1].e, n[2].i, n[3].i,
3477 n[4].e, n[5].e, n[6].data );
3478 ctx->Unpack = save; /* restore */
3479 }
3480 break;
3481 case OPCODE_COPY_PIXELS:
3482 (*ctx->Exec.CopyPixels)( n[1].i, n[2].i,
3483 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
3484 break;
3485 case OPCODE_COPY_TEX_IMAGE1D:
3486 (*ctx->Exec.CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i,
3487 n[5].i, n[6].i, n[7].i );
3488 break;
3489 case OPCODE_COPY_TEX_IMAGE2D:
3490 (*ctx->Exec.CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i,
3491 n[5].i, n[6].i, n[7].i, n[8].i );
3492 break;
3493 case OPCODE_COPY_TEX_SUB_IMAGE1D:
3494 (*ctx->Exec.CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i,
3495 n[4].i, n[5].i, n[6].i );
3496 break;
3497 case OPCODE_COPY_TEX_SUB_IMAGE2D:
3498 (*ctx->Exec.CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i,
3499 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i );
3500 break;
3501 case OPCODE_COPY_TEX_SUB_IMAGE3D:
3502 (*ctx->Exec.CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i,
3503 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
3504 break;
3505 case OPCODE_CULL_FACE:
3506 (*ctx->Exec.CullFace)( n[1].e );
3507 break;
3508 case OPCODE_DEPTH_FUNC:
3509 (*ctx->Exec.DepthFunc)( n[1].e );
3510 break;
3511 case OPCODE_DEPTH_MASK:
3512 (*ctx->Exec.DepthMask)( n[1].b );
3513 break;
3514 case OPCODE_DEPTH_RANGE:
3515 (*ctx->Exec.DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f );
3516 break;
3517 case OPCODE_DISABLE:
3518 (*ctx->Exec.Disable)( n[1].e );
3519 break;
3520 case OPCODE_DRAW_BUFFER:
3521 (*ctx->Exec.DrawBuffer)( n[1].e );
3522 break;
3523 case OPCODE_DRAW_PIXELS:
3524 {
3525 struct gl_pixelstore_attrib save = ctx->Unpack;
3526 ctx->Unpack = _mesa_native_packing;
3527 (*ctx->Exec.DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e,
3528 n[5].data );
3529 ctx->Unpack = save; /* restore */
3530 }
3531 break;
3532 case OPCODE_ENABLE:
3533 (*ctx->Exec.Enable)( n[1].e );
3534 break;
3535 case OPCODE_EVALMESH1:
3536 (*ctx->Exec.EvalMesh1)( n[1].e, n[2].i, n[3].i );
3537 break;
3538 case OPCODE_EVALMESH2:
3539 (*ctx->Exec.EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
3540 break;
3541 case OPCODE_FOG:
3542 {
3543 GLfloat p[4];
3544 p[0] = n[2].f;
3545 p[1] = n[3].f;
3546 p[2] = n[4].f;
3547 p[3] = n[5].f;
3548 (*ctx->Exec.Fogfv)( n[1].e, p );
3549 }
3550 break;
3551 case OPCODE_FRONT_FACE:
3552 (*ctx->Exec.FrontFace)( n[1].e );
3553 break;
3554 case OPCODE_FRUSTUM:
3555 (*ctx->Exec.Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
3556 break;
3557 case OPCODE_HINT:
3558 (*ctx->Exec.Hint)( n[1].e, n[2].e );
3559 break;
3560 case OPCODE_HINT_PGI:
3561 (*ctx->Exec.HintPGI)( n[1].e, n[2].i );
3562 break;
3563 case OPCODE_INDEX_MASK:
3564 (*ctx->Exec.IndexMask)( n[1].ui );
3565 break;
3566 case OPCODE_INIT_NAMES:
3567 (*ctx->Exec.InitNames)();
3568 break;
3569 case OPCODE_LIGHT:
3570 {
3571 GLfloat p[4];
3572 p[0] = n[3].f;
3573 p[1] = n[4].f;
3574 p[2] = n[5].f;
3575 p[3] = n[6].f;
3576 (*ctx->Exec.Lightfv)( n[1].e, n[2].e, p );
3577 }
3578 break;
3579 case OPCODE_LIGHT_MODEL:
3580 {
3581 GLfloat p[4];
3582 p[0] = n[2].f;
3583 p[1] = n[3].f;
3584 p[2] = n[4].f;
3585 p[3] = n[5].f;
3586 (*ctx->Exec.LightModelfv)( n[1].e, p );
3587 }
3588 break;
3589 case OPCODE_LINE_STIPPLE:
3590 (*ctx->Exec.LineStipple)( n[1].i, n[2].us );
3591 break;
3592 case OPCODE_LINE_WIDTH:
3593 (*ctx->Exec.LineWidth)( n[1].f );
3594 break;
3595 case OPCODE_LIST_BASE:
3596 (*ctx->Exec.ListBase)( n[1].ui );
3597 break;
3598 case OPCODE_LOAD_IDENTITY:
3599 (*ctx->Exec.LoadIdentity)();
3600 break;
3601 case OPCODE_LOAD_MATRIX:
3602 if (sizeof(Node)==sizeof(GLfloat)) {
3603 (*ctx->Exec.LoadMatrixf)( &n[1].f );
3604 }
3605 else {
3606 GLfloat m[16];
3607 GLuint i;
3608 for (i=0;i<16;i++) {
3609 m[i] = n[1+i].f;
3610 }
3611 (*ctx->Exec.LoadMatrixf)( m );
3612 }
3613 break;
3614 case OPCODE_LOAD_NAME:
3615 (*ctx->Exec.LoadName)( n[1].ui );
3616 break;
3617 case OPCODE_LOGIC_OP:
3618 (*ctx->Exec.LogicOp)( n[1].e );
3619 break;
3620 case OPCODE_MAP1:
3621 {
3622 GLenum target = n[1].e;
3623 GLint ustride = _mesa_evaluator_components(target);
3624 GLint uorder = n[5].i;
3625 GLfloat u1 = n[2].f;
3626 GLfloat u2 = n[3].f;
3627 (*ctx->Exec.Map1f)( target, u1, u2, ustride, uorder,
3628 (GLfloat *) n[6].data );
3629 }
3630 break;
3631 case OPCODE_MAP2:
3632 {
3633 GLenum target = n[1].e;
3634 GLfloat u1 = n[2].f;
3635 GLfloat u2 = n[3].f;
3636 GLfloat v1 = n[4].f;
3637 GLfloat v2 = n[5].f;
3638 GLint ustride = n[6].i;
3639 GLint vstride = n[7].i;
3640 GLint uorder = n[8].i;
3641 GLint vorder = n[9].i;
3642 (*ctx->Exec.Map2f)( target, u1, u2, ustride, uorder,
3643 v1, v2, vstride, vorder,
3644 (GLfloat *) n[10].data );
3645 }
3646 break;
3647 case OPCODE_MAPGRID1:
3648 (*ctx->Exec.MapGrid1f)( n[1].i, n[2].f, n[3].f );
3649 break;
3650 case OPCODE_MAPGRID2:
3651 (*ctx->Exec.MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
3652 break;
3653 case OPCODE_MATRIX_MODE:
3654 (*ctx->Exec.MatrixMode)( n[1].e );
3655 break;
3656 case OPCODE_MULT_MATRIX:
3657 if (sizeof(Node)==sizeof(GLfloat)) {
3658 (*ctx->Exec.MultMatrixf)( &n[1].f );
3659 }
3660 else {
3661 GLfloat m[16];
3662 GLuint i;
3663 for (i=0;i<16;i++) {
3664 m[i] = n[1+i].f;
3665 }
3666 (*ctx->Exec.MultMatrixf)( m );
3667 }
3668 break;
3669 case OPCODE_ORTHO:
3670 (*ctx->Exec.Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
3671 break;
3672 case OPCODE_PASSTHROUGH:
3673 (*ctx->Exec.PassThrough)( n[1].f );
3674 break;
3675 case OPCODE_PIXEL_MAP:
3676 (*ctx->Exec.PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data );
3677 break;
3678 case OPCODE_PIXEL_TRANSFER:
3679 (*ctx->Exec.PixelTransferf)( n[1].e, n[2].f );
3680 break;
3681 case OPCODE_PIXEL_ZOOM:
3682 (*ctx->Exec.PixelZoom)( n[1].f, n[2].f );
3683 break;
3684 case OPCODE_POINT_SIZE:
3685 (*ctx->Exec.PointSize)( n[1].f );
3686 break;
3687 case OPCODE_POINT_PARAMETERS:
3688 {
3689 GLfloat params[3];
3690 params[0] = n[2].f;
3691 params[1] = n[3].f;
3692 params[2] = n[4].f;
3693 (*ctx->Exec.PointParameterfvEXT)( n[1].e, params );
3694 }
3695 break;
3696 case OPCODE_POLYGON_MODE:
3697 (*ctx->Exec.PolygonMode)( n[1].e, n[2].e );
3698 break;
3699 case OPCODE_POLYGON_STIPPLE:
3700 (*ctx->Exec.PolygonStipple)( (GLubyte *) n[1].data );
3701 break;
3702 case OPCODE_POLYGON_OFFSET:
3703 (*ctx->Exec.PolygonOffset)( n[1].f, n[2].f );
3704 break;
3705 case OPCODE_POP_ATTRIB:
3706 (*ctx->Exec.PopAttrib)();
3707 break;
3708 case OPCODE_POP_MATRIX:
3709 (*ctx->Exec.PopMatrix)();
3710 break;
3711 case OPCODE_POP_NAME:
3712 (*ctx->Exec.PopName)();
3713 break;
3714 case OPCODE_PRIORITIZE_TEXTURE:
3715 (*ctx->Exec.PrioritizeTextures)( 1, &n[1].ui, &n[2].f );
3716 break;
3717 case OPCODE_PUSH_ATTRIB:
3718 (*ctx->Exec.PushAttrib)( n[1].bf );
3719 break;
3720 case OPCODE_PUSH_MATRIX:
3721 (*ctx->Exec.PushMatrix)();
3722 break;
3723 case OPCODE_PUSH_NAME:
3724 (*ctx->Exec.PushName)( n[1].ui );
3725 break;
3726 case OPCODE_RASTER_POS:
3727 (*ctx->Exec.RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f );
3728 break;
3729 case OPCODE_READ_BUFFER:
3730 (*ctx->Exec.ReadBuffer)( n[1].e );
3731 break;
3732 case OPCODE_RECTF:
3733 (*ctx->Exec.Rectf)( n[1].f, n[2].f, n[3].f, n[4].f );
3734 break;
3735 case OPCODE_SCALE:
3736 (*ctx->Exec.Scalef)( n[1].f, n[2].f, n[3].f );
3737 break;
3738 case OPCODE_SCISSOR:
3739 (*ctx->Exec.Scissor)( n[1].i, n[2].i, n[3].i, n[4].i );
3740 break;
3741 case OPCODE_SHADE_MODEL:
3742 (*ctx->Exec.ShadeModel)( n[1].e );
3743 break;
3744 case OPCODE_STENCIL_FUNC:
3745 (*ctx->Exec.StencilFunc)( n[1].e, n[2].i, n[3].ui );
3746 break;
3747 case OPCODE_STENCIL_MASK:
3748 (*ctx->Exec.StencilMask)( n[1].ui );
3749 break;
3750 case OPCODE_STENCIL_OP:
3751 (*ctx->Exec.StencilOp)( n[1].e, n[2].e, n[3].e );
3752 break;
3753 case OPCODE_TEXENV:
3754 {
3755 GLfloat params[4];
3756 params[0] = n[3].f;
3757 params[1] = n[4].f;
3758 params[2] = n[5].f;
3759 params[3] = n[6].f;
3760 (*ctx->Exec.TexEnvfv)( n[1].e, n[2].e, params );
3761 }
3762 break;
3763 case OPCODE_TEXGEN:
3764 {
3765 GLfloat params[4];
3766 params[0] = n[3].f;
3767 params[1] = n[4].f;
3768 params[2] = n[5].f;
3769 params[3] = n[6].f;
3770 (*ctx->Exec.TexGenfv)( n[1].e, n[2].e, params );
3771 }
3772 break;
3773 case OPCODE_TEXPARAMETER:
3774 {
3775 GLfloat params[4];
3776 params[0] = n[3].f;
3777 params[1] = n[4].f;
3778 params[2] = n[5].f;
3779 params[3] = n[6].f;
3780 (*ctx->Exec.TexParameterfv)( n[1].e, n[2].e, params );
3781 }
3782 break;
3783 case OPCODE_TEX_IMAGE1D:
3784 {
3785 struct gl_pixelstore_attrib save = ctx->Unpack;
3786 ctx->Unpack = _mesa_native_packing;
3787 (*ctx->Exec.TexImage1D)(
3788 n[1].e, /* target */
3789 n[2].i, /* level */
3790 n[3].i, /* components */
3791 n[4].i, /* width */
3792 n[5].e, /* border */
3793 n[6].e, /* format */
3794 n[7].e, /* type */
3795 n[8].data );
3796 ctx->Unpack = save; /* restore */
3797 }
3798 break;
3799 case OPCODE_TEX_IMAGE2D:
3800 {
3801 struct gl_pixelstore_attrib save = ctx->Unpack;
3802 ctx->Unpack = _mesa_native_packing;
3803 (*ctx->Exec.TexImage2D)(
3804 n[1].e, /* target */
3805 n[2].i, /* level */
3806 n[3].i, /* components */
3807 n[4].i, /* width */
3808 n[5].i, /* height */
3809 n[6].e, /* border */
3810 n[7].e, /* format */
3811 n[8].e, /* type */
3812 n[9].data );
3813 ctx->Unpack = save; /* restore */
3814 }
3815 break;
3816 case OPCODE_TEX_IMAGE3D:
3817 {
3818 struct gl_pixelstore_attrib save = ctx->Unpack;
3819 ctx->Unpack = _mesa_native_packing;
3820 (*ctx->Exec.TexImage3D)(
3821 n[1].e, /* target */
3822 n[2].i, /* level */
3823 n[3].i, /* components */
3824 n[4].i, /* width */
3825 n[5].i, /* height */
3826 n[6].i, /* depth */
3827 n[7].e, /* border */
3828 n[8].e, /* format */
3829 n[9].e, /* type */
3830 n[10].data );
3831 ctx->Unpack = save; /* restore */
3832 }
3833 break;
3834 case OPCODE_TEX_SUB_IMAGE1D:
3835 {
3836 struct gl_pixelstore_attrib save = ctx->Unpack;
3837 ctx->Unpack = _mesa_native_packing;
3838 (*ctx->Exec.TexSubImage1D)( n[1].e, n[2].i, n[3].i,
3839 n[4].i, n[5].e,
3840 n[6].e, n[7].data );
3841 ctx->Unpack = save; /* restore */
3842 }
3843 break;
3844 case OPCODE_TEX_SUB_IMAGE2D:
3845 {
3846 struct gl_pixelstore_attrib save = ctx->Unpack;
3847 ctx->Unpack = _mesa_native_packing;
3848 (*ctx->Exec.TexSubImage2D)( n[1].e, n[2].i, n[3].i,
3849 n[4].i, n[5].e,
3850 n[6].i, n[7].e, n[8].e, n[9].data );
3851 ctx->Unpack = save; /* restore */
3852 }
3853 break;
3854 case OPCODE_TEX_SUB_IMAGE3D:
3855 {
3856 struct gl_pixelstore_attrib save = ctx->Unpack;
3857 ctx->Unpack = _mesa_native_packing;
3858 (*ctx->Exec.TexSubImage3D)( n[1].e, n[2].i, n[3].i,
3859 n[4].i, n[5].i, n[6].i, n[7].i,
3860 n[8].i, n[9].e, n[10].e,
3861 n[11].data );
3862 ctx->Unpack = save; /* restore */
3863 }
3864 break;
3865 case OPCODE_TRANSLATE:
3866 (*ctx->Exec.Translatef)( n[1].f, n[2].f, n[3].f );
3867 break;
3868 case OPCODE_VIEWPORT:
3869 (*ctx->Exec.Viewport)(n[1].i, n[2].i,
3870 (GLsizei) n[3].i, (GLsizei) n[4].i);
3871 break;
3872 case OPCODE_WINDOW_POS:
3873 (*ctx->Exec.WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f );
3874 break;
3875 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
3876 (*ctx->Exec.ActiveTextureARB)( n[1].e );
3877 break;
3878 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
3879 (*ctx->Exec.ClientActiveTextureARB)( n[1].e );
3880 break;
3881 case OPCODE_CONTINUE:
3882 n = (Node *) n[1].next;
3883 break;
3884 case OPCODE_END_OF_LIST:
3885 done = GL_TRUE;
3886 break;
3887 default:
3888 {
3889 char msg[1000];
3890 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
3891 gl_problem( ctx, msg );
3892 }
3893 done = GL_TRUE;
3894 }
3895
3896 /* increment n to point to next compiled command */
3897 if (opcode!=OPCODE_CONTINUE) {
3898 n += InstSize[opcode];
3899 }
3900
3901 }
3902 ctx->CallDepth--;
3903 }
3904
3905
3906
3907
3908
3909 /**********************************************************************/
3910 /* GL functions */
3911 /**********************************************************************/
3912
3913
3914
3915
3916 /*
3917 * Test if a display list number is valid.
3918 */
3919 GLboolean
3920 _mesa_IsList( GLuint list )
3921 {
3922 GET_CURRENT_CONTEXT(ctx);
3923 return islist(ctx, list);
3924 }
3925
3926
3927 /*
3928 * Delete a sequence of consecutive display lists.
3929 */
3930 void
3931 _mesa_DeleteLists( GLuint list, GLsizei range )
3932 {
3933 GET_CURRENT_CONTEXT(ctx);
3934 GLuint i;
3935
3936 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists");
3937 if (range<0) {
3938 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
3939 return;
3940 }
3941 for (i=list;i<list+range;i++) {
3942 gl_destroy_list( ctx, i );
3943 }
3944 }
3945
3946
3947
3948 /*
3949 * Return a display list number, n, such that lists n through n+range-1
3950 * are free.
3951 */
3952 GLuint
3953 _mesa_GenLists(GLsizei range )
3954 {
3955 GET_CURRENT_CONTEXT(ctx);
3956 GLuint base;
3957
3958 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0);
3959 if (range<0) {
3960 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
3961 return 0;
3962 }
3963 if (range==0) {
3964 return 0;
3965 }
3966
3967 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
3968 if (base) {
3969 /* reserve the list IDs by with empty/dummy lists */
3970 GLint i;
3971 for (i=0; i<range; i++) {
3972 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
3973 }
3974 }
3975 return base;
3976 }
3977
3978
3979
3980 /*
3981 * Begin a new display list.
3982 */
3983 void
3984 _mesa_NewList( GLuint list, GLenum mode )
3985 {
3986 GET_CURRENT_CONTEXT(ctx);
3987 struct immediate *IM;
3988 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");
3989
3990 if (MESA_VERBOSE&VERBOSE_API)
3991 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
3992
3993 if (list==0) {
3994 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
3995 return;
3996 }
3997
3998 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
3999 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
4000 return;
4001 }
4002
4003 if (ctx->CurrentListPtr) {
4004 /* already compiling a display list */
4005 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
4006 return;
4007 }
4008
4009 /* Allocate new display list */
4010 ctx->CurrentListNum = list;
4011 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
4012 ctx->CurrentListPtr = ctx->CurrentBlock;
4013 ctx->CurrentPos = 0;
4014
4015 IM = gl_immediate_alloc( ctx );
4016 SET_IMMEDIATE( ctx, IM );
4017 gl_reset_input( ctx );
4018
4019 ctx->CompileFlag = GL_TRUE;
4020 ctx->CompileCVAFlag = GL_FALSE;
4021 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
4022
4023 ctx->CurrentDispatch = &ctx->Save;
4024 _glapi_set_dispatch( ctx->CurrentDispatch );
4025 }
4026
4027
4028
4029 /*
4030 * End definition of current display list.
4031 */
4032 void
4033 _mesa_EndList( void )
4034 {
4035 GET_CURRENT_CONTEXT(ctx);
4036 if (MESA_VERBOSE&VERBOSE_API)
4037 fprintf(stderr, "glEndList\n");
4038
4039 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );
4040
4041 /* Check that a list is under construction */
4042 if (!ctx->CurrentListPtr) {
4043 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
4044 return;
4045 }
4046
4047 (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
4048
4049 /* Destroy old list, if any */
4050 gl_destroy_list(ctx, ctx->CurrentListNum);
4051 /* Install the list */
4052 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
4053
4054
4055 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
4056 mesa_print_display_list(ctx->CurrentListNum);
4057
4058 ctx->CurrentListNum = 0;
4059 ctx->CurrentListPtr = NULL;
4060 ctx->ExecuteFlag = GL_TRUE;
4061 ctx->CompileFlag = GL_FALSE;
4062 /* ctx->CompileCVAFlag = ...; */
4063
4064 /* KW: Put back the old input pointer.
4065 */
4066 if (--ctx->input->ref_count == 0)
4067 gl_immediate_free( ctx->input );
4068
4069 SET_IMMEDIATE( ctx, ctx->VB->IM );
4070 gl_reset_input( ctx );
4071
4072 /* Haven't tracked down why this is needed.
4073 */
4074 ctx->NewState = ~0;
4075
4076 ctx->CurrentDispatch = &ctx->Exec;
4077 _glapi_set_dispatch( ctx->CurrentDispatch );
4078 }
4079
4080
4081
4082 void
4083 _mesa_CallList( GLuint list )
4084 {
4085 GET_CURRENT_CONTEXT(ctx);
4086 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
4087 /* execute the display list, and restore the CompileFlag. */
4088 GLboolean save_compile_flag;
4089
4090 if (MESA_VERBOSE&VERBOSE_API) {
4091 fprintf(stderr, "glCallList %u\n", list);
4092 mesa_print_display_list( list );
4093 }
4094
4095 save_compile_flag = ctx->CompileFlag;
4096 ctx->CompileFlag = GL_FALSE;
4097
4098 FLUSH_VB( ctx, "call list" );
4099 execute_list( ctx, list );
4100 ctx->CompileFlag = save_compile_flag;
4101
4102 /* also restore API function pointers to point to "save" versions */
4103 if (save_compile_flag) {
4104 ctx->CurrentDispatch = &ctx->Save;
4105 _glapi_set_dispatch( ctx->CurrentDispatch );
4106 }
4107 }
4108
4109
4110
4111 /*
4112 * Execute glCallLists: call multiple display lists.
4113 */
4114 void
4115 _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
4116 {
4117 GET_CURRENT_CONTEXT(ctx);
4118 GLuint list;
4119 GLint i;
4120 GLboolean save_compile_flag;
4121
4122 /* Save the CompileFlag status, turn it off, execute display list,
4123 * and restore the CompileFlag.
4124 */
4125 save_compile_flag = ctx->CompileFlag;
4126 ctx->CompileFlag = GL_FALSE;
4127
4128 FLUSH_VB( ctx, "call lists" );
4129
4130 for (i=0;i<n;i++) {
4131 list = translate_id( i, type, lists );
4132 execute_list( ctx, ctx->List.ListBase + list );
4133 }
4134
4135 ctx->CompileFlag = save_compile_flag;
4136
4137 /* also restore API function pointers to point to "save" versions */
4138 if (save_compile_flag) {
4139 ctx->CurrentDispatch = &ctx->Save;
4140 _glapi_set_dispatch( ctx->CurrentDispatch );
4141 }
4142
4143 /* RESET_IMMEDIATE( ctx ); */
4144 }
4145
4146
4147
4148 /*
4149 * Set the offset added to list numbers in glCallLists.
4150 */
4151 void
4152 _mesa_ListBase( GLuint base )
4153 {
4154 GET_CURRENT_CONTEXT(ctx);
4155 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase");
4156 ctx->List.ListBase = base;
4157 }
4158
4159
4160
4161
4162 /*
4163 * Assign all the pointers in 'table' to point to Mesa's display list
4164 * building functions.
4165 */
4166 void
4167 _mesa_init_dlist_table( struct _glapi_table *table )
4168 {
4169 _mesa_init_no_op_table(table);
4170
4171 /* GL 1.0 */
4172 table->Accum = save_Accum;
4173 table->AlphaFunc = save_AlphaFunc;
4174 table->Begin = save_Begin;
4175 table->Bitmap = save_Bitmap;
4176 table->BlendFunc = save_BlendFunc;
4177 table->CallList = save_CallList;
4178 table->CallLists = save_CallLists;
4179 table->Clear = save_Clear;
4180 table->ClearAccum = save_ClearAccum;
4181 table->ClearColor = save_ClearColor;
4182 table->ClearDepth = save_ClearDepth;
4183 table->ClearIndex = save_ClearIndex;
4184 table->ClearStencil = save_ClearStencil;
4185 table->ClipPlane = save_ClipPlane;
4186 table->Color3b = _mesa_Color3b;
4187 table->Color3bv = _mesa_Color3bv;
4188 table->Color3d = _mesa_Color3d;
4189 table->Color3dv = _mesa_Color3dv;
4190 table->Color3f = _mesa_Color3f;
4191 table->Color3fv = _mesa_Color3fv;
4192 table->Color3i = _mesa_Color3i;
4193 table->Color3iv = _mesa_Color3iv;
4194 table->Color3s = _mesa_Color3s;
4195 table->Color3sv = _mesa_Color3sv;
4196 table->Color3ub = _mesa_Color3ub;
4197 table->Color3ubv = _mesa_Color3ubv;
4198 table->Color3ui = _mesa_Color3ui;
4199 table->Color3uiv = _mesa_Color3uiv;
4200 table->Color3us = _mesa_Color3us;
4201 table->Color3usv = _mesa_Color3usv;
4202 table->Color4b = _mesa_Color4b;
4203 table->Color4bv = _mesa_Color4bv;
4204 table->Color4d = _mesa_Color4d;
4205 table->Color4dv = _mesa_Color4dv;
4206 table->Color4f = _mesa_Color4f;
4207 table->Color4fv = _mesa_Color4fv;
4208 table->Color4i = _mesa_Color4i;
4209 table->Color4iv = _mesa_Color4iv;
4210 table->Color4s = _mesa_Color4s;
4211 table->Color4sv = _mesa_Color4sv;
4212 table->Color4ub = _mesa_Color4ub;
4213 table->Color4ubv = _mesa_Color4ubv;
4214 table->Color4ui = _mesa_Color4ui;
4215 table->Color4uiv = _mesa_Color4uiv;
4216 table->Color4us = _mesa_Color4us;
4217 table->Color4usv = _mesa_Color4usv;
4218 table->ColorMask = save_ColorMask;
4219 table->ColorMaterial = save_ColorMaterial;
4220 table->CopyPixels = save_CopyPixels;
4221 table->CullFace = save_CullFace;
4222 table->DeleteLists = _mesa_DeleteLists;
4223 table->DepthFunc = save_DepthFunc;
4224 table->DepthMask = save_DepthMask;
4225 table->DepthRange = save_DepthRange;
4226 table->Disable = save_Disable;
4227 table->DrawBuffer = save_DrawBuffer;
4228 table->DrawPixels = save_DrawPixels;
4229 table->EdgeFlag = _mesa_EdgeFlag;
4230 table->EdgeFlagv = _mesa_EdgeFlagv;
4231 table->Enable = save_Enable;
4232 table->End = _mesa_End;
4233 table->EndList = _mesa_EndList;
4234 table->EvalCoord1d = _mesa_EvalCoord1d;
4235 table->EvalCoord1dv = _mesa_EvalCoord1dv;
4236 table->EvalCoord1f = _mesa_EvalCoord1f;
4237 table->EvalCoord1fv = _mesa_EvalCoord1fv;
4238 table->EvalCoord2d = _mesa_EvalCoord2d;
4239 table->EvalCoord2dv = _mesa_EvalCoord2dv;
4240 table->EvalCoord2f = _mesa_EvalCoord2f;
4241 table->EvalCoord2fv = _mesa_EvalCoord2fv;
4242 table->EvalMesh1 = save_EvalMesh1;
4243 table->EvalMesh2 = save_EvalMesh2;
4244 table->EvalPoint1 = _mesa_EvalPoint1;
4245 table->EvalPoint2 = _mesa_EvalPoint2;
4246 table->FeedbackBuffer = _mesa_FeedbackBuffer;
4247 table->Finish = _mesa_Finish;
4248 table->Flush = _mesa_Flush;
4249 table->Fogf = save_Fogf;
4250 table->Fogfv = save_Fogfv;
4251 table->Fogi = save_Fogi;
4252 table->Fogiv = save_Fogiv;
4253 table->FrontFace = save_FrontFace;
4254 table->Frustum = save_Frustum;
4255 table->GenLists = _mesa_GenLists;
4256 table->GetBooleanv = _mesa_GetBooleanv;
4257 table->GetClipPlane = _mesa_GetClipPlane;
4258 table->GetDoublev = _mesa_GetDoublev;
4259 table->GetError = _mesa_GetError;
4260 table->GetFloatv = _mesa_GetFloatv;
4261 table->GetIntegerv = _mesa_GetIntegerv;
4262 table->GetLightfv = _mesa_GetLightfv;
4263 table->GetLightiv = _mesa_GetLightiv;
4264 table->GetMapdv = _mesa_GetMapdv;
4265 table->GetMapfv = _mesa_GetMapfv;
4266 table->GetMapiv = _mesa_GetMapiv;
4267 table->GetMaterialfv = _mesa_GetMaterialfv;
4268 table->GetMaterialiv = _mesa_GetMaterialiv;
4269 table->GetPixelMapfv = _mesa_GetPixelMapfv;
4270 table->GetPixelMapuiv = _mesa_GetPixelMapuiv;
4271 table->GetPixelMapusv = _mesa_GetPixelMapusv;
4272 table->GetPolygonStipple = _mesa_GetPolygonStipple;
4273 table->GetString = _mesa_GetString;
4274 table->GetTexEnvfv = _mesa_GetTexEnvfv;
4275 table->GetTexEnviv = _mesa_GetTexEnviv;
4276 table->GetTexGendv = _mesa_GetTexGendv;
4277 table->GetTexGenfv = _mesa_GetTexGenfv;
4278 table->GetTexGeniv = _mesa_GetTexGeniv;
4279 table->GetTexImage = _mesa_GetTexImage;
4280 table->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv;
4281 table->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv;
4282 table->GetTexParameterfv = _mesa_GetTexParameterfv;
4283 table->GetTexParameteriv = _mesa_GetTexParameteriv;
4284 table->Hint = save_Hint;
4285 table->IndexMask = save_IndexMask;
4286 table->Indexd = _mesa_Indexd;
4287 table->Indexdv = _mesa_Indexdv;
4288 table->Indexf = _mesa_Indexf;
4289 table->Indexfv = _mesa_Indexfv;
4290 table->Indexi = _mesa_Indexi;
4291 table->Indexiv = _mesa_Indexiv;
4292 table->Indexs = _mesa_Indexs;
4293 table->Indexsv = _mesa_Indexsv;
4294 table->InitNames = save_InitNames;
4295 table->IsEnabled = _mesa_IsEnabled;
4296 table->IsList = _mesa_IsList;
4297 table->LightModelf = save_LightModelf;
4298 table->LightModelfv = save_LightModelfv;
4299 table->LightModeli = save_LightModeli;
4300 table->LightModeliv = save_LightModeliv;
4301 table->Lightf = save_Lightf;
4302 table->Lightfv = save_Lightfv;
4303 table->Lighti = save_Lighti;
4304 table->Lightiv = save_Lightiv;
4305 table->LineStipple = save_LineStipple;
4306 table->LineWidth = save_LineWidth;
4307 table->ListBase = save_ListBase;
4308 table->LoadIdentity = save_LoadIdentity;
4309 table->LoadMatrixd = save_LoadMatrixd;
4310 table->LoadMatrixf = save_LoadMatrixf;
4311 table->LoadName = save_LoadName;
4312 table->LogicOp = save_LogicOp;
4313 table->Map1d = save_Map1d;
4314 table->Map1f = save_Map1f;
4315 table->Map2d = save_Map2d;
4316 table->Map2f = save_Map2f;
4317 table->MapGrid1d = save_MapGrid1d;
4318 table->MapGrid1f = save_MapGrid1f;
4319 table->MapGrid2d = save_MapGrid2d;
4320 table->MapGrid2f = save_MapGrid2f;
4321 table->Materialf = _mesa_Materialf;
4322 table->Materialfv = _mesa_Materialfv;
4323 table->Materiali = _mesa_Materiali;
4324 table->Materialiv = _mesa_Materialiv;
4325 table->MatrixMode = save_MatrixMode;
4326 table->MultMatrixd = save_MultMatrixd;
4327 table->MultMatrixf = save_MultMatrixf;
4328 table->NewList = save_NewList;
4329 table->Normal3b = _mesa_Normal3b;
4330 table->Normal3bv = _mesa_Normal3bv;
4331 table->Normal3d = _mesa_Normal3d;
4332 table->Normal3dv = _mesa_Normal3dv;
4333 table->Normal3f = _mesa_Normal3f;
4334 table->Normal3fv = _mesa_Normal3fv;
4335 table->Normal3i = _mesa_Normal3i;
4336 table->Normal3iv = _mesa_Normal3iv;
4337 table->Normal3s = _mesa_Normal3s;
4338 table->Normal3sv = _mesa_Normal3sv;
4339 table->Ortho = save_Ortho;
4340 table->PassThrough = save_PassThrough;
4341 table->PixelMapfv = save_PixelMapfv;
4342 table->PixelMapuiv = save_PixelMapuiv;
4343 table->PixelMapusv = save_PixelMapusv;
4344 table->PixelStoref = _mesa_PixelStoref;
4345 table->PixelStorei = _mesa_PixelStorei;
4346 table->PixelTransferf = save_PixelTransferf;
4347 table->PixelTransferi = save_PixelTransferi;
4348 table->PixelZoom = save_PixelZoom;
4349 table->PointSize = save_PointSize;
4350 table->PolygonMode = save_PolygonMode;
4351 table->PolygonOffset = save_PolygonOffset;
4352 table->PolygonStipple = save_PolygonStipple;
4353 table->PopAttrib = save_PopAttrib;
4354 table->PopMatrix = save_PopMatrix;
4355 table->PopName = save_PopName;
4356 table->PushAttrib = save_PushAttrib;
4357 table->PushMatrix = save_PushMatrix;
4358 table->PushName = save_PushName;
4359 table->RasterPos2d = save_RasterPos2d;
4360 table->RasterPos2dv = save_RasterPos2dv;
4361 table->RasterPos2f = save_RasterPos2f;
4362 table->RasterPos2fv = save_RasterPos2fv;
4363 table->RasterPos2i = save_RasterPos2i;
4364 table->RasterPos2iv = save_RasterPos2iv;
4365 table->RasterPos2s = save_RasterPos2s;
4366 table->RasterPos2sv = save_RasterPos2sv;
4367 table->RasterPos3d = save_RasterPos3d;
4368 table->RasterPos3dv = save_RasterPos3dv;
4369 table->RasterPos3f = save_RasterPos3f;
4370 table->RasterPos3fv = save_RasterPos3fv;
4371 table->RasterPos3i = save_RasterPos3i;
4372 table->RasterPos3iv = save_RasterPos3iv;
4373 table->RasterPos3s = save_RasterPos3s;
4374 table->RasterPos3sv = save_RasterPos3sv;
4375 table->RasterPos4d = save_RasterPos4d;
4376 table->RasterPos4dv = save_RasterPos4dv;
4377 table->RasterPos4f = save_RasterPos4f;
4378 table->RasterPos4fv = save_RasterPos4fv;
4379 table->RasterPos4i = save_RasterPos4i;
4380 table->RasterPos4iv = save_RasterPos4iv;
4381 table->RasterPos4s = save_RasterPos4s;
4382 table->RasterPos4sv = save_RasterPos4sv;
4383 table->ReadBuffer = save_ReadBuffer;
4384 table->ReadPixels = _mesa_ReadPixels;
4385 table->Rectd = save_Rectd;
4386 table->Rectdv = save_Rectdv;
4387 table->Rectf = save_Rectf;
4388 table->Rectfv = save_Rectfv;
4389 table->Recti = save_Recti;
4390 table->Rectiv = save_Rectiv;
4391 table->Rects = save_Rects;
4392 table->Rectsv = save_Rectsv;
4393 table->RenderMode = _mesa_RenderMode;
4394 table->Rotated = save_Rotated;
4395 table->Rotatef = save_Rotatef;
4396 table->Scaled = save_Scaled;
4397 table->Scalef = save_Scalef;
4398 table->Scissor = save_Scissor;
4399 table->SelectBuffer = _mesa_SelectBuffer;
4400 table->ShadeModel = save_ShadeModel;
4401 table->StencilFunc = save_StencilFunc;
4402 table->StencilMask = save_StencilMask;
4403 table->StencilOp = save_StencilOp;
4404 table->TexCoord1d = _mesa_TexCoord1d;
4405 table->TexCoord1dv = _mesa_TexCoord1dv;
4406 table->TexCoord1f = _mesa_TexCoord1f;
4407 table->TexCoord1fv = _mesa_TexCoord1fv;
4408 table->TexCoord1i = _mesa_TexCoord1i;
4409 table->TexCoord1iv = _mesa_TexCoord1iv;
4410 table->TexCoord1s = _mesa_TexCoord1s;
4411 table->TexCoord1sv = _mesa_TexCoord1sv;
4412 table->TexCoord2d = _mesa_TexCoord2d;
4413 table->TexCoord2dv = _mesa_TexCoord2dv;
4414 table->TexCoord2f = _mesa_TexCoord2f;
4415 table->TexCoord2fv = _mesa_TexCoord2fv;
4416 table->TexCoord2i = _mesa_TexCoord2i;
4417 table->TexCoord2iv = _mesa_TexCoord2iv;
4418 table->TexCoord2s = _mesa_TexCoord2s;
4419 table->TexCoord2sv = _mesa_TexCoord2sv;
4420 table->TexCoord3d = _mesa_TexCoord3d;
4421 table->TexCoord3dv = _mesa_TexCoord3dv;
4422 table->TexCoord3f = _mesa_TexCoord3f;
4423 table->TexCoord3fv = _mesa_TexCoord3fv;
4424 table->TexCoord3i = _mesa_TexCoord3i;
4425 table->TexCoord3iv = _mesa_TexCoord3iv;
4426 table->TexCoord3s = _mesa_TexCoord3s;
4427 table->TexCoord3sv = _mesa_TexCoord3sv;
4428 table->TexCoord4d = _mesa_TexCoord4d;
4429 table->TexCoord4dv = _mesa_TexCoord4dv;
4430 table->TexCoord4f = _mesa_TexCoord4f;
4431 table->TexCoord4fv = _mesa_TexCoord4fv;
4432 table->TexCoord4i = _mesa_TexCoord4i;
4433 table->TexCoord4iv = _mesa_TexCoord4iv;
4434 table->TexCoord4s = _mesa_TexCoord4s;
4435 table->TexCoord4sv = _mesa_TexCoord4sv;
4436 table->TexEnvf = save_TexEnvf;
4437 table->TexEnvfv = save_TexEnvfv;
4438 table->TexEnvi = save_TexEnvi;
4439 table->TexEnviv = save_TexEnviv;
4440 table->TexGend = save_TexGend;
4441 table->TexGendv = save_TexGendv;
4442 table->TexGenf = save_TexGenf;
4443 table->TexGenfv = save_TexGenfv;
4444 table->TexGeni = save_TexGeni;
4445 table->TexGeniv = save_TexGeniv;
4446 table->TexImage1D = save_TexImage1D;
4447 table->TexImage2D = save_TexImage2D;
4448 table->TexParameterf = save_TexParameterf;
4449 table->TexParameterfv = save_TexParameterfv;
4450 table->TexParameteri = save_TexParameteri;
4451 table->TexParameteriv = save_TexParameteriv;
4452 table->Translated = save_Translated;
4453 table->Translatef = save_Translatef;
4454 table->Vertex2d = _mesa_Vertex2d;
4455 table->Vertex2dv = _mesa_Vertex2dv;
4456 table->Vertex2f = _mesa_Vertex2f;
4457 table->Vertex2fv = _mesa_Vertex2fv;
4458 table->Vertex2i = _mesa_Vertex2i;
4459 table->Vertex2iv = _mesa_Vertex2iv;
4460 table->Vertex2s = _mesa_Vertex2s;
4461 table->Vertex2sv = _mesa_Vertex2sv;
4462 table->Vertex3d = _mesa_Vertex3d;
4463 table->Vertex3dv = _mesa_Vertex3dv;
4464 table->Vertex3f = _mesa_Vertex3f;
4465 table->Vertex3fv = _mesa_Vertex3fv;
4466 table->Vertex3i = _mesa_Vertex3i;
4467 table->Vertex3iv = _mesa_Vertex3iv;
4468 table->Vertex3s = _mesa_Vertex3s;
4469 table->Vertex3sv = _mesa_Vertex3sv;
4470 table->Vertex4d = _mesa_Vertex4d;
4471 table->Vertex4dv = _mesa_Vertex4dv;
4472 table->Vertex4f = _mesa_Vertex4f;
4473 table->Vertex4fv = _mesa_Vertex4fv;
4474 table->Vertex4i = _mesa_Vertex4i;
4475 table->Vertex4iv = _mesa_Vertex4iv;
4476 table->Vertex4s = _mesa_Vertex4s;
4477 table->Vertex4sv = _mesa_Vertex4sv;
4478 table->Viewport = save_Viewport;
4479
4480 /* GL 1.1 */
4481 table->AreTexturesResident = _mesa_AreTexturesResident;
4482 table->ArrayElement = _mesa_ArrayElement;
4483 table->BindTexture = save_BindTexture;
4484 table->ColorPointer = _mesa_ColorPointer;
4485 table->CopyTexImage1D = save_CopyTexImage1D;
4486 table->CopyTexImage2D = save_CopyTexImage2D;
4487 table->CopyTexSubImage1D = save_CopyTexSubImage1D;
4488 table->CopyTexSubImage2D = save_CopyTexSubImage2D;
4489 table->DeleteTextures = _mesa_DeleteTextures;
4490 table->DisableClientState = _mesa_DisableClientState;
4491 table->DrawArrays = _mesa_DrawArrays;
4492 table->DrawElements = _mesa_DrawElements;
4493 table->EdgeFlagPointer = _mesa_EdgeFlagPointer;
4494 table->EnableClientState = _mesa_EnableClientState;
4495 table->GenTextures = _mesa_GenTextures;
4496 table->GetPointerv = _mesa_GetPointerv;
4497 table->IndexPointer = _mesa_IndexPointer;
4498 table->Indexub = _mesa_Indexub;
4499 table->Indexubv = _mesa_Indexubv;
4500 table->InterleavedArrays = _mesa_InterleavedArrays;
4501 table->IsTexture = _mesa_IsTexture;
4502 table->NormalPointer = _mesa_NormalPointer;
4503 table->PopClientAttrib = _mesa_PopClientAttrib;
4504 table->PrioritizeTextures = save_PrioritizeTextures;
4505 table->PushClientAttrib = _mesa_PushClientAttrib;
4506 table->TexCoordPointer = _mesa_TexCoordPointer;
4507 table->TexSubImage1D = save_TexSubImage1D;
4508 table->TexSubImage2D = save_TexSubImage2D;
4509 table->VertexPointer = _mesa_VertexPointer;
4510
4511 /* GL 1.2 */
4512 table->CopyTexSubImage3D = save_CopyTexSubImage3D;
4513 table->DrawRangeElements = _mesa_DrawRangeElements;
4514 table->TexImage3D = save_TexImage3D;
4515 table->TexSubImage3D = save_TexSubImage3D;
4516
4517 /* GL_ARB_imaging */
4518 /* NOT supported, just call stub functions */
4519 table->BlendColor = _mesa_BlendColor;
4520 table->BlendEquation = _mesa_BlendEquation;
4521 table->ColorSubTable = _mesa_ColorSubTable;
4522 table->ColorTable = _mesa_ColorTable;
4523 table->ColorTableParameterfv = _mesa_ColorTableParameterfv;
4524 table->ColorTableParameteriv = _mesa_ColorTableParameteriv;
4525 table->ConvolutionFilter1D = _mesa_ConvolutionFilter1D;
4526 table->ConvolutionFilter2D = _mesa_ConvolutionFilter2D;
4527 table->ConvolutionParameterf = _mesa_ConvolutionParameterf;
4528 table->ConvolutionParameterfv = _mesa_ConvolutionParameterfv;
4529 table->ConvolutionParameteri = _mesa_ConvolutionParameteri;
4530 table->ConvolutionParameteriv = _mesa_ConvolutionParameteriv;
4531 table->CopyColorSubTable = _mesa_CopyColorSubTable;
4532 table->CopyColorTable = _mesa_CopyColorTable;
4533 table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D;
4534 table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D;
4535 table->GetColorTable = _mesa_GetColorTable;
4536 table->GetColorTableParameterfv = _mesa_GetColorTableParameterfv;
4537 table->GetColorTableParameteriv = _mesa_GetColorTableParameteriv;
4538 table->GetConvolutionFilter = _mesa_GetConvolutionFilter;
4539 table->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv;
4540 table->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv;
4541 table->GetHistogram = _mesa_GetHistogram;
4542 table->GetHistogramParameterfv = _mesa_GetHistogramParameterfv;
4543 table->GetHistogramParameteriv = _mesa_GetHistogramParameteriv;
4544 table->GetMinmax = _mesa_GetMinmax;
4545 table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv;
4546 table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv;
4547 table->GetSeparableFilter = _mesa_GetSeparableFilter;
4548 table->Histogram = _mesa_Histogram;
4549 table->Minmax = _mesa_Minmax;
4550 table->ResetHistogram = _mesa_ResetHistogram;
4551 table->ResetMinmax = _mesa_ResetMinmax;
4552 table->SeparableFilter2D = _mesa_SeparableFilter2D;
4553
4554 /* 6. GL_EXT_texture3d */
4555 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D;
4556 table->TexImage3DEXT = save_TexImage3DEXT;
4557 table->TexSubImage3DEXT = save_TexSubImage3D;
4558
4559 /* GL_EXT_paletted_texture */
4560 table->ColorTableEXT = save_ColorTableEXT;
4561 table->ColorSubTableEXT = save_ColorSubTableEXT;
4562 table->GetColorTableEXT = _mesa_GetColorTableEXT;
4563 table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfvEXT;
4564 table->GetColorTableParameterivEXT = _mesa_GetColorTableParameterivEXT;
4565
4566 /* GL_EXT_compiled_vertex_array */
4567 table->LockArraysEXT = _mesa_LockArraysEXT;
4568 table->UnlockArraysEXT = _mesa_UnlockArraysEXT;
4569
4570 /* GL_EXT_point_parameters */
4571 table->PointParameterfEXT = save_PointParameterfEXT;
4572 table->PointParameterfvEXT = save_PointParameterfvEXT;
4573
4574 /* GL_PGI_misc_hints */
4575 table->HintPGI = save_HintPGI;
4576
4577 /* GL_EXT_polygon_offset */
4578 table->PolygonOffsetEXT = save_PolygonOffsetEXT;
4579
4580 /* GL_EXT_blend_minmax */
4581 table->BlendEquationEXT = save_BlendEquation;
4582
4583 /* GL_EXT_blend_color */
4584 table->BlendColorEXT = save_BlendColor;
4585
4586 /* GL_ARB_multitexture */
4587 table->ActiveTextureARB = save_ActiveTextureARB;
4588 table->ClientActiveTextureARB = save_ClientActiveTextureARB;
4589 table->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB;
4590 table->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB;
4591 table->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB;
4592 table->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB;
4593 table->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB;
4594 table->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB;
4595 table->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB;
4596 table->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB;
4597 table->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB;
4598 table->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB;
4599 table->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB;
4600 table->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB;
4601 table->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB;
4602 table->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB;
4603 table->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB;
4604 table->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB;
4605 table->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB;
4606 table->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB;
4607 table->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB;
4608 table->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB;
4609 table->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB;
4610 table->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB;
4611 table->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB;
4612 table->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB;
4613 table->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB;
4614 table->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB;
4615 table->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB;
4616 table->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB;
4617 table->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB;
4618 table->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB;
4619 table->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB;
4620 table->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB;
4621
4622 /* GL_INGR_blend_func_separate */
4623 table->BlendFuncSeparateINGR = save_BlendFuncSeparateINGR;
4624
4625 /* GL_MESA_window_pos */
4626 table->WindowPos2dMESA = save_WindowPos2dMESA;
4627 table->WindowPos2dvMESA = save_WindowPos2dvMESA;
4628 table->WindowPos2fMESA = save_WindowPos2fMESA;
4629 table->WindowPos2fvMESA = save_WindowPos2fvMESA;
4630 table->WindowPos2iMESA = save_WindowPos2iMESA;
4631 table->WindowPos2ivMESA = save_WindowPos2ivMESA;
4632 table->WindowPos2sMESA = save_WindowPos2sMESA;
4633 table->WindowPos2svMESA = save_WindowPos2svMESA;
4634 table->WindowPos3dMESA = save_WindowPos3dMESA;
4635 table->WindowPos3dvMESA = save_WindowPos3dvMESA;
4636 table->WindowPos3fMESA = save_WindowPos3fMESA;
4637 table->WindowPos3fvMESA = save_WindowPos3fvMESA;
4638 table->WindowPos3iMESA = save_WindowPos3iMESA;
4639 table->WindowPos3ivMESA = save_WindowPos3ivMESA;
4640 table->WindowPos3sMESA = save_WindowPos3sMESA;
4641 table->WindowPos3svMESA = save_WindowPos3svMESA;
4642 table->WindowPos4dMESA = save_WindowPos4dMESA;
4643 table->WindowPos4dvMESA = save_WindowPos4dvMESA;
4644 table->WindowPos4fMESA = save_WindowPos4fMESA;
4645 table->WindowPos4fvMESA = save_WindowPos4fvMESA;
4646 table->WindowPos4iMESA = save_WindowPos4iMESA;
4647 table->WindowPos4ivMESA = save_WindowPos4ivMESA;
4648 table->WindowPos4sMESA = save_WindowPos4sMESA;
4649 table->WindowPos4svMESA = save_WindowPos4svMESA;
4650
4651 /* GL_MESA_resize_buffers */
4652 table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA;
4653
4654 /* GL_ARB_transpose_matrix */
4655 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB;
4656 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB;
4657 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
4658 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
4659
4660 }
4661
4662
4663
4664 /***
4665 *** Debugging code
4666 ***/
4667 static const char *enum_string( GLenum k )
4668 {
4669 return gl_lookup_enum_by_nr( k );
4670 }
4671
4672
4673 /*
4674 * Print the commands in a display list. For debugging only.
4675 * TODO: many commands aren't handled yet.
4676 */
4677 static void print_list( GLcontext *ctx, FILE *f, GLuint list )
4678 {
4679 Node *n;
4680 GLboolean done;
4681 OpCode opcode;
4682
4683 if (!glIsList(list)) {
4684 fprintf(f,"%u is not a display list ID\n",list);
4685 return;
4686 }
4687
4688 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
4689
4690 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n );
4691
4692 done = n ? GL_FALSE : GL_TRUE;
4693 while (!done) {
4694 opcode = n[0].opcode;
4695
4696 switch (opcode) {
4697 case OPCODE_ACCUM:
4698 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
4699 break;
4700 case OPCODE_BITMAP:
4701 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
4702 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
4703 break;
4704 case OPCODE_CALL_LIST:
4705 fprintf(f,"CallList %d\n", (int) n[1].ui );
4706 break;
4707 case OPCODE_CALL_LIST_OFFSET:
4708 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui,
4709 ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
4710 break;
4711 case OPCODE_DISABLE:
4712 fprintf(f,"Disable %s\n", enum_string(n[1].e));
4713 break;
4714 case OPCODE_ENABLE:
4715 fprintf(f,"Enable %s\n", enum_string(n[1].e));
4716 break;
4717 case OPCODE_FRUSTUM:
4718 fprintf(f,"Frustum %g %g %g %g %g %g\n",
4719 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4720 break;
4721 case OPCODE_LINE_STIPPLE:
4722 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
4723 break;
4724 case OPCODE_LOAD_IDENTITY:
4725 fprintf(f,"LoadIdentity\n");
4726 break;
4727 case OPCODE_LOAD_MATRIX:
4728 fprintf(f,"LoadMatrix\n");
4729 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
4730 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
4731 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
4732 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
4733 break;
4734 case OPCODE_MULT_MATRIX:
4735 fprintf(f,"MultMatrix (or Rotate)\n");
4736 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f);
4737 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
4738 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
4739 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
4740 break;
4741 case OPCODE_ORTHO:
4742 fprintf(f,"Ortho %g %g %g %g %g %g\n",
4743 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
4744 break;
4745 case OPCODE_POP_ATTRIB:
4746 fprintf(f,"PopAttrib\n");
4747 break;
4748 case OPCODE_POP_MATRIX:
4749 fprintf(f,"PopMatrix\n");
4750 break;
4751 case OPCODE_POP_NAME:
4752 fprintf(f,"PopName\n");
4753 break;
4754 case OPCODE_PUSH_ATTRIB:
4755 fprintf(f,"PushAttrib %x\n", n[1].bf );
4756 break;
4757 case OPCODE_PUSH_MATRIX:
4758 fprintf(f,"PushMatrix\n");
4759 break;
4760 case OPCODE_PUSH_NAME:
4761 fprintf(f,"PushName %d\n", (int) n[1].ui );
4762 break;
4763 case OPCODE_RASTER_POS:
4764 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
4765 break;
4766 case OPCODE_RECTF:
4767 fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
4768 break;
4769 case OPCODE_SCALE:
4770 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
4771 break;
4772 case OPCODE_TRANSLATE:
4773 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
4774 break;
4775 case OPCODE_BIND_TEXTURE:
4776 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui),
4777 n[2].ui);
4778 break;
4779 case OPCODE_SHADE_MODEL:
4780 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui));
4781 break;
4782
4783 /*
4784 * meta opcodes/commands
4785 */
4786 case OPCODE_ERROR:
4787 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
4788 break;
4789 case OPCODE_VERTEX_CASSETTE:
4790 fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
4791 ((struct immediate *) n[1].data)->id,
4792 n[2].ui,
4793 n[3].ui);
4794 break;
4795 case OPCODE_CONTINUE:
4796 fprintf(f,"DISPLAY-LIST-CONTINUE\n");
4797 n = (Node *) n[1].next;
4798 break;
4799 case OPCODE_END_OF_LIST:
4800 fprintf(f,"END-LIST %u\n", list);
4801 done = GL_TRUE;
4802 break;
4803 default:
4804 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
4805 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
4806 opcode, (void*) n);
4807 return;
4808 }
4809 else {
4810 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
4811 }
4812 }
4813
4814 /* increment n to point to next compiled command */
4815 if (opcode!=OPCODE_CONTINUE) {
4816 n += InstSize[opcode];
4817 }
4818 }
4819 }
4820
4821
4822
4823 /*
4824 * Clients may call this function to help debug display list problems.
4825 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
4826 * changed, or break in the future without notice.
4827 */
4828 void mesa_print_display_list( GLuint list )
4829 {
4830 GET_CURRENT_CONTEXT(ctx);
4831 print_list( ctx, stderr, list );
4832 }