1 /* $Id: dlist.c,v 1.37 1997/12/06 18:06:50 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 2.6
6 * Copyright (C) 1995-1997 Brian Paul
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23
24 /*
25 * $Log: dlist.c,v $
26 * Revision 1.37 1997/12/06 18:06:50 brianp
27 * moved several static display list vars into GLcontext
28 *
29 * Revision 1.36 1997/11/25 03:20:09 brianp
30 * simple clean-ups for multi-threading (John Stone)
31 *
32 * Revision 1.35 1997/10/29 01:29:09 brianp
33 * added GL_EXT_point_parameters extension from Daniel Barrero
34 *
35 * Revision 1.34 1997/10/02 00:48:29 brianp
36 * removed the EXEC() macro stuff, it caused bugs in gl_save_Color*()
37 *
38 * Revision 1.33 1997/09/27 00:13:44 brianp
39 * added GL_EXT_paletted_texture extension
40 *
41 * Revision 1.32 1997/09/23 00:57:52 brianp
42 * removed list>MAX_DISPLAYLISTS test
43 *
44 * Revision 1.31 1997/09/22 02:33:58 brianp
45 * display lists now implemented with hash table
46 *
47 * Revision 1.30 1997/07/24 01:25:01 brianp
48 * changed precompiled header symbol from PCH to PC_HEADER
49 *
50 * Revision 1.29 1997/07/09 01:26:12 brianp
51 * fixed glDrawPixels() GL_COMPILE_AND_EXECUTE infinite loop (Renaud Cazoulat)
52 *
53 * Revision 1.28 1997/06/24 01:13:26 brianp
54 * initialize image RefCount to 1 for gl_save_TexSubImage[123]D()
55 *
56 * Revision 1.27 1997/06/20 01:57:57 brianp
57 * added gl_save_Color4ubv()
58 *
59 * Revision 1.26 1997/06/06 02:59:19 brianp
60 * renamed destroy_list() to gl_destroy_list()
61 *
62 * Revision 1.25 1997/05/28 03:24:22 brianp
63 * added precompiled header (PCH) support
64 *
65 * Revision 1.24 1997/05/27 03:13:41 brianp
66 * removed some debugging code
67 *
68 * Revision 1.23 1997/04/30 21:36:22 brianp
69 * added casts to gl_TexImage[123]D() calls
70 *
71 * Revision 1.22 1997/04/28 23:40:47 brianp
72 * added #include "rect.h"
73 *
74 * Revision 1.21 1997/04/24 01:50:53 brianp
75 * optimized glColor3f, glColor3fv, glColor4fv
76 *
77 * Revision 1.20 1997/04/24 00:30:17 brianp
78 * optimized glTexCoord2() code
79 *
80 * Revision 1.19 1997/04/21 01:21:33 brianp
81 * added gl_save_Rectf()
82 *
83 * Revision 1.18 1997/04/20 16:18:15 brianp
84 * added glOrtho and glFrustum API pointers
85 *
86 * Revision 1.17 1997/04/16 23:55:33 brianp
87 * added optimized glTexCoord2f code
88 *
89 * Revision 1.16 1997/04/14 22:18:23 brianp
90 * added optimized glVertex3fv code
91 *
92 * Revision 1.15 1997/04/14 02:00:39 brianp
93 * #include "texstate.h" instead of "texture.h"
94 *
95 * Revision 1.14 1997/04/07 02:58:49 brianp
96 * added gl_save_Vertex[23]f() and related code
97 *
98 * Revision 1.13 1997/04/01 04:26:02 brianp
99 * added code for glLoadIdentity(), changed #include's
100 *
101 * Revision 1.12 1997/02/27 19:58:08 brianp
102 * call gl_problem() instead of gl_warning()
103 *
104 * Revision 1.11 1997/02/09 18:50:18 brianp
105 * added GL_EXT_texture3D support
106 *
107 * Revision 1.10 1997/01/29 18:51:30 brianp
108 * small MEMCPY call change for Acorn compiler, per Graham Jones
109 *
110 * Revision 1.9 1997/01/09 21:25:28 brianp
111 * set reference count to one for texture images in display lists
112 *
113 * Revision 1.8 1996/12/11 20:19:11 brianp
114 * abort display list execution if invalid opcode found
115 *
116 * Revision 1.7 1996/12/09 21:39:23 brianp
117 * compare list to MAX_DISPLAYLISTS in gl_IsList()
118 *
119 * Revision 1.6 1996/12/04 22:14:27 brianp
120 * improved the mesa_print_display_list() debug function
121 *
122 * Revision 1.5 1996/11/07 04:12:45 brianp
123 * texture images are now gl_image structs, not gl_texture_image structs
124 *
125 * Revision 1.4 1996/10/16 00:59:12 brianp
126 * fixed bug in gl_save_Lightfv()
127 * execution of OPCODE_EDGE_FLAG used enum value instead of boolean
128 *
129 * Revision 1.3 1996/09/27 01:26:08 brianp
130 * removed unused variables
131 *
132 * Revision 1.2 1996/09/19 00:54:43 brianp
133 * fixed bug in gl_save_Rotatef() when in GL_COMPILE_AND_EXECUTE mode
134 *
135 * Revision 1.1 1996/09/13 01:38:16 brianp
136 * Initial revision
137 *
138 */
139
140
141 #ifdef PC_HEADER
142 #include "all.h"
143 #else
144 #include <assert.h>
145 #include <stdio.h>
146 #include <stdlib.h>
147 #include <string.h>
148 #include "accum.h"
149 #include "alpha.h"
150 #include "attrib.h"
151 #include "bitmap.h"
152 #include "blend.h"
153 #include "clip.h"
154 #include "colortab.h"
155 #include "context.h"
156 #include "copypix.h"
157 #include "depth.h"
158 #include "drawpix.h"
159 #include "enable.h"
160 #include "eval.h"
161 #include "feedback.h"
162 #include "fog.h"
163 #include "hash.h"
164 #include "image.h"
165 #include "light.h"
166 #include "lines.h"
167 #include "dlist.h"
168 #include "logic.h"
169 #include "macros.h"
170 #include "masking.h"
171 #include "matrix.h"
172 #include "misc.h"
173 #include "pixel.h"
174 #include "points.h"
175 #include "polygon.h"
176 #include "rastpos.h"
177 #include "rect.h"
178 #include "scissor.h"
179 #include "stencil.h"
180 #include "texobj.h"
181 #include "teximage.h"
182 #include "texstate.h"
183 #include "types.h"
184 #include "vb.h"
185 #include "vbfill.h"
186 #endif
187
188
189
190 /*
191 Functions which aren't compiled but executed immediately:
192 glIsList
193 glGenLists
194 glDeleteLists
195 glEndList
196 glFeedbackBuffer
197 glSelectBuffer
198 glRenderMode
199 glReadPixels
200 glPixelStore
201 glFlush
202 glFinish
203 glIsEnabled
204 glGet*
205
206 Functions which cause errors if called while compiling a display list:
207 glNewList
208 */
209
210
211
212 /*
213 * Display list instructions are stored as sequences of "nodes". Nodes
214 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
215 * are linked together with a pointer.
216 */
217
218
219 /* How many nodes to allocate at a time: */
220 #define BLOCK_SIZE 500
221
222
223 /*
224 * Display list opcodes.
225 *
226 * The fact that these identifiers are assigned consecutive
227 * integer values starting at 0 is very important, see InstSize array usage)
228 */
229 typedef enum {
230 OPCODE_ACCUM,
231 OPCODE_ALPHA_FUNC,
232 OPCODE_BEGIN,
233 OPCODE_BIND_TEXTURE,
234 OPCODE_BITMAP,
235 OPCODE_BLEND_FUNC,
236 OPCODE_CALL_LIST,
237 OPCODE_CALL_LIST_OFFSET,
238 OPCODE_CLEAR,
239 OPCODE_CLEAR_ACCUM,
240 OPCODE_CLEAR_COLOR,
241 OPCODE_CLEAR_DEPTH,
242 OPCODE_CLEAR_INDEX,
243 OPCODE_CLEAR_STENCIL,
244 OPCODE_CLIP_PLANE,
245 OPCODE_COLOR_3F,
246 OPCODE_COLOR_4F,
247 OPCODE_COLOR_4UB,
248 OPCODE_COLOR_MASK,
249 OPCODE_COLOR_MATERIAL,
250 OPCODE_COLOR_TABLE,
251 OPCODE_COLOR_SUB_TABLE,
252 OPCODE_COPY_PIXELS,
253 OPCODE_COPY_TEX_IMAGE1D,
254 OPCODE_COPY_TEX_IMAGE2D,
255 OPCODE_COPY_TEX_IMAGE3D,
256 OPCODE_COPY_TEX_SUB_IMAGE1D,
257 OPCODE_COPY_TEX_SUB_IMAGE2D,
258 OPCODE_CULL_FACE,
259 OPCODE_DEPTH_FUNC,
260 OPCODE_DEPTH_MASK,
261 OPCODE_DEPTH_RANGE,
262 OPCODE_DISABLE,
263 OPCODE_DRAW_BUFFER,
264 OPCODE_DRAW_PIXELS,
265 OPCODE_EDGE_FLAG,
266 OPCODE_ENABLE,
267 OPCODE_END,
268 OPCODE_EVALCOORD1,
269 OPCODE_EVALCOORD2,
270 OPCODE_EVALMESH1,
271 OPCODE_EVALMESH2,
272 OPCODE_EVALPOINT1,
273 OPCODE_EVALPOINT2,
274 OPCODE_FOG,
275 OPCODE_FRONT_FACE,
276 OPCODE_FRUSTUM,
277 OPCODE_HINT,
278 OPCODE_INDEX,
279 OPCODE_INDEX_MASK,
280 OPCODE_INIT_NAMES,
281 OPCODE_LIGHT,
282 OPCODE_LIGHT_MODEL,
283 OPCODE_LINE_STIPPLE,
284 OPCODE_LINE_WIDTH,
285 OPCODE_LIST_BASE,
286 OPCODE_LOAD_IDENTITY,
287 OPCODE_LOAD_MATRIX,
288 OPCODE_LOAD_NAME,
289 OPCODE_LOGIC_OP,
290 OPCODE_MAP1,
291 OPCODE_MAP2,
292 OPCODE_MAPGRID1,
293 OPCODE_MAPGRID2,
294 OPCODE_MATERIAL,
295 OPCODE_MATRIX_MODE,
296 OPCODE_MULT_MATRIX,
297 OPCODE_NORMAL,
298 OPCODE_ORTHO,
299 OPCODE_PASSTHROUGH,
300 OPCODE_PIXEL_MAP,
301 OPCODE_PIXEL_TRANSFER,
302 OPCODE_PIXEL_ZOOM,
303 OPCODE_POINT_SIZE,
304 OPCODE_POLYGON_MODE,
305 OPCODE_POLYGON_STIPPLE,
306 OPCODE_POLYGON_OFFSET,
307 OPCODE_POP_ATTRIB,
308 OPCODE_POP_MATRIX,
309 OPCODE_POP_NAME,
310 OPCODE_PRIORITIZE_TEXTURE,
311 OPCODE_PUSH_ATTRIB,
312 OPCODE_PUSH_MATRIX,
313 OPCODE_PUSH_NAME,
314 OPCODE_RASTER_POS,
315 OPCODE_RECTF,
316 OPCODE_READ_BUFFER,
317 OPCODE_SCALE,
318 OPCODE_SCISSOR,
319 OPCODE_SHADE_MODEL,
320 OPCODE_STENCIL_FUNC,
321 OPCODE_STENCIL_MASK,
322 OPCODE_STENCIL_OP,
323 OPCODE_TEXCOORD2,
324 OPCODE_TEXCOORD4,
325 OPCODE_TEXENV,
326 OPCODE_TEXGEN,
327 OPCODE_TEXPARAMETER,
328 OPCODE_TEX_IMAGE1D,
329 OPCODE_TEX_IMAGE2D,
330 OPCODE_TEX_SUB_IMAGE1D,
331 OPCODE_TEX_SUB_IMAGE2D,
332 OPCODE_TRANSLATE,
333 OPCODE_VERTEX2,
334 OPCODE_VERTEX3,
335 OPCODE_VERTEX4,
336 OPCODE_VIEWPORT,
337 /* The following two are meta instructions */
338 OPCODE_CONTINUE,
339 OPCODE_END_OF_LIST
340 } OpCode;
341
342
343 /*
344 * Each instruction in the display list is stored as a sequence of
345 * contiguous nodes in memory.
346 * Each node is the union of a variety of datatypes.
347 */
348 union node {
349 OpCode opcode;
350 GLboolean b;
351 GLbitfield bf;
352 GLubyte ub;
353 GLshort s;
354 GLushort us;
355 GLint i;
356 GLuint ui;
357 GLenum e;
358 GLfloat f;
359 GLvoid *data;
360 void *next; /* If prev node's opcode==OPCODE_CONTINUE */
361 };
362
363
364
365 /* Number of nodes of storage needed for each instruction: */
366 static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
367
368
369
370 /**********************************************************************/
371 /***** Private *****/
372 /**********************************************************************/
373
374
375 /*
376 * Allocate space for a display list instruction.
377 * Input: opcode - type of instruction
378 * argcount - number of arguments following the instruction
379 * Return: pointer to first node in the instruction
380 */
alloc_instruction(GLcontext * ctx,OpCode opcode,GLint argcount)381 static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
382 {
383 Node *n, *newblock;
384 GLuint count = InstSize[opcode];
385
386 assert( count == argcount+1 );
387
388 if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
389 /* This block is full. Allocate a new block and chain to it */
390 n = ctx->CurrentBlock + ctx->CurrentPos;
391 n[0].opcode = OPCODE_CONTINUE;
392 newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
393 if (!newblock) {
394 gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
395 return NULL;
396 }
397 n[1].next = (Node *) newblock;
398 ctx->CurrentBlock = newblock;
399 ctx->CurrentPos = 0;
400 }
401
402 n = ctx->CurrentBlock + ctx->CurrentPos;
403 ctx->CurrentPos += count;
404
405 n[0].opcode = opcode;
406
407 return n;
408 }
409
410
411
412 /*
413 * Make an empty display list. This is used by glGenLists() to
414 * reserver display list IDs.
415 */
make_empty_list(void)416 static Node *make_empty_list( void )
417 {
418 Node *n = (Node *) malloc( sizeof(Node) );
419 n[0].opcode = OPCODE_END_OF_LIST;
420 return n;
421 }
422
423
424
425 /*
426 * Destroy all nodes in a display list.
427 * Input: list - display list number
428 */
gl_destroy_list(GLcontext * ctx,GLuint list)429 void gl_destroy_list( GLcontext *ctx, GLuint list )
430 {
431 Node *n, *block;
432 GLboolean done;
433
434 block = (Node *) HashLookup(ctx->Shared->DisplayList, list);
435 n = block;
436
437 done = block ? GL_FALSE : GL_TRUE;
438 while (!done) {
439 switch (n[0].opcode) {
440 /* special cases first */
441 case OPCODE_MAP1:
442 gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data );
443 n += InstSize[n[0].opcode];
444 break;
445 case OPCODE_MAP2:
446 gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data );
447 n += InstSize[n[0].opcode];
448 break;
449 case OPCODE_DRAW_PIXELS:
450 free( n[5].data );
451 n += InstSize[n[0].opcode];
452 break;
453 case OPCODE_BITMAP:
454 gl_free_image( (struct gl_image *) n[7].data );
455 n += InstSize[n[0].opcode];
456 break;
457 case OPCODE_COLOR_TABLE:
458 gl_free_image( (struct gl_image *) n[3].data );
459 n += InstSize[n[0].opcode];
460 break;
461 case OPCODE_COLOR_SUB_TABLE:
462 gl_free_image( (struct gl_image *) n[3].data );
463 n += InstSize[n[0].opcode];
464 break;
465 case OPCODE_POLYGON_STIPPLE:
466 free( n[1].data );
467 n += InstSize[n[0].opcode];
468 break;
469 case OPCODE_TEX_IMAGE1D:
470 gl_free_image( (struct gl_image *) n[8].data );
471 n += InstSize[n[0].opcode];
472 break;
473 case OPCODE_TEX_IMAGE2D:
474 gl_free_image( (struct gl_image *) n[9].data );
475 n += InstSize[n[0].opcode];
476 break;
477 case OPCODE_TEX_SUB_IMAGE1D:
478 {
479 struct gl_image *image;
480 image = (struct gl_image *) n[7].data;
481 gl_free_image( image );
482 }
483 break;
484 case OPCODE_TEX_SUB_IMAGE2D:
485 {
486 struct gl_image *image;
487 image = (struct gl_image *) n[9].data;
488 gl_free_image( image );
489 }
490 break;
491 case OPCODE_CONTINUE:
492 n = (Node *) n[1].next;
493 free( block );
494 block = n;
495 break;
496 case OPCODE_END_OF_LIST:
497 free( block );
498 done = GL_TRUE;
499 break;
500 default:
501 /* Most frequent case */
502 n += InstSize[n[0].opcode];
503 break;
504 }
505 }
506
507 HashRemove(ctx->Shared->DisplayList, list);
508 }
509
510
511
512 /*
513 * Translate the nth element of list from type to GLuint.
514 */
translate_id(GLsizei n,GLenum type,const GLvoid * list)515 static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
516 {
517 GLbyte *bptr;
518 GLubyte *ubptr;
519 GLshort *sptr;
520 GLushort *usptr;
521 GLint *iptr;
522 GLuint *uiptr;
523 GLfloat *fptr;
524
525 switch (type) {
526 case GL_BYTE:
527 bptr = (GLbyte *) list;
528 return (GLuint) *(bptr+n);
529 case GL_UNSIGNED_BYTE:
530 ubptr = (GLubyte *) list;
531 return (GLuint) *(ubptr+n);
532 case GL_SHORT:
533 sptr = (GLshort *) list;
534 return (GLuint) *(sptr+n);
535 case GL_UNSIGNED_SHORT:
536 usptr = (GLushort *) list;
537 return (GLuint) *(usptr+n);
538 case GL_INT:
539 iptr = (GLint *) list;
540 return (GLuint) *(iptr+n);
541 case GL_UNSIGNED_INT:
542 uiptr = (GLuint *) list;
543 return (GLuint) *(uiptr+n);
544 case GL_FLOAT:
545 fptr = (GLfloat *) list;
546 return (GLuint) *(fptr+n);
547 case GL_2_BYTES:
548 ubptr = ((GLubyte *) list) + 2*n;
549 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
550 case GL_3_BYTES:
551 ubptr = ((GLubyte *) list) + 3*n;
552 return (GLuint) *ubptr * 65536
553 + (GLuint) *(ubptr+1) * 256
554 + (GLuint) *(ubptr+2);
555 case GL_4_BYTES:
556 ubptr = ((GLubyte *) list) + 4*n;
557 return (GLuint) *ubptr * 16777216
558 + (GLuint) *(ubptr+1) * 65536
559 + (GLuint) *(ubptr+2) * 256
560 + (GLuint) *(ubptr+3);
561 default:
562 return 0;
563 }
564 }
565
566
567
568
569 /**********************************************************************/
570 /***** Public *****/
571 /**********************************************************************/
572
gl_init_lists(void)573 void gl_init_lists( void )
574 {
575 static int init_flag = 0;
576
577 if (init_flag==0) {
578 InstSize[OPCODE_ACCUM] = 3;
579 InstSize[OPCODE_ALPHA_FUNC] = 3;
580 InstSize[OPCODE_BEGIN] = 2;
581 InstSize[OPCODE_BIND_TEXTURE] = 3;
582 InstSize[OPCODE_BITMAP] = 8;
583 InstSize[OPCODE_BLEND_FUNC] = 3;
584 InstSize[OPCODE_CALL_LIST] = 2;
585 InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
586 InstSize[OPCODE_CLEAR] = 2;
587 InstSize[OPCODE_CLEAR_ACCUM] = 5;
588 InstSize[OPCODE_CLEAR_COLOR] = 5;
589 InstSize[OPCODE_CLEAR_DEPTH] = 2;
590 InstSize[OPCODE_CLEAR_INDEX] = 2;
591 InstSize[OPCODE_CLEAR_STENCIL] = 2;
592 InstSize[OPCODE_CLIP_PLANE] = 6;
593 InstSize[OPCODE_COLOR_3F] = 4;
594 InstSize[OPCODE_COLOR_4F] = 5;
595 InstSize[OPCODE_COLOR_4UB] = 5;
596 InstSize[OPCODE_COLOR_MASK] = 5;
597 InstSize[OPCODE_COLOR_MATERIAL] = 3;
598 InstSize[OPCODE_COLOR_TABLE] = 4;
599 InstSize[OPCODE_COLOR_SUB_TABLE] = 4;
600 InstSize[OPCODE_COPY_PIXELS] = 6;
601 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
602 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
603 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
604 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
605 InstSize[OPCODE_CULL_FACE] = 2;
606 InstSize[OPCODE_DEPTH_FUNC] = 2;
607 InstSize[OPCODE_DEPTH_MASK] = 2;
608 InstSize[OPCODE_DEPTH_RANGE] = 3;
609 InstSize[OPCODE_DISABLE] = 2;
610 InstSize[OPCODE_DRAW_BUFFER] = 2;
611 InstSize[OPCODE_DRAW_PIXELS] = 6;
612 InstSize[OPCODE_ENABLE] = 2;
613 InstSize[OPCODE_EDGE_FLAG] = 2;
614 InstSize[OPCODE_END] = 1;
615 InstSize[OPCODE_EVALCOORD1] = 2;
616 InstSize[OPCODE_EVALCOORD2] = 3;
617 InstSize[OPCODE_EVALMESH1] = 4;
618 InstSize[OPCODE_EVALMESH2] = 6;
619 InstSize[OPCODE_EVALPOINT1] = 2;
620 InstSize[OPCODE_EVALPOINT2] = 3;
621 InstSize[OPCODE_FOG] = 6;
622 InstSize[OPCODE_FRONT_FACE] = 2;
623 InstSize[OPCODE_FRUSTUM] = 7;
624 InstSize[OPCODE_HINT] = 3;
625 InstSize[OPCODE_INDEX] = 2;
626 InstSize[OPCODE_INDEX_MASK] = 2;
627 InstSize[OPCODE_INIT_NAMES] = 1;
628 InstSize[OPCODE_LIGHT] = 7;
629 InstSize[OPCODE_LIGHT_MODEL] = 6;
630 InstSize[OPCODE_LINE_STIPPLE] = 3;
631 InstSize[OPCODE_LINE_WIDTH] = 2;
632 InstSize[OPCODE_LIST_BASE] = 2;
633 InstSize[OPCODE_LOAD_IDENTITY] = 1;
634 InstSize[OPCODE_LOAD_MATRIX] = 17;
635 InstSize[OPCODE_LOAD_NAME] = 2;
636 InstSize[OPCODE_LOGIC_OP] = 2;
637 InstSize[OPCODE_MAP1] = 7;
638 InstSize[OPCODE_MAP2] = 11;
639 InstSize[OPCODE_MAPGRID1] = 4;
640 InstSize[OPCODE_MAPGRID2] = 7;
641 InstSize[OPCODE_MATERIAL] = 7;
642 InstSize[OPCODE_MATRIX_MODE] = 2;
643 InstSize[OPCODE_MULT_MATRIX] = 17;
644 InstSize[OPCODE_NORMAL] = 4;
645 InstSize[OPCODE_ORTHO] = 7;
646 InstSize[OPCODE_PASSTHROUGH] = 2;
647 InstSize[OPCODE_PIXEL_MAP] = 4;
648 InstSize[OPCODE_PIXEL_TRANSFER] = 3;
649 InstSize[OPCODE_PIXEL_ZOOM] = 3;
650 InstSize[OPCODE_POINT_SIZE] = 2;
651 InstSize[OPCODE_POLYGON_MODE] = 3;
652 InstSize[OPCODE_POLYGON_STIPPLE] = 2;
653 InstSize[OPCODE_POLYGON_OFFSET] = 3;
654 InstSize[OPCODE_POP_ATTRIB] = 1;
655 InstSize[OPCODE_POP_MATRIX] = 1;
656 InstSize[OPCODE_POP_NAME] = 1;
657 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
658 InstSize[OPCODE_PUSH_ATTRIB] = 2;
659 InstSize[OPCODE_PUSH_MATRIX] = 1;
660 InstSize[OPCODE_PUSH_NAME] = 2;
661 InstSize[OPCODE_RASTER_POS] = 5;
662 InstSize[OPCODE_RECTF] = 5;
663 InstSize[OPCODE_READ_BUFFER] = 2;
664 InstSize[OPCODE_SCALE] = 4;
665 InstSize[OPCODE_SCISSOR] = 5;
666 InstSize[OPCODE_STENCIL_FUNC] = 4;
667 InstSize[OPCODE_STENCIL_MASK] = 2;
668 InstSize[OPCODE_STENCIL_OP] = 4;
669 InstSize[OPCODE_SHADE_MODEL] = 2;
670 InstSize[OPCODE_TEXCOORD2] = 3;
671 InstSize[OPCODE_TEXCOORD4] = 5;
672 InstSize[OPCODE_TEXENV] = 7;
673 InstSize[OPCODE_TEXGEN] = 7;
674 InstSize[OPCODE_TEXPARAMETER] = 7;
675 InstSize[OPCODE_TEX_IMAGE1D] = 9;
676 InstSize[OPCODE_TEX_IMAGE2D] = 10;
677 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
678 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
679 InstSize[OPCODE_TRANSLATE] = 4;
680 InstSize[OPCODE_VERTEX2] = 3;
681 InstSize[OPCODE_VERTEX3] = 4;
682 InstSize[OPCODE_VERTEX4] = 5;
683 InstSize[OPCODE_VIEWPORT] = 5;
684 InstSize[OPCODE_CONTINUE] = 2;
685 InstSize[OPCODE_END_OF_LIST] = 1;
686 }
687 init_flag = 1;
688 }
689
690
691 /*
692 * Display List compilation functions
693 */
694
695
gl_save_Accum(GLcontext * ctx,GLenum op,GLfloat value)696 void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
697 {
698 Node *n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
699 if (n) {
700 n[1].e = op;
701 n[2].f = value;
702 }
703 if (ctx->ExecuteFlag) {
704 (*ctx->Exec.Accum)( ctx, op, value );
705 }
706 }
707
708
gl_save_AlphaFunc(GLcontext * ctx,GLenum func,GLclampf ref)709 void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
710 {
711 Node *n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
712 if (n) {
713 n[1].e = func;
714 n[2].f = (GLfloat) ref;
715 }
716 if (ctx->ExecuteFlag) {
717 (*ctx->Exec.AlphaFunc)( ctx, func, ref );
718 }
719 }
720
721
gl_save_Begin(GLcontext * ctx,GLenum mode)722 void gl_save_Begin( GLcontext *ctx, GLenum mode )
723 {
724 Node *n = alloc_instruction( ctx, OPCODE_BEGIN, 1 );
725 if (n) {
726 n[1].e = mode;
727 }
728 if (ctx->ExecuteFlag) {
729 (*ctx->Exec.Begin)( ctx, mode );
730 }
731 }
732
733
gl_save_BindTexture(GLcontext * ctx,GLenum target,GLuint texture)734 void gl_save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
735 {
736 Node *n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
737 if (n) {
738 n[1].e = target;
739 n[2].ui = texture;
740 }
741 if (ctx->ExecuteFlag) {
742 (*ctx->Exec.BindTexture)( ctx, target, texture );
743 }
744 }
745
746
gl_save_Bitmap(GLcontext * ctx,GLsizei width,GLsizei height,GLfloat xorig,GLfloat yorig,GLfloat xmove,GLfloat ymove,const struct gl_image * bitmap)747 void gl_save_Bitmap( GLcontext *ctx,
748 GLsizei width, GLsizei height,
749 GLfloat xorig, GLfloat yorig,
750 GLfloat xmove, GLfloat ymove,
751 const struct gl_image *bitmap )
752 {
753 Node *n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
754 if (n) {
755 n[1].i = (GLint) width;
756 n[2].i = (GLint) height;
757 n[3].f = xorig;
758 n[4].f = yorig;
759 n[5].f = xmove;
760 n[6].f = ymove;
761 n[7].data = (void *) bitmap;
762 }
763 if (ctx->ExecuteFlag) {
764 (*ctx->Exec.Bitmap)( ctx, width, height,
765 xorig, yorig, xmove, ymove, bitmap );
766 }
767 }
768
769
gl_save_BlendFunc(GLcontext * ctx,GLenum sfactor,GLenum dfactor)770 void gl_save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
771 {
772 Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
773 if (n) {
774 n[1].e = sfactor;
775 n[2].e = dfactor;
776 }
777 if (ctx->ExecuteFlag) {
778 (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor );
779 }
780 }
781
782
gl_save_CallList(GLcontext * ctx,GLuint list)783 void gl_save_CallList( GLcontext *ctx, GLuint list )
784 {
785 Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
786 if (n) {
787 n[1].ui = list;
788 }
789 if (ctx->ExecuteFlag) {
790 (*ctx->Exec.CallList)( ctx, list );
791 }
792 }
793
794
gl_save_CallLists(GLcontext * ctx,GLsizei n,GLenum type,const GLvoid * lists)795 void gl_save_CallLists( GLcontext *ctx,
796 GLsizei n, GLenum type, const GLvoid *lists )
797 {
798 GLuint i;
799
800 for (i=0;i<n;i++) {
801 GLuint list = translate_id( i, type, lists );
802 Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
803 if (n) {
804 n[1].ui = list;
805 }
806 }
807 if (ctx->ExecuteFlag) {
808 (*ctx->Exec.CallLists)( ctx, n, type, lists );
809 }
810 }
811
812
gl_save_Clear(GLcontext * ctx,GLbitfield mask)813 void gl_save_Clear( GLcontext *ctx, GLbitfield mask )
814 {
815 Node *n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
816 if (n) {
817 n[1].bf = mask;
818 }
819 if (ctx->ExecuteFlag) {
820 (*ctx->Exec.Clear)( ctx, mask );
821 }
822 }
823
824
gl_save_ClearAccum(GLcontext * ctx,GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)825 void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
826 GLfloat blue, GLfloat alpha )
827 {
828 Node *n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
829 if (n) {
830 n[1].f = red;
831 n[2].f = green;
832 n[3].f = blue;
833 n[4].f = alpha;
834 }
835 if (ctx->ExecuteFlag) {
836 (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha );
837 }
838 }
839
840
gl_save_ClearColor(GLcontext * ctx,GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)841 void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
842 GLclampf blue, GLclampf alpha )
843 {
844 Node *n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
845 if (n) {
846 n[1].f = red;
847 n[2].f = green;
848 n[3].f = blue;
849 n[4].f = alpha;
850 }
851 if (ctx->ExecuteFlag) {
852 (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha );
853 }
854 }
855
856
gl_save_ClearDepth(GLcontext * ctx,GLclampd depth)857 void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth )
858 {
859 Node *n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
860 if (n) {
861 n[1].f = (GLfloat) depth;
862 }
863 if (ctx->ExecuteFlag) {
864 (*ctx->Exec.ClearDepth)( ctx, depth );
865 }
866 }
867
868
gl_save_ClearIndex(GLcontext * ctx,GLfloat c)869 void gl_save_ClearIndex( GLcontext *ctx, GLfloat c )
870 {
871 Node *n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
872 if (n) {
873 n[1].f = c;
874 }
875 if (ctx->ExecuteFlag) {
876 (*ctx->Exec.ClearIndex)( ctx, c );
877 }
878 }
879
880
gl_save_ClearStencil(GLcontext * ctx,GLint s)881 void gl_save_ClearStencil( GLcontext *ctx, GLint s )
882 {
883 Node *n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
884 if (n) {
885 n[1].i = s;
886 }
887 if (ctx->ExecuteFlag) {
888 (*ctx->Exec.ClearStencil)( ctx, s );
889 }
890 }
891
892
gl_save_ClipPlane(GLcontext * ctx,GLenum plane,const GLfloat * equ)893 void gl_save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
894 {
895 Node *n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
896 if (n) {
897 n[1].e = plane;
898 n[2].f = equ[0];
899 n[3].f = equ[1];
900 n[4].f = equ[2];
901 n[5].f = equ[3];
902 }
903 if (ctx->ExecuteFlag) {
904 (*ctx->Exec.ClipPlane)( ctx, plane, equ );
905 }
906 }
907
908
gl_save_Color3f(GLcontext * ctx,GLfloat r,GLfloat g,GLfloat b)909 void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b )
910 {
911 Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
912 if (n) {
913 n[1].f = r;
914 n[2].f = g;
915 n[3].f = b;
916 }
917 if (ctx->ExecuteFlag) {
918 (*ctx->Exec.Color3f)( ctx, r, g, b );
919 }
920 }
921
922
gl_save_Color3fv(GLcontext * ctx,const GLfloat * c)923 void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c )
924 {
925 Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
926 if (n) {
927 n[1].f = c[0];
928 n[2].f = c[1];
929 n[3].f = c[2];
930 }
931 if (ctx->ExecuteFlag) {
932 (*ctx->Exec.Color3fv)( ctx, c );
933 }
934 }
935
936
gl_save_Color4f(GLcontext * ctx,GLfloat r,GLfloat g,GLfloat b,GLfloat a)937 void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g,
938 GLfloat b, GLfloat a )
939 {
940 Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
941 if (n) {
942 n[1].f = r;
943 n[2].f = g;
944 n[3].f = b;
945 n[4].f = a;
946 }
947 if (ctx->ExecuteFlag) {
948 (*ctx->Exec.Color4f)( ctx, r, g, b, a );
949 }
950 }
951
952
gl_save_Color4fv(GLcontext * ctx,const GLfloat * c)953 void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c )
954 {
955 Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
956 if (n) {
957 n[1].f = c[0];
958 n[2].f = c[1];
959 n[3].f = c[2];
960 n[4].f = c[3];
961 }
962 if (ctx->ExecuteFlag) {
963 (*ctx->Exec.Color4fv)( ctx, c );
964 }
965 }
966
967
gl_save_Color4ub(GLcontext * ctx,GLubyte r,GLubyte g,GLubyte b,GLubyte a)968 void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g,
969 GLubyte b, GLubyte a )
970 {
971 Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
972 if (n) {
973 n[1].ub = r;
974 n[2].ub = g;
975 n[3].ub = b;
976 n[4].ub = a;
977 }
978 if (ctx->ExecuteFlag) {
979 (*ctx->Exec.Color4ub)( ctx, r, g, b, a );
980 }
981 }
982
983
gl_save_Color4ubv(GLcontext * ctx,const GLubyte * c)984 void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c )
985 {
986 Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
987 if (n) {
988 n[1].ub = c[0];
989 n[2].ub = c[1];
990 n[3].ub = c[2];
991 n[4].ub = c[3];
992 }
993 if (ctx->ExecuteFlag) {
994 (*ctx->Exec.Color4ubv)( ctx, c );
995 }
996 }
997
998
gl_save_ColorMask(GLcontext * ctx,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)999 void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
1000 GLboolean blue, GLboolean alpha )
1001 {
1002 Node *n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
1003 if (n) {
1004 n[1].b = red;
1005 n[2].b = green;
1006 n[3].b = blue;
1007 n[4].b = alpha;
1008 }
1009 if (ctx->ExecuteFlag) {
1010 (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha );
1011 }
1012 }
1013
1014
gl_save_ColorMaterial(GLcontext * ctx,GLenum face,GLenum mode)1015 void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
1016 {
1017 Node *n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
1018 if (n) {
1019 n[1].e = face;
1020 n[2].e = mode;
1021 }
1022 if (ctx->ExecuteFlag) {
1023 (*ctx->Exec.ColorMaterial)( ctx, face, mode );
1024 }
1025 }
1026
1027
gl_save_ColorTable(GLcontext * ctx,GLenum target,GLenum internalFormat,struct gl_image * table)1028 void gl_save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
1029 struct gl_image *table )
1030 {
1031 Node *n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
1032 if (n) {
1033 n[1].e = target;
1034 n[2].e = internalFormat;
1035 n[3].data = (GLvoid *) table;
1036 if (table) {
1037 /* must retain this image */
1038 table->RefCount = 1;
1039 }
1040 }
1041 if (ctx->ExecuteFlag) {
1042 (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table );
1043 }
1044 }
1045
1046
gl_save_ColorSubTable(GLcontext * ctx,GLenum target,GLsizei start,struct gl_image * data)1047 void gl_save_ColorSubTable( GLcontext *ctx, GLenum target,
1048 GLsizei start, struct gl_image *data )
1049 {
1050 Node *n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
1051 if (n) {
1052 n[1].e = target;
1053 n[2].i = start;
1054 n[3].data = (GLvoid *) data;
1055 if (data) {
1056 /* must retain this image */
1057 data->RefCount = 1;
1058 }
1059 }
1060 if (ctx->ExecuteFlag) {
1061 (*ctx->Exec.ColorSubTable)( ctx, target, start, data );
1062 }
1063 }
1064
1065
1066
gl_save_CopyPixels(GLcontext * ctx,GLint x,GLint y,GLsizei width,GLsizei height,GLenum type)1067 void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
1068 GLsizei width, GLsizei height, GLenum type )
1069 {
1070 Node *n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
1071 if (n) {
1072 n[1].i = x;
1073 n[2].i = y;
1074 n[3].i = (GLint) width;
1075 n[4].i = (GLint) height;
1076 n[5].e = type;
1077 }
1078 if (ctx->ExecuteFlag) {
1079 (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type );
1080 }
1081 }
1082
1083
1084
gl_save_CopyTexImage1D(GLcontext * ctx,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLint border)1085 void gl_save_CopyTexImage1D( GLcontext *ctx,
1086 GLenum target, GLint level,
1087 GLenum internalformat,
1088 GLint x, GLint y, GLsizei width,
1089 GLint border )
1090 {
1091 Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
1092 if (n) {
1093 n[1].e = target;
1094 n[2].i = level;
1095 n[3].e = internalformat;
1096 n[4].i = x;
1097 n[5].i = y;
1098 n[6].i = width;
1099 n[7].i = border;
1100 }
1101 if (ctx->ExecuteFlag) {
1102 (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat,
1103 x, y, width, border );
1104 }
1105 }
1106
1107
gl_save_CopyTexImage2D(GLcontext * ctx,GLenum target,GLint level,GLenum internalformat,GLint x,GLint y,GLsizei width,GLsizei height,GLint border)1108 void gl_save_CopyTexImage2D( GLcontext *ctx,
1109 GLenum target, GLint level,
1110 GLenum internalformat,
1111 GLint x, GLint y, GLsizei width,
1112 GLsizei height, GLint border )
1113 {
1114 Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
1115 if (n) {
1116 n[1].e = target;
1117 n[2].i = level;
1118 n[3].e = internalformat;
1119 n[4].i = x;
1120 n[5].i = y;
1121 n[6].i = width;
1122 n[7].i = height;
1123 n[8].i = border;
1124 }
1125 if (ctx->ExecuteFlag) {
1126 (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat,
1127 x, y, width, height, border );
1128 }
1129 }
1130
1131
1132
gl_save_CopyTexSubImage1D(GLcontext * ctx,GLenum target,GLint level,GLint xoffset,GLint x,GLint y,GLsizei width)1133 void gl_save_CopyTexSubImage1D( GLcontext *ctx,
1134 GLenum target, GLint level,
1135 GLint xoffset, GLint x, GLint y,
1136 GLsizei width )
1137 {
1138 Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
1139 if (n) {
1140 n[1].e = target;
1141 n[2].i = level;
1142 n[3].i = xoffset;
1143 n[4].i = x;
1144 n[5].i = y;
1145 n[6].i = width;
1146 }
1147 if (ctx->ExecuteFlag) {
1148 (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width );
1149 }
1150 }
1151
1152
gl_save_CopyTexSubImage2D(GLcontext * ctx,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint x,GLint y,GLsizei width,GLint height)1153 void gl_save_CopyTexSubImage2D( GLcontext *ctx,
1154 GLenum target, GLint level,
1155 GLint xoffset, GLint yoffset,
1156 GLint x, GLint y,
1157 GLsizei width, GLint height )
1158 {
1159 Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
1160 if (n) {
1161 n[1].e = target;
1162 n[2].i = level;
1163 n[3].i = xoffset;
1164 n[4].i = yoffset;
1165 n[5].i = x;
1166 n[6].i = y;
1167 n[7].i = width;
1168 n[8].i = height;
1169 }
1170 if (ctx->ExecuteFlag) {
1171 (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset,
1172 x, y, width, height );
1173 }
1174 }
1175
gl_save_CullFace(GLcontext * ctx,GLenum mode)1176 void gl_save_CullFace( GLcontext *ctx, GLenum mode )
1177 {
1178 Node *n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
1179 if (n) {
1180 n[1].e = mode;
1181 }
1182 if (ctx->ExecuteFlag) {
1183 (*ctx->Exec.CullFace)( ctx, mode );
1184 }
1185 }
1186
1187
gl_save_DepthFunc(GLcontext * ctx,GLenum func)1188 void gl_save_DepthFunc( GLcontext *ctx, GLenum func )
1189 {
1190 Node *n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
1191 if (n) {
1192 n[1].e = func;
1193 }
1194 if (ctx->ExecuteFlag) {
1195 (*ctx->Exec.DepthFunc)( ctx, func );
1196 }
1197 }
1198
1199
gl_save_DepthMask(GLcontext * ctx,GLboolean mask)1200 void gl_save_DepthMask( GLcontext *ctx, GLboolean mask )
1201 {
1202 Node *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)( ctx, mask );
1208 }
1209 }
1210
1211
gl_save_DepthRange(GLcontext * ctx,GLclampd nearval,GLclampd farval)1212 void gl_save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
1213 {
1214 Node *n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
1215 if (n) {
1216 n[1].f = (GLfloat) nearval;
1217 n[2].f = (GLfloat) farval;
1218 }
1219 if (ctx->ExecuteFlag) {
1220 (*ctx->Exec.DepthRange)( ctx, nearval, farval );
1221 }
1222 }
1223
1224
gl_save_Disable(GLcontext * ctx,GLenum cap)1225 void gl_save_Disable( GLcontext *ctx, GLenum cap )
1226 {
1227 Node *n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
1228 if (n) {
1229 n[1].e = cap;
1230 }
1231 if (ctx->ExecuteFlag) {
1232 (*ctx->Exec.Disable)( ctx, cap );
1233 }
1234 }
1235
1236
gl_save_DrawBuffer(GLcontext * ctx,GLenum mode)1237 void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode )
1238 {
1239 Node *n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
1240 if (n) {
1241 n[1].e = mode;
1242 }
1243 if (ctx->ExecuteFlag) {
1244 (*ctx->Exec.DrawBuffer)( ctx, mode );
1245 }
1246 }
1247
1248
gl_save_DrawPixels(GLcontext * ctx,GLsizei width,GLsizei height,GLenum format,GLenum type,const GLvoid * pixels)1249 void gl_save_DrawPixels( GLcontext *ctx, GLsizei width, GLsizei height,
1250 GLenum format, GLenum type, const GLvoid *pixels )
1251 {
1252 Node *n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 );
1253 if (n) {
1254 n[1].i = (GLint) width;
1255 n[2].i = (GLint) height;
1256 n[3].e = format;
1257 n[4].e = type;
1258 n[5].data = (GLvoid *) pixels;
1259 }
1260 /* Special case: gl_DrawPixels takes care of GL_COMPILE_AND_EXECUTE case!
1261 if (ctx->ExecuteFlag) {
1262 (*ctx->Exec.DrawPixels)( ctx, width, height, format, type, pixels );
1263 }
1264 */
1265 }
1266
1267
gl_save_EdgeFlag(GLcontext * ctx,GLboolean flag)1268 void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag )
1269 {
1270 Node *n = alloc_instruction( ctx, OPCODE_EDGE_FLAG, 1 );
1271 if (n) {
1272 n[1].b = flag;
1273 }
1274 if (ctx->ExecuteFlag) {
1275 (*ctx->Exec.EdgeFlag)( ctx, flag );
1276 }
1277 }
1278
1279
gl_save_Enable(GLcontext * ctx,GLenum cap)1280 void gl_save_Enable( GLcontext *ctx, GLenum cap )
1281 {
1282 Node *n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
1283 if (n) {
1284 n[1].e = cap;
1285 }
1286 if (ctx->ExecuteFlag) {
1287 (*ctx->Exec.Enable)( ctx, cap );
1288 }
1289 }
1290
1291
gl_save_End(GLcontext * ctx)1292 void gl_save_End( GLcontext *ctx )
1293 {
1294 (void) alloc_instruction( ctx, OPCODE_END, 0 );
1295 if (ctx->ExecuteFlag) {
1296 (*ctx->Exec.End)( ctx );
1297 }
1298 }
1299
1300
gl_save_EvalCoord1f(GLcontext * ctx,GLfloat u)1301 void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u )
1302 {
1303 Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD1, 1 );
1304 if (n) {
1305 n[1].f = u;
1306 }
1307 if (ctx->ExecuteFlag) {
1308 (*ctx->Exec.EvalCoord1f)( ctx, u );
1309 }
1310 }
1311
1312
gl_save_EvalCoord2f(GLcontext * ctx,GLfloat u,GLfloat v)1313 void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v )
1314 {
1315 Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD2, 2 );
1316 if (n) {
1317 n[1].f = u;
1318 n[2].f = v;
1319 }
1320 if (ctx->ExecuteFlag) {
1321 (*ctx->Exec.EvalCoord2f)( ctx, u, v );
1322 }
1323 }
1324
1325
gl_save_EvalMesh1(GLcontext * ctx,GLenum mode,GLint i1,GLint i2)1326 void gl_save_EvalMesh1( GLcontext *ctx,
1327 GLenum mode, GLint i1, GLint i2 )
1328 {
1329 Node *n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
1330 if (n) {
1331 n[1].e = mode;
1332 n[2].i = i1;
1333 n[3].i = i2;
1334 }
1335 if (ctx->ExecuteFlag) {
1336 (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 );
1337 }
1338 }
1339
1340
gl_save_EvalMesh2(GLcontext * ctx,GLenum mode,GLint i1,GLint i2,GLint j1,GLint j2)1341 void gl_save_EvalMesh2( GLcontext *ctx,
1342 GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
1343 {
1344 Node *n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
1345 if (n) {
1346 n[1].e = mode;
1347 n[2].i = i1;
1348 n[3].i = i2;
1349 n[4].i = j1;
1350 n[5].i = j2;
1351 }
1352 if (ctx->ExecuteFlag) {
1353 (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 );
1354 }
1355 }
1356
1357
gl_save_EvalPoint1(GLcontext * ctx,GLint i)1358 void gl_save_EvalPoint1( GLcontext *ctx, GLint i )
1359 {
1360 Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT1, 1 );
1361 if (n) {
1362 n[1].i = i;
1363 }
1364 if (ctx->ExecuteFlag) {
1365 (*ctx->Exec.EvalPoint1)( ctx, i );
1366 }
1367 }
1368
1369
gl_save_EvalPoint2(GLcontext * ctx,GLint i,GLint j)1370 void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j )
1371 {
1372 Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT2, 2 );
1373 if (n) {
1374 n[1].i = i;
1375 n[2].i = j;
1376 }
1377 if (ctx->ExecuteFlag) {
1378 (*ctx->Exec.EvalPoint2)( ctx, i, j );
1379 }
1380 }
1381
1382
gl_save_Fogfv(GLcontext * ctx,GLenum pname,const GLfloat * params)1383 void gl_save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
1384 {
1385 Node *n = alloc_instruction( ctx, OPCODE_FOG, 5 );
1386 if (n) {
1387 n[1].e = pname;
1388 n[2].f = params[0];
1389 n[3].f = params[1];
1390 n[4].f = params[2];
1391 n[5].f = params[3];
1392 }
1393 if (ctx->ExecuteFlag) {
1394 (*ctx->Exec.Fogfv)( ctx, pname, params );
1395 }
1396 }
1397
1398
gl_save_FrontFace(GLcontext * ctx,GLenum mode)1399 void gl_save_FrontFace( GLcontext *ctx, GLenum mode )
1400 {
1401 Node *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)( ctx, mode );
1407 }
1408 }
1409
1410
gl_save_Frustum(GLcontext * ctx,GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)1411 void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
1412 GLdouble bottom, GLdouble top,
1413 GLdouble nearval, GLdouble farval )
1414 {
1415 Node *n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
1416 if (n) {
1417 n[1].f = left;
1418 n[2].f = right;
1419 n[3].f = bottom;
1420 n[4].f = top;
1421 n[5].f = nearval;
1422 n[6].f = farval;
1423 }
1424 if (ctx->ExecuteFlag) {
1425 (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval );
1426 }
1427 }
1428
1429
gl_save_Hint(GLcontext * ctx,GLenum target,GLenum mode)1430 void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
1431 {
1432 Node *n = alloc_instruction( ctx, OPCODE_HINT, 2 );
1433 if (n) {
1434 n[1].e = target;
1435 n[2].e = mode;
1436 }
1437 if (ctx->ExecuteFlag) {
1438 (*ctx->Exec.Hint)( ctx, target, mode );
1439 }
1440 }
1441
1442
gl_save_Indexi(GLcontext * ctx,GLint index)1443 void gl_save_Indexi( GLcontext *ctx, GLint index )
1444 {
1445 Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
1446 if (n) {
1447 n[1].i = index;
1448 }
1449 if (ctx->ExecuteFlag) {
1450 (*ctx->Exec.Indexi)( ctx, index );
1451 }
1452 }
1453
1454
gl_save_Indexf(GLcontext * ctx,GLfloat index)1455 void gl_save_Indexf( GLcontext *ctx, GLfloat index )
1456 {
1457 Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
1458 if (n) {
1459 n[1].i = (GLint) index;
1460 }
1461 if (ctx->ExecuteFlag) {
1462 (*ctx->Exec.Indexf)( ctx,index );
1463 }
1464 }
1465
1466
gl_save_IndexMask(GLcontext * ctx,GLuint mask)1467 void gl_save_IndexMask( GLcontext *ctx, GLuint mask )
1468 {
1469 Node *n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
1470 if (n) {
1471 n[1].ui = mask;
1472 }
1473 if (ctx->ExecuteFlag) {
1474 (*ctx->Exec.IndexMask)( ctx, mask );
1475 }
1476 }
1477
1478
gl_save_InitNames(GLcontext * ctx)1479 void gl_save_InitNames( GLcontext *ctx )
1480 {
1481 (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
1482 if (ctx->ExecuteFlag) {
1483 (*ctx->Exec.InitNames)( ctx );
1484 }
1485 }
1486
1487
gl_save_Lightfv(GLcontext * ctx,GLenum light,GLenum pname,const GLfloat * params,GLint numparams)1488 void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
1489 const GLfloat *params, GLint numparams )
1490 {
1491 Node *n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
1492 if (OPCODE_LIGHT) {
1493 GLint i;
1494 n[1].e = light;
1495 n[2].e = pname;
1496 for (i=0;i<numparams;i++) {
1497 n[3+i].f = params[i];
1498 }
1499 }
1500 if (ctx->ExecuteFlag) {
1501 (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams );
1502 }
1503 }
1504
1505
gl_save_LightModelfv(GLcontext * ctx,GLenum pname,const GLfloat * params)1506 void gl_save_LightModelfv( GLcontext *ctx,
1507 GLenum pname, const GLfloat *params )
1508 {
1509 Node *n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
1510 if (n) {
1511 n[1].e = pname;
1512 n[2].f = params[0];
1513 n[3].f = params[1];
1514 n[4].f = params[2];
1515 n[5].f = params[3];
1516 }
1517 if (ctx->ExecuteFlag) {
1518 (*ctx->Exec.LightModelfv)( ctx, pname, params );
1519 }
1520 }
1521
1522
gl_save_LineStipple(GLcontext * ctx,GLint factor,GLushort pattern)1523 void gl_save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
1524 {
1525 Node *n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
1526 if (n) {
1527 n[1].i = factor;
1528 n[2].us = pattern;
1529 }
1530 if (ctx->ExecuteFlag) {
1531 (*ctx->Exec.LineStipple)( ctx, factor, pattern );
1532 }
1533 }
1534
1535
gl_save_LineWidth(GLcontext * ctx,GLfloat width)1536 void gl_save_LineWidth( GLcontext *ctx, GLfloat width )
1537 {
1538 Node *n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
1539 if (n) {
1540 n[1].f = width;
1541 }
1542 if (ctx->ExecuteFlag) {
1543 (*ctx->Exec.LineWidth)( ctx, width );
1544 }
1545 }
1546
1547
gl_save_ListBase(GLcontext * ctx,GLuint base)1548 void gl_save_ListBase( GLcontext *ctx, GLuint base )
1549 {
1550 Node *n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
1551 if (n) {
1552 n[1].ui = base;
1553 }
1554 if (ctx->ExecuteFlag) {
1555 (*ctx->Exec.ListBase)( ctx, base );
1556 }
1557 }
1558
1559
gl_save_LoadIdentity(GLcontext * ctx)1560 void gl_save_LoadIdentity( GLcontext *ctx )
1561 {
1562 (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
1563 if (ctx->ExecuteFlag) {
1564 (*ctx->Exec.LoadIdentity)( ctx );
1565 }
1566 }
1567
1568
gl_save_LoadMatrixf(GLcontext * ctx,const GLfloat * m)1569 void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
1570 {
1571 Node *n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
1572 if (n) {
1573 GLuint i;
1574 for (i=0;i<16;i++) {
1575 n[1+i].f = m[i];
1576 }
1577 }
1578 if (ctx->ExecuteFlag) {
1579 (*ctx->Exec.LoadMatrixf)( ctx, m );
1580 }
1581 }
1582
1583
gl_save_LoadName(GLcontext * ctx,GLuint name)1584 void gl_save_LoadName( GLcontext *ctx, GLuint name )
1585 {
1586 Node *n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
1587 if (n) {
1588 n[1].ui = name;
1589 }
1590 if (ctx->ExecuteFlag) {
1591 (*ctx->Exec.LoadName)( ctx, name );
1592 }
1593 }
1594
1595
gl_save_LogicOp(GLcontext * ctx,GLenum opcode)1596 void gl_save_LogicOp( GLcontext *ctx, GLenum opcode )
1597 {
1598 Node *n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
1599 if (n) {
1600 n[1].e = opcode;
1601 }
1602 if (ctx->ExecuteFlag) {
1603 (*ctx->Exec.LogicOp)( ctx, opcode );
1604 }
1605 }
1606
1607
gl_save_Map1f(GLcontext * ctx,GLenum target,GLfloat u1,GLfloat u2,GLint stride,GLint order,const GLfloat * points,GLboolean retain)1608 void gl_save_Map1f( GLcontext *ctx,
1609 GLenum target, GLfloat u1, GLfloat u2, GLint stride,
1610 GLint order, const GLfloat *points, GLboolean retain )
1611 {
1612 Node *n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
1613 if (n) {
1614 n[1].e = target;
1615 n[2].f = u1;
1616 n[3].f = u2;
1617 n[4].i = stride;
1618 n[5].i = order;
1619 n[6].data = (void *) points;
1620 }
1621 if (ctx->ExecuteFlag) {
1622 (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE );
1623 }
1624 }
1625
1626
gl_save_Map2f(GLcontext * ctx,GLenum target,GLfloat u1,GLfloat u2,GLint ustride,GLint uorder,GLfloat v1,GLfloat v2,GLint vstride,GLint vorder,const GLfloat * points,GLboolean retain)1627 void gl_save_Map2f( GLcontext *ctx, GLenum target,
1628 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
1629 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
1630 const GLfloat *points, GLboolean retain )
1631 {
1632 Node *n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
1633 if (n) {
1634 n[1].e = target;
1635 n[2].f = u1;
1636 n[3].f = u2;
1637 n[4].f = v1;
1638 n[5].f = v2;
1639 n[6].i = ustride;
1640 n[7].i = vstride;
1641 n[8].i = uorder;
1642 n[9].i = vorder;
1643 n[10].data = (void *) points;
1644 }
1645 if (ctx->ExecuteFlag) {
1646 (*ctx->Exec.Map2f)( ctx, target,
1647 u1, u2, ustride, uorder,
1648 v1, v2, vstride, vorder, points, GL_TRUE );
1649 }
1650 }
1651
1652
gl_save_MapGrid1f(GLcontext * ctx,GLint un,GLfloat u1,GLfloat u2)1653 void gl_save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
1654 {
1655 Node *n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
1656 if (n) {
1657 n[1].i = un;
1658 n[2].f = u1;
1659 n[3].f = u2;
1660 }
1661 if (ctx->ExecuteFlag) {
1662 (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 );
1663 }
1664 }
1665
1666
gl_save_MapGrid2f(GLcontext * ctx,GLint un,GLfloat u1,GLfloat u2,GLint vn,GLfloat v1,GLfloat v2)1667 void gl_save_MapGrid2f( GLcontext *ctx,
1668 GLint un, GLfloat u1, GLfloat u2,
1669 GLint vn, GLfloat v1, GLfloat v2 )
1670 {
1671 Node *n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
1672 if (n) {
1673 n[1].i = un;
1674 n[2].f = u1;
1675 n[3].f = u2;
1676 n[4].i = vn;
1677 n[5].f = v1;
1678 n[6].f = v2;
1679 }
1680 if (ctx->ExecuteFlag) {
1681 (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 );
1682 }
1683 }
1684
1685
gl_save_Materialfv(GLcontext * ctx,GLenum face,GLenum pname,const GLfloat * params)1686 void gl_save_Materialfv( GLcontext *ctx,
1687 GLenum face, GLenum pname, const GLfloat *params )
1688 {
1689 Node *n = alloc_instruction( ctx, OPCODE_MATERIAL, 6 );
1690 if (n) {
1691 n[1].e = face;
1692 n[2].e = pname;
1693 n[3].f = params[0];
1694 n[4].f = params[1];
1695 n[5].f = params[2];
1696 n[6].f = params[3];
1697 }
1698 if (ctx->ExecuteFlag) {
1699 (*ctx->Exec.Materialfv)( ctx, face, pname, params );
1700 }
1701 }
1702
1703
gl_save_MatrixMode(GLcontext * ctx,GLenum mode)1704 void gl_save_MatrixMode( GLcontext *ctx, GLenum mode )
1705 {
1706 Node *n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
1707 if (n) {
1708 n[1].e = mode;
1709 }
1710 if (ctx->ExecuteFlag) {
1711 (*ctx->Exec.MatrixMode)( ctx, mode );
1712 }
1713 }
1714
1715
gl_save_MultMatrixf(GLcontext * ctx,const GLfloat * m)1716 void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
1717 {
1718 Node *n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
1719 if (n) {
1720 GLuint i;
1721 for (i=0;i<16;i++) {
1722 n[1+i].f = m[i];
1723 }
1724 }
1725 if (ctx->ExecuteFlag) {
1726 (*ctx->Exec.MultMatrixf)( ctx, m );
1727 }
1728 }
1729
1730
gl_save_NewList(GLcontext * ctx,GLuint list,GLenum mode)1731 void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
1732 {
1733 /* It's an error to call this function while building a display list */
1734 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
1735 }
1736
1737
gl_save_Normal3fv(GLcontext * ctx,const GLfloat norm[3])1738 void gl_save_Normal3fv( GLcontext *ctx, const GLfloat norm[3] )
1739 {
1740 Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
1741 if (n) {
1742 n[1].f = norm[0];
1743 n[2].f = norm[1];
1744 n[3].f = norm[2];
1745 }
1746 if (ctx->ExecuteFlag) {
1747 (*ctx->Exec.Normal3fv)( ctx, norm );
1748 }
1749 }
1750
1751
gl_save_Normal3f(GLcontext * ctx,GLfloat nx,GLfloat ny,GLfloat nz)1752 void gl_save_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz )
1753 {
1754 Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
1755 if (n) {
1756 n[1].f = nx;
1757 n[2].f = ny;
1758 n[3].f = nz;
1759 }
1760 if (ctx->ExecuteFlag) {
1761 (*ctx->Exec.Normal3f)( ctx, nx, ny, nz );
1762 }
1763 }
1764
1765
gl_save_Ortho(GLcontext * ctx,GLdouble left,GLdouble right,GLdouble bottom,GLdouble top,GLdouble nearval,GLdouble farval)1766 void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
1767 GLdouble bottom, GLdouble top,
1768 GLdouble nearval, GLdouble farval )
1769 {
1770 Node *n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
1771 if (n) {
1772 n[1].f = left;
1773 n[2].f = right;
1774 n[3].f = bottom;
1775 n[4].f = top;
1776 n[5].f = nearval;
1777 n[6].f = farval;
1778 }
1779 if (ctx->ExecuteFlag) {
1780 (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval );
1781 }
1782 }
1783
1784
gl_save_PixelMapfv(GLcontext * ctx,GLenum map,GLint mapsize,const GLfloat * values)1785 void gl_save_PixelMapfv( GLcontext *ctx,
1786 GLenum map, GLint mapsize, const GLfloat *values )
1787 {
1788 Node *n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
1789 if (n) {
1790 n[1].e = map;
1791 n[2].i = mapsize;
1792 n[3].data = (void *) malloc( mapsize * sizeof(GLfloat) );
1793 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
1794 }
1795 if (ctx->ExecuteFlag) {
1796 (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values );
1797 }
1798 }
1799
1800
gl_save_PixelTransferf(GLcontext * ctx,GLenum pname,GLfloat param)1801 void gl_save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
1802 {
1803 Node *n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
1804 if (n) {
1805 n[1].e = pname;
1806 n[2].f = param;
1807 }
1808 if (ctx->ExecuteFlag) {
1809 (*ctx->Exec.PixelTransferf)( ctx, pname, param );
1810 }
1811 }
1812
1813
gl_save_PixelZoom(GLcontext * ctx,GLfloat xfactor,GLfloat yfactor)1814 void gl_save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
1815 {
1816 Node *n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
1817 if (n) {
1818 n[1].f = xfactor;
1819 n[2].f = yfactor;
1820 }
1821 if (ctx->ExecuteFlag) {
1822 (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor );
1823 }
1824 }
1825
1826
gl_save_PointSize(GLcontext * ctx,GLfloat size)1827 void gl_save_PointSize( GLcontext *ctx, GLfloat size )
1828 {
1829 Node *n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
1830 if (n) {
1831 n[1].f = size;
1832 }
1833 if (ctx->ExecuteFlag) {
1834 (*ctx->Exec.PointSize)( ctx, size );
1835 }
1836 }
1837
1838
gl_save_PolygonMode(GLcontext * ctx,GLenum face,GLenum mode)1839 void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
1840 {
1841 Node *n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
1842 if (n) {
1843 n[1].e = face;
1844 n[2].e = mode;
1845 }
1846 if (ctx->ExecuteFlag) {
1847 (*ctx->Exec.PolygonMode)( ctx, face, mode );
1848 }
1849 }
1850
1851
gl_save_PolygonStipple(GLcontext * ctx,const GLubyte * mask)1852 void gl_save_PolygonStipple( GLcontext *ctx, const GLubyte *mask )
1853 {
1854 Node *n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
1855 if (n) {
1856 void *data;
1857 n[1].data = malloc( 32 * 4 );
1858 data = n[1].data; /* This needed for Acorn compiler */
1859 MEMCPY( data, mask, 32 * 4 );
1860 }
1861 if (ctx->ExecuteFlag) {
1862 (*ctx->Exec.PolygonStipple)( ctx, mask );
1863 }
1864 }
1865
1866
gl_save_PolygonOffset(GLcontext * ctx,GLfloat factor,GLfloat units)1867 void gl_save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
1868 {
1869 Node *n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
1870 if (n) {
1871 n[1].f = factor;
1872 n[2].f = units;
1873 }
1874 if (ctx->ExecuteFlag) {
1875 (*ctx->Exec.PolygonOffset)( ctx, factor, units );
1876 }
1877 }
1878
1879
gl_save_PopAttrib(GLcontext * ctx)1880 void gl_save_PopAttrib( GLcontext *ctx )
1881 {
1882 (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
1883 if (ctx->ExecuteFlag) {
1884 (*ctx->Exec.PopAttrib)( ctx );
1885 }
1886 }
1887
1888
gl_save_PopMatrix(GLcontext * ctx)1889 void gl_save_PopMatrix( GLcontext *ctx )
1890 {
1891 (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
1892 if (ctx->ExecuteFlag) {
1893 (*ctx->Exec.PopMatrix)( ctx );
1894 }
1895 }
1896
1897
gl_save_PopName(GLcontext * ctx)1898 void gl_save_PopName( GLcontext *ctx )
1899 {
1900 (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
1901 if (ctx->ExecuteFlag) {
1902 (*ctx->Exec.PopName)( ctx );
1903 }
1904 }
1905
1906
gl_save_PrioritizeTextures(GLcontext * ctx,GLsizei num,const GLuint * textures,const GLclampf * priorities)1907 void gl_save_PrioritizeTextures( GLcontext *ctx,
1908 GLsizei num, const GLuint *textures,
1909 const GLclampf *priorities )
1910 {
1911 GLint i;
1912
1913 for (i=0;i<num;i++) {
1914 Node *n = alloc_instruction( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
1915 if (n) {
1916 n[1].ui = textures[i];
1917 n[2].f = priorities[i];
1918 }
1919 }
1920 if (ctx->ExecuteFlag) {
1921 (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities );
1922 }
1923 }
1924
1925
gl_save_PushAttrib(GLcontext * ctx,GLbitfield mask)1926 void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask )
1927 {
1928 Node *n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
1929 if (n) {
1930 n[1].bf = mask;
1931 }
1932 if (ctx->ExecuteFlag) {
1933 (*ctx->Exec.PushAttrib)( ctx, mask );
1934 }
1935 }
1936
1937
gl_save_PushMatrix(GLcontext * ctx)1938 void gl_save_PushMatrix( GLcontext *ctx )
1939 {
1940 (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
1941 if (ctx->ExecuteFlag) {
1942 (*ctx->Exec.PushMatrix)( ctx );
1943 }
1944 }
1945
1946
gl_save_PushName(GLcontext * ctx,GLuint name)1947 void gl_save_PushName( GLcontext *ctx, GLuint name )
1948 {
1949 Node *n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
1950 if (n) {
1951 n[1].ui = name;
1952 }
1953 if (ctx->ExecuteFlag) {
1954 (*ctx->Exec.PushName)( ctx, name );
1955 }
1956 }
1957
1958
gl_save_RasterPos4f(GLcontext * ctx,GLfloat x,GLfloat y,GLfloat z,GLfloat w)1959 void gl_save_RasterPos4f( GLcontext *ctx,
1960 GLfloat x, GLfloat y, GLfloat z, GLfloat w )
1961 {
1962 Node *n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
1963 if (n) {
1964 n[1].f = x;
1965 n[2].f = y;
1966 n[3].f = z;
1967 n[4].f = w;
1968 }
1969 if (ctx->ExecuteFlag) {
1970 (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w );
1971 }
1972 }
1973
1974
gl_save_PassThrough(GLcontext * ctx,GLfloat token)1975 void gl_save_PassThrough( GLcontext *ctx, GLfloat token )
1976 {
1977 Node *n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
1978 if (n) {
1979 n[1].f = token;
1980 }
1981 if (ctx->ExecuteFlag) {
1982 (*ctx->Exec.PassThrough)( ctx, token );
1983 }
1984 }
1985
1986
gl_save_ReadBuffer(GLcontext * ctx,GLenum mode)1987 void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode )
1988 {
1989 Node *n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
1990 if (n) {
1991 n[1].e = mode;
1992 }
1993 if (ctx->ExecuteFlag) {
1994 (*ctx->Exec.ReadBuffer)( ctx, mode );
1995 }
1996 }
1997
1998
gl_save_Rectf(GLcontext * ctx,GLfloat x1,GLfloat y1,GLfloat x2,GLfloat y2)1999 void gl_save_Rectf( GLcontext *ctx,
2000 GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
2001 {
2002 Node *n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
2003 if (n) {
2004 n[1].f = x1;
2005 n[2].f = y1;
2006 n[3].f = x2;
2007 n[4].f = y2;
2008 }
2009 if (ctx->ExecuteFlag) {
2010 (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 );
2011 }
2012 }
2013
2014
gl_save_Rotatef(GLcontext * ctx,GLfloat angle,GLfloat x,GLfloat y,GLfloat z)2015 void gl_save_Rotatef( GLcontext *ctx, GLfloat angle,
2016 GLfloat x, GLfloat y, GLfloat z )
2017 {
2018 GLfloat m[16];
2019 gl_rotation_matrix( angle, x, y, z, m );
2020 gl_save_MultMatrixf( ctx, m ); /* save and maybe execute */
2021 }
2022
2023
gl_save_Scalef(GLcontext * ctx,GLfloat x,GLfloat y,GLfloat z)2024 void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
2025 {
2026 Node *n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
2027 if (n) {
2028 n[1].f = x;
2029 n[2].f = y;
2030 n[3].f = z;
2031 }
2032 if (ctx->ExecuteFlag) {
2033 (*ctx->Exec.Scalef)( ctx, x, y, z );
2034 }
2035 }
2036
2037
gl_save_Scissor(GLcontext * ctx,GLint x,GLint y,GLsizei width,GLsizei height)2038 void gl_save_Scissor( GLcontext *ctx,
2039 GLint x, GLint y, GLsizei width, GLsizei height )
2040 {
2041 Node *n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
2042 if (n) {
2043 n[1].i = x;
2044 n[2].i = y;
2045 n[3].i = width;
2046 n[4].i = height;
2047 }
2048 if (ctx->ExecuteFlag) {
2049 (*ctx->Exec.Scissor)( ctx, x, y, width, height );
2050 }
2051 }
2052
2053
gl_save_ShadeModel(GLcontext * ctx,GLenum mode)2054 void gl_save_ShadeModel( GLcontext *ctx, GLenum mode )
2055 {
2056 Node *n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
2057 if (n) {
2058 n[1].e = mode;
2059 }
2060 if (ctx->ExecuteFlag) {
2061 (*ctx->Exec.ShadeModel)( ctx, mode );
2062 }
2063 }
2064
2065
gl_save_StencilFunc(GLcontext * ctx,GLenum func,GLint ref,GLuint mask)2066 void gl_save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
2067 {
2068 Node *n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
2069 if (n) {
2070 n[1].e = func;
2071 n[2].i = ref;
2072 n[3].ui = mask;
2073 }
2074 if (ctx->ExecuteFlag) {
2075 (*ctx->Exec.StencilFunc)( ctx, func, ref, mask );
2076 }
2077 }
2078
2079
gl_save_StencilMask(GLcontext * ctx,GLuint mask)2080 void gl_save_StencilMask( GLcontext *ctx, GLuint mask )
2081 {
2082 Node *n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
2083 if (n) {
2084 n[1].ui = mask;
2085 }
2086 if (ctx->ExecuteFlag) {
2087 (*ctx->Exec.StencilMask)( ctx, mask );
2088 }
2089 }
2090
2091
gl_save_StencilOp(GLcontext * ctx,GLenum fail,GLenum zfail,GLenum zpass)2092 void gl_save_StencilOp( GLcontext *ctx,
2093 GLenum fail, GLenum zfail, GLenum zpass )
2094 {
2095 Node *n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
2096 if (n) {
2097 n[1].e = fail;
2098 n[2].e = zfail;
2099 n[3].e = zpass;
2100 }
2101 if (ctx->ExecuteFlag) {
2102 (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass );
2103 }
2104 }
2105
2106
gl_save_TexCoord2f(GLcontext * ctx,GLfloat s,GLfloat t)2107 void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t )
2108 {
2109 Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD2, 2 );
2110 if (n) {
2111 n[1].f = s;
2112 n[2].f = t;
2113 }
2114 if (ctx->ExecuteFlag) {
2115 (*ctx->Exec.TexCoord2f)( ctx, s, t );
2116 }
2117 }
2118
2119
gl_save_TexCoord4f(GLcontext * ctx,GLfloat s,GLfloat t,GLfloat r,GLfloat q)2120 void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t,
2121 GLfloat r, GLfloat q )
2122 {
2123 Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD4, 4 );
2124 if (n) {
2125 n[1].f = s;
2126 n[2].f = t;
2127 n[3].f = r;
2128 n[4].f = q;
2129 }
2130 if (ctx->ExecuteFlag) {
2131 (*ctx->Exec.TexCoord4f)( ctx, s, t, r, q );
2132 }
2133 }
2134
2135
gl_save_TexEnvfv(GLcontext * ctx,GLenum target,GLenum pname,const GLfloat * params)2136 void gl_save_TexEnvfv( GLcontext *ctx,
2137 GLenum target, GLenum pname, const GLfloat *params )
2138 {
2139 Node *n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
2140 if (n) {
2141 n[1].e = target;
2142 n[2].e = pname;
2143 n[3].f = params[0];
2144 n[4].f = params[1];
2145 n[5].f = params[2];
2146 n[6].f = params[3];
2147 }
2148 if (ctx->ExecuteFlag) {
2149 (*ctx->Exec.TexEnvfv)( ctx, target, pname, params );
2150 }
2151 }
2152
2153
gl_save_TexGenfv(GLcontext * ctx,GLenum coord,GLenum pname,const GLfloat * params)2154 void gl_save_TexGenfv( GLcontext *ctx,
2155 GLenum coord, GLenum pname, const GLfloat *params )
2156 {
2157 Node *n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
2158 if (n) {
2159 n[1].e = coord;
2160 n[2].e = pname;
2161 n[3].f = params[0];
2162 n[4].f = params[1];
2163 n[5].f = params[2];
2164 n[6].f = params[3];
2165 }
2166 if (ctx->ExecuteFlag) {
2167 (*ctx->Exec.TexGenfv)( ctx, coord, pname, params );
2168 }
2169 }
2170
2171
gl_save_TexParameterfv(GLcontext * ctx,GLenum target,GLenum pname,const GLfloat * params)2172 void gl_save_TexParameterfv( GLcontext *ctx, GLenum target,
2173 GLenum pname, const GLfloat *params )
2174 {
2175 Node *n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
2176 if (n) {
2177 n[1].e = target;
2178 n[2].e = pname;
2179 n[3].f = params[0];
2180 n[4].f = params[1];
2181 n[5].f = params[2];
2182 n[6].f = params[3];
2183 }
2184 if (ctx->ExecuteFlag) {
2185 (*ctx->Exec.TexParameterfv)( ctx, target, pname, params );
2186 }
2187 }
2188
2189
gl_save_TexImage1D(GLcontext * ctx,GLenum target,GLint level,GLint components,GLsizei width,GLint border,GLenum format,GLenum type,struct gl_image * teximage)2190 void gl_save_TexImage1D( GLcontext *ctx, GLenum target,
2191 GLint level, GLint components,
2192 GLsizei width, GLint border,
2193 GLenum format, GLenum type,
2194 struct gl_image *teximage )
2195 {
2196 Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
2197 if (n) {
2198 n[1].e = target;
2199 n[2].i = level;
2200 n[3].i = components;
2201 n[4].i = (GLint) width;
2202 n[5].i = border;
2203 n[6].e = format;
2204 n[7].e = type;
2205 n[8].data = teximage;
2206 if (teximage) {
2207 /* this prevents gl_TexImage2D() from freeing the image */
2208 teximage->RefCount = 1;
2209 }
2210 }
2211 if (ctx->ExecuteFlag) {
2212 (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
2213 border, format, type, teximage );
2214 }
2215 }
2216
2217
gl_save_TexImage2D(GLcontext * ctx,GLenum target,GLint level,GLint components,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,struct gl_image * teximage)2218 void gl_save_TexImage2D( GLcontext *ctx, GLenum target,
2219 GLint level, GLint components,
2220 GLsizei width, GLsizei height, GLint border,
2221 GLenum format, GLenum type,
2222 struct gl_image *teximage )
2223 {
2224 Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
2225 if (n) {
2226 n[1].e = target;
2227 n[2].i = level;
2228 n[3].i = components;
2229 n[4].i = (GLint) width;
2230 n[5].i = (GLint) height;
2231 n[6].i = border;
2232 n[7].e = format;
2233 n[8].e = type;
2234 n[9].data = teximage;
2235 if (teximage) {
2236 /* this prevents gl_TexImage2D() from freeing the image */
2237 teximage->RefCount = 1;
2238 }
2239 }
2240 if (ctx->ExecuteFlag) {
2241 (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
2242 height, border, format, type, teximage );
2243 }
2244 }
2245
2246
gl_save_TexSubImage1D(GLcontext * ctx,GLenum target,GLint level,GLint xoffset,GLsizei width,GLenum format,GLenum type,struct gl_image * image)2247 void gl_save_TexSubImage1D( GLcontext *ctx,
2248 GLenum target, GLint level, GLint xoffset,
2249 GLsizei width, GLenum format, GLenum type,
2250 struct gl_image *image )
2251 {
2252 Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
2253 if (n) {
2254 n[1].e = target;
2255 n[2].i = level;
2256 n[3].i = xoffset;
2257 n[4].i = (GLint) width;
2258 n[5].e = format;
2259 n[6].e = type;
2260 n[7].data = image;
2261 if (image)
2262 image->RefCount = 1;
2263 }
2264 if (ctx->ExecuteFlag) {
2265 (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width,
2266 format, type, image );
2267 }
2268 }
2269
2270
gl_save_TexSubImage2D(GLcontext * ctx,GLenum target,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,struct gl_image * image)2271 void gl_save_TexSubImage2D( GLcontext *ctx,
2272 GLenum target, GLint level,
2273 GLint xoffset, GLint yoffset,
2274 GLsizei width, GLsizei height,
2275 GLenum format, GLenum type,
2276 struct gl_image *image )
2277 {
2278 Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
2279 if (n) {
2280 n[1].e = target;
2281 n[2].i = level;
2282 n[3].i = xoffset;
2283 n[4].i = yoffset;
2284 n[5].i = (GLint) width;
2285 n[6].i = (GLint) height;
2286 n[7].e = format;
2287 n[8].e = type;
2288 n[9].data = image;
2289 if (image)
2290 image->RefCount = 1;
2291 }
2292 if (ctx->ExecuteFlag) {
2293 (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset,
2294 width, height, format, type, image );
2295 }
2296 }
2297
2298
gl_save_Translatef(GLcontext * ctx,GLfloat x,GLfloat y,GLfloat z)2299 void gl_save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
2300 {
2301 Node *n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 );
2302 if (n) {
2303 n[1].f = x;
2304 n[2].f = y;
2305 n[3].f = z;
2306 }
2307 if (ctx->ExecuteFlag) {
2308 (*ctx->Exec.Translatef)( ctx, x, y, z );
2309 }
2310 }
2311
2312
gl_save_Vertex2f(GLcontext * ctx,GLfloat x,GLfloat y)2313 void gl_save_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y )
2314 {
2315 Node *n = alloc_instruction( ctx, OPCODE_VERTEX2, 2 );
2316 if (n) {
2317 n[1].f = x;
2318 n[2].f = y;
2319 }
2320 if (ctx->ExecuteFlag) {
2321 (*ctx->Exec.Vertex2f)( ctx, x, y );
2322 }
2323 }
2324
2325
gl_save_Vertex3f(GLcontext * ctx,GLfloat x,GLfloat y,GLfloat z)2326 void gl_save_Vertex3f( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
2327 {
2328 Node *n = alloc_instruction( ctx, OPCODE_VERTEX3, 3 );
2329 if (n) {
2330 n[1].f = x;
2331 n[2].f = y;
2332 n[3].f = z;
2333 }
2334 if (ctx->ExecuteFlag) {
2335 (*ctx->Exec.Vertex3f)( ctx, x, y, z );
2336 }
2337 }
2338
2339
gl_save_Vertex4f(GLcontext * ctx,GLfloat x,GLfloat y,GLfloat z,GLfloat w)2340 void gl_save_Vertex4f( GLcontext *ctx,
2341 GLfloat x, GLfloat y, GLfloat z, GLfloat w )
2342 {
2343 Node *n = alloc_instruction( ctx, OPCODE_VERTEX4, 4 );
2344 if (n) {
2345 n[1].f = x;
2346 n[2].f = y;
2347 n[3].f = z;
2348 n[4].f = w;
2349 }
2350 if (ctx->ExecuteFlag) {
2351 (*ctx->Exec.Vertex4f)( ctx, x, y, z, w );
2352 }
2353 }
2354
2355
gl_save_Vertex3fv(GLcontext * ctx,const GLfloat v[3])2356 void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat v[3] )
2357 {
2358 Node *n = alloc_instruction( ctx, OPCODE_VERTEX3, 3 );
2359 if (n) {
2360 n[1].f = v[0];
2361 n[2].f = v[1];
2362 n[3].f = v[2];
2363 }
2364 if (ctx->ExecuteFlag) {
2365 (*ctx->Exec.Vertex3fv)( ctx, v );
2366 }
2367 }
2368
2369
gl_save_Viewport(GLcontext * ctx,GLint x,GLint y,GLsizei width,GLsizei height)2370 void gl_save_Viewport( GLcontext *ctx,
2371 GLint x, GLint y, GLsizei width, GLsizei height )
2372 {
2373 Node *n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 );
2374 if (n) {
2375 n[1].i = x;
2376 n[2].i = y;
2377 n[3].i = (GLint) width;
2378 n[4].i = (GLint) height;
2379 }
2380 if (ctx->ExecuteFlag) {
2381 (*ctx->Exec.Viewport)( ctx, x, y, width, height );
2382 }
2383 }
2384
2385
2386 /**********************************************************************/
2387 /* Display list execution */
2388 /**********************************************************************/
2389
2390
2391 /*
2392 * Execute a display list. Note that the ListBase offset must have already
2393 * been added before calling this function. I.e. the list argument is
2394 * the absolute list number, not relative to ListBase.
2395 * Input: list - display list number
2396 */
execute_list(GLcontext * ctx,GLuint list)2397 static void execute_list( GLcontext *ctx, GLuint list )
2398 {
2399 Node *n;
2400 GLboolean done;
2401 OpCode opcode;
2402
2403 if (!gl_IsList(ctx,list))
2404 return;
2405
2406 ctx->CallDepth++;
2407
2408 n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
2409
2410 done = GL_FALSE;
2411 while (!done) {
2412 opcode = n[0].opcode;
2413
2414 switch (opcode) {
2415 /* Frequently called functions: */
2416 case OPCODE_VERTEX2:
2417 (*ctx->Exec.Vertex2f)( ctx, n[1].f, n[2].f );
2418 break;
2419 case OPCODE_VERTEX3:
2420 (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f );
2421 break;
2422 case OPCODE_VERTEX4:
2423 (*ctx->Exec.Vertex4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2424 break;
2425 case OPCODE_NORMAL:
2426 ctx->Current.Normal[0] = n[1].f;
2427 ctx->Current.Normal[1] = n[2].f;
2428 ctx->Current.Normal[2] = n[3].f;
2429 ctx->VB->MonoNormal = GL_FALSE;
2430 break;
2431 case OPCODE_COLOR_4UB:
2432 (*ctx->Exec.Color4ub)( ctx, n[1].ub, n[2].ub, n[3].ub, n[4].ub );
2433 break;
2434 case OPCODE_COLOR_3F:
2435 (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f );
2436 break;
2437 case OPCODE_COLOR_4F:
2438 (*ctx->Exec.Color4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2439 break;
2440 case OPCODE_INDEX:
2441 ctx->Current.Index = n[1].ui;
2442 ctx->VB->MonoColor = GL_FALSE;
2443 break;
2444 case OPCODE_BEGIN:
2445 gl_Begin( ctx, n[1].e );
2446 break;
2447 case OPCODE_END:
2448 gl_End( ctx );
2449 break;
2450 case OPCODE_TEXCOORD2:
2451 ctx->Current.TexCoord[0] = n[1].f;
2452 ctx->Current.TexCoord[1] = n[2].f;
2453 if (ctx->VB->TexCoordSize==4) {
2454 ctx->Current.TexCoord[2] = 0.0F;
2455 ctx->Current.TexCoord[3] = 1.0F;
2456 }
2457 break;
2458 case OPCODE_TEXCOORD4:
2459 ctx->Current.TexCoord[0] = n[1].f;
2460 ctx->Current.TexCoord[1] = n[2].f;
2461 ctx->Current.TexCoord[2] = n[3].f;
2462 ctx->Current.TexCoord[3] = n[4].f;
2463 if (ctx->VB->TexCoordSize==2) {
2464 /* Switch to 4-component texcoords */
2465 ctx->VB->TexCoordSize = 4;
2466 gl_set_vertex_function(ctx);
2467 }
2468 break;
2469
2470 /* Everything Else: */
2471 case OPCODE_ACCUM:
2472 gl_Accum( ctx, n[1].e, n[2].f );
2473 break;
2474 case OPCODE_ALPHA_FUNC:
2475 gl_AlphaFunc( ctx, n[1].e, n[2].f );
2476 break;
2477 case OPCODE_BIND_TEXTURE:
2478 gl_BindTexture( ctx, n[1].e, n[2].ui );
2479 break;
2480 case OPCODE_BITMAP:
2481 gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
2482 n[3].f, n[4].f,
2483 n[5].f, n[6].f,
2484 (struct gl_image *) n[7].data );
2485 break;
2486 case OPCODE_BLEND_FUNC:
2487 gl_BlendFunc( ctx, n[1].e, n[2].e );
2488 break;
2489 case OPCODE_CALL_LIST:
2490 /* Generated by glCallList(), don't add ListBase */
2491 if (ctx->CallDepth<MAX_LIST_NESTING) {
2492 execute_list( ctx, n[1].ui );
2493 }
2494 break;
2495 case OPCODE_CALL_LIST_OFFSET:
2496 /* Generated by glCallLists() so we must add ListBase */
2497 if (ctx->CallDepth<MAX_LIST_NESTING) {
2498 execute_list( ctx, ctx->List.ListBase + n[1].ui );
2499 }
2500 break;
2501 case OPCODE_CLEAR:
2502 gl_Clear( ctx, n[1].bf );
2503 break;
2504 case OPCODE_CLEAR_COLOR:
2505 gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2506 break;
2507 case OPCODE_CLEAR_ACCUM:
2508 gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2509 break;
2510 case OPCODE_CLEAR_DEPTH:
2511 gl_ClearDepth( ctx, (GLclampd) n[1].f );
2512 break;
2513 case OPCODE_CLEAR_INDEX:
2514 gl_ClearIndex( ctx, n[1].ui );
2515 break;
2516 case OPCODE_CLEAR_STENCIL:
2517 gl_ClearStencil( ctx, n[1].i );
2518 break;
2519 case OPCODE_CLIP_PLANE:
2520 {
2521 GLfloat equ[4];
2522 equ[0] = n[2].f;
2523 equ[1] = n[3].f;
2524 equ[2] = n[4].f;
2525 equ[3] = n[5].f;
2526 gl_ClipPlane( ctx, n[1].e, equ );
2527 }
2528 break;
2529 case OPCODE_COLOR_MASK:
2530 gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b );
2531 break;
2532 case OPCODE_COLOR_MATERIAL:
2533 gl_ColorMaterial( ctx, n[1].e, n[2].e );
2534 break;
2535 case OPCODE_COLOR_TABLE:
2536 gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data);
2537 break;
2538 case OPCODE_COLOR_SUB_TABLE:
2539 gl_ColorSubTable( ctx, n[1].e, n[2].i,
2540 (struct gl_image *) n[3].data);
2541 break;
2542 case OPCODE_COPY_PIXELS:
2543 gl_CopyPixels( ctx, n[1].i, n[2].i,
2544 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
2545 break;
2546 case OPCODE_COPY_TEX_IMAGE1D:
2547 gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
2548 n[5].i, n[6].i, n[7].i );
2549 break;
2550 case OPCODE_COPY_TEX_IMAGE2D:
2551 gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
2552 n[5].i, n[6].i, n[7].i, n[8].i );
2553 break;
2554 case OPCODE_COPY_TEX_SUB_IMAGE1D:
2555 gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
2556 n[5].i, n[6].i );
2557 break;
2558 case OPCODE_COPY_TEX_SUB_IMAGE2D:
2559 gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
2560 n[5].i, n[6].i, n[7].i, n[8].i );
2561 break;
2562 case OPCODE_CULL_FACE:
2563 gl_CullFace( ctx, n[1].e );
2564 break;
2565 case OPCODE_DEPTH_FUNC:
2566 gl_DepthFunc( ctx, n[1].e );
2567 break;
2568 case OPCODE_DEPTH_MASK:
2569 gl_DepthMask( ctx, n[1].b );
2570 break;
2571 case OPCODE_DEPTH_RANGE:
2572 gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f );
2573 break;
2574 case OPCODE_DISABLE:
2575 gl_Disable( ctx, n[1].e );
2576 break;
2577 case OPCODE_DRAW_BUFFER:
2578 gl_DrawBuffer( ctx, n[1].e );
2579 break;
2580 case OPCODE_DRAW_PIXELS:
2581 gl_DrawPixels( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
2582 n[3].e, n[4].e, n[5].data );
2583 break;
2584 case OPCODE_EDGE_FLAG:
2585 ctx->Current.EdgeFlag = n[1].b;
2586 break;
2587 case OPCODE_ENABLE:
2588 gl_Enable( ctx, n[1].e );
2589 break;
2590 case OPCODE_EVALCOORD1:
2591 gl_EvalCoord1f( ctx, n[1].f );
2592 break;
2593 case OPCODE_EVALCOORD2:
2594 gl_EvalCoord2f( ctx, n[1].f, n[2].f );
2595 break;
2596 case OPCODE_EVALMESH1:
2597 gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i );
2598 break;
2599 case OPCODE_EVALMESH2:
2600 gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
2601 break;
2602 case OPCODE_EVALPOINT1:
2603 gl_EvalPoint1( ctx, n[1].i );
2604 break;
2605 case OPCODE_EVALPOINT2:
2606 gl_EvalPoint2( ctx, n[1].i, n[2].i );
2607 break;
2608 case OPCODE_FOG:
2609 {
2610 GLfloat p[4];
2611 p[0] = n[2].f;
2612 p[1] = n[3].f;
2613 p[2] = n[4].f;
2614 p[3] = n[5].f;
2615 gl_Fogfv( ctx, n[1].e, p );
2616 }
2617 break;
2618 case OPCODE_FRONT_FACE:
2619 gl_FrontFace( ctx, n[1].e );
2620 break;
2621 case OPCODE_FRUSTUM:
2622 gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
2623 break;
2624 case OPCODE_HINT:
2625 gl_Hint( ctx, n[1].e, n[2].e );
2626 break;
2627 case OPCODE_INDEX_MASK:
2628 gl_IndexMask( ctx, n[1].ui );
2629 break;
2630 case OPCODE_INIT_NAMES:
2631 gl_InitNames( ctx );
2632 break;
2633 case OPCODE_LIGHT:
2634 {
2635 GLfloat p[4];
2636 p[0] = n[3].f;
2637 p[1] = n[4].f;
2638 p[2] = n[5].f;
2639 p[3] = n[6].f;
2640 gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 );
2641 }
2642 break;
2643 case OPCODE_LIGHT_MODEL:
2644 {
2645 GLfloat p[4];
2646 p[0] = n[2].f;
2647 p[1] = n[3].f;
2648 p[2] = n[4].f;
2649 p[3] = n[5].f;
2650 gl_LightModelfv( ctx, n[1].e, p );
2651 }
2652 break;
2653 case OPCODE_LINE_STIPPLE:
2654 gl_LineStipple( ctx, n[1].i, n[2].us );
2655 break;
2656 case OPCODE_LINE_WIDTH:
2657 gl_LineWidth( ctx, n[1].f );
2658 break;
2659 case OPCODE_LIST_BASE:
2660 gl_ListBase( ctx, n[1].ui );
2661 break;
2662 case OPCODE_LOAD_IDENTITY:
2663 gl_LoadIdentity( ctx );
2664 break;
2665 case OPCODE_LOAD_MATRIX:
2666 if (sizeof(Node)==sizeof(GLfloat)) {
2667 gl_LoadMatrixf( ctx, &n[1].f );
2668 }
2669 else {
2670 GLfloat m[16];
2671 GLuint i;
2672 for (i=0;i<16;i++) {
2673 m[i] = n[1+i].f;
2674 }
2675 gl_LoadMatrixf( ctx, m );
2676 }
2677 break;
2678 case OPCODE_LOAD_NAME:
2679 gl_LoadName( ctx, n[1].ui );
2680 break;
2681 case OPCODE_LOGIC_OP:
2682 gl_LogicOp( ctx, n[1].e );
2683 break;
2684 case OPCODE_MAP1:
2685 gl_Map1f( ctx, n[1].e, n[2].f, n[3].f,
2686 n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE );
2687 break;
2688 case OPCODE_MAP2:
2689 gl_Map2f( ctx, n[1].e,
2690 n[2].f, n[3].f, /* u1, u2 */
2691 n[6].i, n[8].i, /* ustride, uorder */
2692 n[4].f, n[5].f, /* v1, v2 */
2693 n[7].i, n[9].i, /* vstride, vorder */
2694 (GLfloat *) n[10].data,
2695 GL_TRUE);
2696 break;
2697 case OPCODE_MAPGRID1:
2698 gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f );
2699 break;
2700 case OPCODE_MAPGRID2:
2701 gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
2702 break;
2703 case OPCODE_MATERIAL:
2704 {
2705 GLfloat params[4];
2706 params[0] = n[3].f;
2707 params[1] = n[4].f;
2708 params[2] = n[5].f;
2709 params[3] = n[6].f;
2710 gl_Materialfv( ctx, n[1].e, n[2].e, params );
2711 }
2712 break;
2713 case OPCODE_MATRIX_MODE:
2714 gl_MatrixMode( ctx, n[1].e );
2715 break;
2716 case OPCODE_MULT_MATRIX:
2717 if (sizeof(Node)==sizeof(GLfloat)) {
2718 gl_MultMatrixf( ctx, &n[1].f );
2719 }
2720 else {
2721 GLfloat m[16];
2722 GLuint i;
2723 for (i=0;i<16;i++) {
2724 m[i] = n[1+i].f;
2725 }
2726 gl_MultMatrixf( ctx, m );
2727 }
2728 break;
2729 case OPCODE_ORTHO:
2730 gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
2731 break;
2732 case OPCODE_PASSTHROUGH:
2733 gl_PassThrough( ctx, n[1].f );
2734 break;
2735 case OPCODE_PIXEL_MAP:
2736 gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data );
2737 break;
2738 case OPCODE_PIXEL_TRANSFER:
2739 gl_PixelTransferf( ctx, n[1].e, n[2].f );
2740 break;
2741 case OPCODE_PIXEL_ZOOM:
2742 gl_PixelZoom( ctx, n[1].f, n[2].f );
2743 break;
2744 case OPCODE_POINT_SIZE:
2745 gl_PointSize( ctx, n[1].f );
2746 break;
2747 case OPCODE_POLYGON_MODE:
2748 gl_PolygonMode( ctx, n[1].e, n[2].e );
2749 break;
2750 case OPCODE_POLYGON_STIPPLE:
2751 gl_PolygonStipple( ctx, (GLubyte *) n[1].data );
2752 break;
2753 case OPCODE_POLYGON_OFFSET:
2754 gl_PolygonOffset( ctx, n[1].f, n[2].f );
2755 break;
2756 case OPCODE_POP_ATTRIB:
2757 gl_PopAttrib( ctx );
2758 break;
2759 case OPCODE_POP_MATRIX:
2760 gl_PopMatrix( ctx );
2761 break;
2762 case OPCODE_POP_NAME:
2763 gl_PopName( ctx );
2764 break;
2765 case OPCODE_PRIORITIZE_TEXTURE:
2766 gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f );
2767 break;
2768 case OPCODE_PUSH_ATTRIB:
2769 gl_PushAttrib( ctx, n[1].bf );
2770 break;
2771 case OPCODE_PUSH_MATRIX:
2772 gl_PushMatrix( ctx );
2773 break;
2774 case OPCODE_PUSH_NAME:
2775 gl_PushName( ctx, n[1].ui );
2776 break;
2777 case OPCODE_RASTER_POS:
2778 gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2779 break;
2780 case OPCODE_READ_BUFFER:
2781 gl_ReadBuffer( ctx, n[1].e );
2782 break;
2783 case OPCODE_RECTF:
2784 gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
2785 break;
2786 case OPCODE_SCALE:
2787 gl_Scalef( ctx, n[1].f, n[2].f, n[3].f );
2788 break;
2789 case OPCODE_SCISSOR:
2790 gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i );
2791 break;
2792 case OPCODE_SHADE_MODEL:
2793 gl_ShadeModel( ctx, n[1].e );
2794 break;
2795 case OPCODE_STENCIL_FUNC:
2796 gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui );
2797 break;
2798 case OPCODE_STENCIL_MASK:
2799 gl_StencilMask( ctx, n[1].ui );
2800 break;
2801 case OPCODE_STENCIL_OP:
2802 gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e );
2803 break;
2804 case OPCODE_TEXENV:
2805 {
2806 GLfloat params[4];
2807 params[0] = n[3].f;
2808 params[1] = n[4].f;
2809 params[2] = n[5].f;
2810 params[3] = n[6].f;
2811 gl_TexEnvfv( ctx, n[1].e, n[2].e, params );
2812 }
2813 break;
2814 case OPCODE_TEXGEN:
2815 {
2816 GLfloat params[4];
2817 params[0] = n[3].f;
2818 params[1] = n[4].f;
2819 params[2] = n[5].f;
2820 params[3] = n[6].f;
2821 gl_TexGenfv( ctx, n[1].e, n[2].e, params );
2822 }
2823 break;
2824 case OPCODE_TEXPARAMETER:
2825 {
2826 GLfloat params[4];
2827 params[0] = n[3].f;
2828 params[1] = n[4].f;
2829 params[2] = n[5].f;
2830 params[3] = n[6].f;
2831 gl_TexParameterfv( ctx, n[1].e, n[2].e, params );
2832 }
2833 break;
2834 case OPCODE_TEX_IMAGE1D:
2835 gl_TexImage1D( ctx,
2836 n[1].e, /* target */
2837 n[2].i, /* level */
2838 n[3].i, /* components */
2839 n[4].i, /* width */
2840 n[5].e, /* border */
2841 n[6].e, /* format */
2842 n[7].e, /* type */
2843 (struct gl_image *) n[8].data );
2844 break;
2845 case OPCODE_TEX_IMAGE2D:
2846 gl_TexImage2D( ctx,
2847 n[1].e, /* target */
2848 n[2].i, /* level */
2849 n[3].i, /* components */
2850 n[4].i, /* width */
2851 n[5].i, /* height */
2852 n[6].e, /* border */
2853 n[7].e, /* format */
2854 n[8].e, /* type */
2855 (struct gl_image *) n[9].data );
2856 break;
2857 case OPCODE_TEX_SUB_IMAGE1D:
2858 gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
2859 n[6].e, (struct gl_image *) n[7].data );
2860 break;
2861 case OPCODE_TEX_SUB_IMAGE2D:
2862 gl_TexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
2863 n[6].i, n[7].e, n[8].e,
2864 (struct gl_image *) n[9].data );
2865 break;
2866 case OPCODE_TRANSLATE:
2867 gl_Translatef( ctx, n[1].f, n[2].f, n[3].f );
2868 break;
2869 case OPCODE_VIEWPORT:
2870 gl_Viewport( ctx,
2871 n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
2872 break;
2873 case OPCODE_CONTINUE:
2874 n = (Node *) n[1].next;
2875 break;
2876 case OPCODE_END_OF_LIST:
2877 done = GL_TRUE;
2878 break;
2879 default:
2880 {
2881 char msg[1000];
2882 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
2883 gl_problem( ctx, msg );
2884 }
2885 done = GL_TRUE;
2886 }
2887
2888 /* increment n to point to next compiled command */
2889 if (opcode!=OPCODE_CONTINUE) {
2890 n += InstSize[opcode];
2891 }
2892
2893 }
2894 ctx->CallDepth--;
2895 }
2896
2897
2898
2899 /**********************************************************************/
2900 /* GL functions */
2901 /**********************************************************************/
2902
2903
2904
2905 /*
2906 * Test if a display list number is valid.
2907 */
gl_IsList(GLcontext * ctx,GLuint list)2908 GLboolean gl_IsList( GLcontext *ctx, GLuint list )
2909 {
2910 if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) {
2911 return GL_TRUE;
2912 }
2913 else {
2914 return GL_FALSE;
2915 }
2916 }
2917
2918
2919
2920 /*
2921 * Delete a sequence of consecutive display lists.
2922 */
gl_DeleteLists(GLcontext * ctx,GLuint list,GLsizei range)2923 void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range )
2924 {
2925 GLuint i;
2926
2927 if (INSIDE_BEGIN_END(ctx)) {
2928 gl_error( ctx, GL_INVALID_OPERATION, "glDeleteLists" );
2929 return;
2930 }
2931 if (range<0) {
2932 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
2933 return;
2934 }
2935 for (i=list;i<list+range;i++) {
2936 gl_destroy_list( ctx, i );
2937 }
2938 }
2939
2940
2941
2942 /*
2943 * Return a display list number, n, such that lists n through n+range-1
2944 * are free.
2945 */
gl_GenLists(GLcontext * ctx,GLsizei range)2946 GLuint gl_GenLists( GLcontext *ctx, GLsizei range )
2947 {
2948 GLuint base;
2949
2950 if (INSIDE_BEGIN_END(ctx)) {
2951 gl_error( ctx, GL_INVALID_OPERATION, "glGenLists" );
2952 return 0;
2953 }
2954 if (range<0) {
2955 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
2956 return 0;
2957 }
2958 if (range==0) {
2959 return 0;
2960 }
2961
2962 base = HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
2963 if (base) {
2964 /* reserve the list IDs by with empty/dummy lists */
2965 GLuint i;
2966 for (i=0; i<range; i++) {
2967 HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
2968 }
2969 }
2970 return base;
2971 }
2972
2973
2974
2975 /*
2976 * Begin a new display list.
2977 */
gl_NewList(GLcontext * ctx,GLuint list,GLenum mode)2978 void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
2979 {
2980 if (INSIDE_BEGIN_END(ctx)) {
2981 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
2982 return;
2983 }
2984 if (list==0) {
2985 gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
2986 return;
2987 }
2988 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
2989 gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
2990 return;
2991 }
2992 if (ctx->CurrentListPtr) {
2993 /* already compiling a display list */
2994 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
2995 return;
2996 }
2997
2998 /* Allocate new display list */
2999 ctx->CurrentListNum = list;
3000 ctx->CurrentListPtr = ctx->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
3001 ctx->CurrentPos = 0;
3002
3003 ctx->CompileFlag = GL_TRUE;
3004 if (mode==GL_COMPILE) {
3005 ctx->ExecuteFlag = GL_FALSE;
3006 }
3007 else {
3008 /* Compile and execute */
3009 ctx->ExecuteFlag = GL_TRUE;
3010 }
3011
3012 ctx->API = ctx->Save; /* Switch the API function pointers */
3013 }
3014
3015
3016
3017 /*
3018 * End definition of current display list.
3019 */
gl_EndList(GLcontext * ctx)3020 void gl_EndList( GLcontext *ctx )
3021 {
3022 Node *n;
3023
3024 /* Check that a list is under construction */
3025 if (!ctx->CurrentListPtr) {
3026 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
3027 return;
3028 }
3029
3030 n = alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
3031 (void)n;
3032
3033 /* Destroy old list, if any */
3034 gl_destroy_list(ctx, ctx->CurrentListNum);
3035 /* Install the list */
3036 HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
3037
3038 ctx->CurrentListNum = 0;
3039 ctx->CurrentListPtr = NULL;
3040 ctx->ExecuteFlag = GL_TRUE;
3041 ctx->CompileFlag = GL_FALSE;
3042
3043 ctx->API = ctx->Exec; /* Switch the API function pointers */
3044 }
3045
3046
3047
gl_CallList(GLcontext * ctx,GLuint list)3048 void gl_CallList( GLcontext *ctx, GLuint list )
3049 {
3050 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
3051 /* execute the display list, and restore the CompileFlag. */
3052 GLboolean save_compile_flag;
3053 save_compile_flag = ctx->CompileFlag;
3054 ctx->CompileFlag = GL_FALSE;
3055 execute_list( ctx, list );
3056 ctx->CompileFlag = save_compile_flag;
3057 }
3058
3059
3060
3061 /*
3062 * Execute glCallLists: call multiple display lists.
3063 */
gl_CallLists(GLcontext * ctx,GLsizei n,GLenum type,const GLvoid * lists)3064 void gl_CallLists( GLcontext *ctx,
3065 GLsizei n, GLenum type, const GLvoid *lists )
3066 {
3067 GLuint i, list;
3068 GLboolean save_compile_flag;
3069
3070 /* Save the CompileFlag status, turn it off, execute display list,
3071 * and restore the CompileFlag.
3072 */
3073 save_compile_flag = ctx->CompileFlag;
3074 ctx->CompileFlag = GL_FALSE;
3075
3076 for (i=0;i<n;i++) {
3077 list = translate_id( i, type, lists );
3078 execute_list( ctx, ctx->List.ListBase + list );
3079 }
3080
3081 ctx->CompileFlag = save_compile_flag;
3082 }
3083
3084
3085
3086 /*
3087 * Set the offset added to list numbers in glCallLists.
3088 */
gl_ListBase(GLcontext * ctx,GLuint base)3089 void gl_ListBase( GLcontext *ctx, GLuint base )
3090 {
3091 if (INSIDE_BEGIN_END(ctx)) {
3092 gl_error( ctx, GL_INVALID_OPERATION, "glListBase" );
3093 return;
3094 }
3095 ctx->List.ListBase = base;
3096 }
3097