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