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