1 /* $Id: dlist.c,v 1.13 1999/11/03 17:27:05 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
28 /* $XFree86: xc/lib/GL/mesa/src/dlist.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */
39 #include "GL/xf86glx.h"
57 #include "extensions.h"
92 #include "GL/xf86glx.h"
99 Functions which aren't compiled but executed immediately:
114 Functions which cause errors if called while compiling a display list:
121 * Display list instructions are stored as sequences of "nodes". Nodes
122 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
123 * are linked together with a pointer.
127 /* How many nodes to allocate at a time:
128 * - reduced now that we hold vertices etc. elsewhere.
130 #define BLOCK_SIZE 64
134 * Display list opcodes.
136 * The fact that these identifiers are assigned consecutive
137 * integer values starting at 0 is very important, see InstSize array usage)
139 * KW: Commented out opcodes now handled by vertex-cassettes.
147 OPCODE_BLEND_EQUATION
,
149 OPCODE_BLEND_FUNC_SEPARATE
,
151 OPCODE_CALL_LIST_OFFSET
,
157 OPCODE_CLEAR_STENCIL
,
160 OPCODE_COLOR_MATERIAL
,
162 OPCODE_COLOR_SUB_TABLE
,
164 OPCODE_COPY_TEX_IMAGE1D
,
165 OPCODE_COPY_TEX_IMAGE2D
,
166 OPCODE_COPY_TEX_IMAGE3D
,
167 OPCODE_COPY_TEX_SUB_IMAGE1D
,
168 OPCODE_COPY_TEX_SUB_IMAGE2D
,
169 OPCODE_COPY_TEX_SUB_IMAGE3D
,
195 OPCODE_LOAD_IDENTITY
,
208 OPCODE_PIXEL_TRANSFER
,
211 OPCODE_POINT_PARAMETERS
,
213 OPCODE_POLYGON_STIPPLE
,
214 OPCODE_POLYGON_OFFSET
,
218 OPCODE_PRIORITIZE_TEXTURE
,
227 OPCODE_SELECT_TEXTURE_SGIS
,
228 OPCODE_SELECT_TEXTURE_COORD_SET
,
239 OPCODE_TEX_SUB_IMAGE1D
,
240 OPCODE_TEX_SUB_IMAGE2D
,
241 OPCODE_TEX_SUB_IMAGE3D
,
245 /* GL_ARB_multitexture */
246 OPCODE_ACTIVE_TEXTURE
,
247 OPCODE_CLIENT_ACTIVE_TEXTURE
,
248 /* The following three are meta instructions */
249 OPCODE_ERROR
, /* raise compiled-in error */
250 OPCODE_VERTEX_CASSETTE
, /* render prebuilt vertex buffer */
257 * Each instruction in the display list is stored as a sequence of
258 * contiguous nodes in memory.
259 * Each node is the union of a variety of datatypes.
273 void *next
; /* If prev node's opcode==OPCODE_CONTINUE */
278 /* Number of nodes of storage needed for each instruction: */
279 static GLuint InstSize
[ OPCODE_END_OF_LIST
+1 ];
281 void mesa_print_display_list( GLuint list
);
284 /**********************************************************************/
285 /***** Private *****/
286 /**********************************************************************/
290 * Allocate space for a display list instruction.
291 * Input: opcode - type of instruction
292 * argcount - number of arguments following the instruction
293 * Return: pointer to first node in the instruction
295 static Node
*alloc_instruction( GLcontext
*ctx
, OpCode opcode
, GLint argcount
)
298 GLuint count
= InstSize
[opcode
];
300 assert( (GLint
) count
== argcount
+1 );
302 if (ctx
->CurrentPos
+ count
+ 2 > BLOCK_SIZE
) {
303 /* This block is full. Allocate a new block and chain to it */
304 n
= ctx
->CurrentBlock
+ ctx
->CurrentPos
;
305 n
[0].opcode
= OPCODE_CONTINUE
;
306 newblock
= (Node
*) MALLOC( sizeof(Node
) * BLOCK_SIZE
);
308 gl_error( ctx
, GL_OUT_OF_MEMORY
, "Building display list" );
311 n
[1].next
= (Node
*) newblock
;
312 ctx
->CurrentBlock
= newblock
;
316 n
= ctx
->CurrentBlock
+ ctx
->CurrentPos
;
317 ctx
->CurrentPos
+= count
;
319 n
[0].opcode
= opcode
;
327 * Make an empty display list. This is used by glGenLists() to
328 * reserver display list IDs.
330 static Node
*make_empty_list( void )
332 Node
*n
= (Node
*) MALLOC( sizeof(Node
) );
333 n
[0].opcode
= OPCODE_END_OF_LIST
;
340 * Destroy all nodes in a display list.
341 * Input: list - display list number
343 void gl_destroy_list( GLcontext
*ctx
, GLuint list
)
351 block
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
354 done
= block
? GL_FALSE
: GL_TRUE
;
356 switch (n
[0].opcode
) {
357 /* special cases first */
358 case OPCODE_VERTEX_CASSETTE
:
359 if ( ! -- ((struct immediate
*) n
[1].data
)->ref_count
)
360 gl_immediate_free( (struct immediate
*) n
[1].data
);
361 n
+= InstSize
[n
[0].opcode
];
364 gl_free_control_points( ctx
, n
[1].e
, (GLfloat
*) n
[6].data
);
365 n
+= InstSize
[n
[0].opcode
];
368 gl_free_control_points( ctx
, n
[1].e
, (GLfloat
*) n
[10].data
);
369 n
+= InstSize
[n
[0].opcode
];
371 case OPCODE_DRAW_PIXELS
:
372 gl_free_image( (struct gl_image
*) n
[1].data
);
373 n
+= InstSize
[n
[0].opcode
];
376 gl_free_image( (struct gl_image
*) n
[7].data
);
377 n
+= InstSize
[n
[0].opcode
];
379 case OPCODE_COLOR_TABLE
:
380 gl_free_image( (struct gl_image
*) n
[3].data
);
381 n
+= InstSize
[n
[0].opcode
];
383 case OPCODE_COLOR_SUB_TABLE
:
384 gl_free_image( (struct gl_image
*) n
[3].data
);
385 n
+= InstSize
[n
[0].opcode
];
387 case OPCODE_POLYGON_STIPPLE
:
389 n
+= InstSize
[n
[0].opcode
];
391 case OPCODE_TEX_IMAGE1D
:
393 n
+= InstSize
[n
[0].opcode
];
395 case OPCODE_TEX_IMAGE2D
:
397 n
+= InstSize
[n
[0].opcode
];
399 case OPCODE_TEX_IMAGE3D
:
401 n
+= InstSize
[n
[0].opcode
];
403 case OPCODE_TEX_SUB_IMAGE1D
:
405 n
+= InstSize
[n
[0].opcode
];
407 case OPCODE_TEX_SUB_IMAGE2D
:
409 n
+= InstSize
[n
[0].opcode
];
411 case OPCODE_TEX_SUB_IMAGE3D
:
413 n
+= InstSize
[n
[0].opcode
];
415 case OPCODE_CONTINUE
:
416 n
= (Node
*) n
[1].next
;
420 case OPCODE_END_OF_LIST
:
425 /* Most frequent case */
426 n
+= InstSize
[n
[0].opcode
];
431 HashRemove(ctx
->Shared
->DisplayList
, list
);
437 * Translate the nth element of list from type to GLuint.
439 static GLuint
translate_id( GLsizei n
, GLenum type
, const GLvoid
*list
)
451 bptr
= (GLbyte
*) list
;
452 return (GLuint
) *(bptr
+n
);
453 case GL_UNSIGNED_BYTE
:
454 ubptr
= (GLubyte
*) list
;
455 return (GLuint
) *(ubptr
+n
);
457 sptr
= (GLshort
*) list
;
458 return (GLuint
) *(sptr
+n
);
459 case GL_UNSIGNED_SHORT
:
460 usptr
= (GLushort
*) list
;
461 return (GLuint
) *(usptr
+n
);
463 iptr
= (GLint
*) list
;
464 return (GLuint
) *(iptr
+n
);
465 case GL_UNSIGNED_INT
:
466 uiptr
= (GLuint
*) list
;
467 return (GLuint
) *(uiptr
+n
);
469 fptr
= (GLfloat
*) list
;
470 return (GLuint
) *(fptr
+n
);
472 ubptr
= ((GLubyte
*) list
) + 2*n
;
473 return (GLuint
) *ubptr
* 256 + (GLuint
) *(ubptr
+1);
475 ubptr
= ((GLubyte
*) list
) + 3*n
;
476 return (GLuint
) *ubptr
* 65536
477 + (GLuint
) *(ubptr
+1) * 256
478 + (GLuint
) *(ubptr
+2);
480 ubptr
= ((GLubyte
*) list
) + 4*n
;
481 return (GLuint
) *ubptr
* 16777216
482 + (GLuint
) *(ubptr
+1) * 65536
483 + (GLuint
) *(ubptr
+2) * 256
484 + (GLuint
) *(ubptr
+3);
493 /**********************************************************************/
495 /**********************************************************************/
497 void gl_init_lists( void )
499 static int init_flag
= 0;
502 InstSize
[OPCODE_ACCUM
] = 3;
503 InstSize
[OPCODE_ALPHA_FUNC
] = 3;
504 InstSize
[OPCODE_BIND_TEXTURE
] = 3;
505 InstSize
[OPCODE_BITMAP
] = 8;
506 InstSize
[OPCODE_BLEND_COLOR
] = 5;
507 InstSize
[OPCODE_BLEND_EQUATION
] = 2;
508 InstSize
[OPCODE_BLEND_FUNC
] = 3;
509 InstSize
[OPCODE_BLEND_FUNC_SEPARATE
] = 5;
510 InstSize
[OPCODE_CALL_LIST
] = 2;
511 InstSize
[OPCODE_CALL_LIST_OFFSET
] = 2;
512 InstSize
[OPCODE_CLEAR
] = 2;
513 InstSize
[OPCODE_CLEAR_ACCUM
] = 5;
514 InstSize
[OPCODE_CLEAR_COLOR
] = 5;
515 InstSize
[OPCODE_CLEAR_DEPTH
] = 2;
516 InstSize
[OPCODE_CLEAR_INDEX
] = 2;
517 InstSize
[OPCODE_CLEAR_STENCIL
] = 2;
518 InstSize
[OPCODE_CLIP_PLANE
] = 6;
519 InstSize
[OPCODE_COLOR_MASK
] = 5;
520 InstSize
[OPCODE_COLOR_MATERIAL
] = 3;
521 InstSize
[OPCODE_COLOR_TABLE
] = 4;
522 InstSize
[OPCODE_COLOR_SUB_TABLE
] = 4;
523 InstSize
[OPCODE_COPY_PIXELS
] = 6;
524 InstSize
[OPCODE_COPY_TEX_IMAGE1D
] = 8;
525 InstSize
[OPCODE_COPY_TEX_IMAGE2D
] = 9;
526 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE1D
] = 7;
527 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE2D
] = 9;
528 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE3D
] = 10;
529 InstSize
[OPCODE_CULL_FACE
] = 2;
530 InstSize
[OPCODE_DEPTH_FUNC
] = 2;
531 InstSize
[OPCODE_DEPTH_MASK
] = 2;
532 InstSize
[OPCODE_DEPTH_RANGE
] = 3;
533 InstSize
[OPCODE_DISABLE
] = 2;
534 InstSize
[OPCODE_DRAW_BUFFER
] = 2;
535 InstSize
[OPCODE_DRAW_PIXELS
] = 2;
536 InstSize
[OPCODE_ENABLE
] = 2;
537 InstSize
[OPCODE_EVALCOORD1
] = 2;
538 InstSize
[OPCODE_EVALCOORD2
] = 3;
539 InstSize
[OPCODE_EVALMESH1
] = 4;
540 InstSize
[OPCODE_EVALMESH2
] = 6;
541 InstSize
[OPCODE_EVALPOINT1
] = 2;
542 InstSize
[OPCODE_EVALPOINT2
] = 3;
543 InstSize
[OPCODE_FOG
] = 6;
544 InstSize
[OPCODE_FRONT_FACE
] = 2;
545 InstSize
[OPCODE_FRUSTUM
] = 7;
546 InstSize
[OPCODE_HINT
] = 3;
547 InstSize
[OPCODE_INDEX_MASK
] = 2;
548 InstSize
[OPCODE_INIT_NAMES
] = 1;
549 InstSize
[OPCODE_LIGHT
] = 7;
550 InstSize
[OPCODE_LIGHT_MODEL
] = 6;
551 InstSize
[OPCODE_LINE_STIPPLE
] = 3;
552 InstSize
[OPCODE_LINE_WIDTH
] = 2;
553 InstSize
[OPCODE_LIST_BASE
] = 2;
554 InstSize
[OPCODE_LOAD_IDENTITY
] = 1;
555 InstSize
[OPCODE_LOAD_MATRIX
] = 17;
556 InstSize
[OPCODE_LOAD_NAME
] = 2;
557 InstSize
[OPCODE_LOGIC_OP
] = 2;
558 InstSize
[OPCODE_MAP1
] = 7;
559 InstSize
[OPCODE_MAP2
] = 11;
560 InstSize
[OPCODE_MAPGRID1
] = 4;
561 InstSize
[OPCODE_MAPGRID2
] = 7;
562 InstSize
[OPCODE_MATRIX_MODE
] = 2;
563 InstSize
[OPCODE_MULT_MATRIX
] = 17;
564 InstSize
[OPCODE_ORTHO
] = 7;
565 InstSize
[OPCODE_PASSTHROUGH
] = 2;
566 InstSize
[OPCODE_PIXEL_MAP
] = 4;
567 InstSize
[OPCODE_PIXEL_TRANSFER
] = 3;
568 InstSize
[OPCODE_PIXEL_ZOOM
] = 3;
569 InstSize
[OPCODE_POINT_SIZE
] = 2;
570 InstSize
[OPCODE_POINT_PARAMETERS
] = 5;
571 InstSize
[OPCODE_POLYGON_MODE
] = 3;
572 InstSize
[OPCODE_POLYGON_STIPPLE
] = 2;
573 InstSize
[OPCODE_POLYGON_OFFSET
] = 3;
574 InstSize
[OPCODE_POP_ATTRIB
] = 1;
575 InstSize
[OPCODE_POP_MATRIX
] = 1;
576 InstSize
[OPCODE_POP_NAME
] = 1;
577 InstSize
[OPCODE_PRIORITIZE_TEXTURE
] = 3;
578 InstSize
[OPCODE_PUSH_ATTRIB
] = 2;
579 InstSize
[OPCODE_PUSH_MATRIX
] = 1;
580 InstSize
[OPCODE_PUSH_NAME
] = 2;
581 InstSize
[OPCODE_RASTER_POS
] = 5;
582 InstSize
[OPCODE_RECTF
] = 5;
583 InstSize
[OPCODE_READ_BUFFER
] = 2;
584 InstSize
[OPCODE_SCALE
] = 4;
585 InstSize
[OPCODE_SCISSOR
] = 5;
586 InstSize
[OPCODE_STENCIL_FUNC
] = 4;
587 InstSize
[OPCODE_STENCIL_MASK
] = 2;
588 InstSize
[OPCODE_STENCIL_OP
] = 4;
589 InstSize
[OPCODE_SHADE_MODEL
] = 2;
590 InstSize
[OPCODE_TEXENV
] = 7;
591 InstSize
[OPCODE_TEXGEN
] = 7;
592 InstSize
[OPCODE_TEXPARAMETER
] = 7;
593 InstSize
[OPCODE_TEX_IMAGE1D
] = 9;
594 InstSize
[OPCODE_TEX_IMAGE2D
] = 10;
595 InstSize
[OPCODE_TEX_IMAGE3D
] = 11;
596 InstSize
[OPCODE_TEX_SUB_IMAGE1D
] = 8;
597 InstSize
[OPCODE_TEX_SUB_IMAGE2D
] = 10;
598 InstSize
[OPCODE_TEX_SUB_IMAGE3D
] = 12;
599 InstSize
[OPCODE_TRANSLATE
] = 4;
600 InstSize
[OPCODE_VIEWPORT
] = 5;
601 InstSize
[OPCODE_WINDOW_POS
] = 5;
602 InstSize
[OPCODE_CONTINUE
] = 2;
603 InstSize
[OPCODE_ERROR
] = 3;
604 InstSize
[OPCODE_VERTEX_CASSETTE
] = 9;
605 InstSize
[OPCODE_END_OF_LIST
] = 1;
606 /* GL_ARB_multitexture */
607 InstSize
[OPCODE_ACTIVE_TEXTURE
] = 2;
608 InstSize
[OPCODE_CLIENT_ACTIVE_TEXTURE
] = 2;
615 * Display List compilation functions
620 static void save_Accum( GLcontext
*ctx
, GLenum op
, GLfloat value
)
623 FLUSH_VB(ctx
, "dlist");
624 n
= alloc_instruction( ctx
, OPCODE_ACCUM
, 2 );
629 if (ctx
->ExecuteFlag
) {
630 (*ctx
->Exec
.Accum
)( ctx
, op
, value
);
635 static void save_AlphaFunc( GLcontext
*ctx
, GLenum func
, GLclampf ref
)
638 FLUSH_VB(ctx
, "dlist");
639 n
= alloc_instruction( ctx
, OPCODE_ALPHA_FUNC
, 2 );
642 n
[2].f
= (GLfloat
) ref
;
644 if (ctx
->ExecuteFlag
) {
645 (*ctx
->Exec
.AlphaFunc
)( ctx
, func
, ref
);
649 static void save_BindTexture( GLcontext
*ctx
, GLenum target
, GLuint texture
)
652 FLUSH_VB(ctx
, "dlist");
653 n
= alloc_instruction( ctx
, OPCODE_BIND_TEXTURE
, 2 );
658 if (ctx
->ExecuteFlag
) {
659 (*ctx
->Exec
.BindTexture
)( ctx
, target
, texture
);
664 static void save_Bitmap( GLcontext
*ctx
,
665 GLsizei width
, GLsizei height
,
666 GLfloat xorig
, GLfloat yorig
,
667 GLfloat xmove
, GLfloat ymove
,
668 const GLubyte
*bitmap
,
669 const struct gl_pixelstore_attrib
*packing
)
672 FLUSH_VB(ctx
, "dlist");
673 n
= alloc_instruction( ctx
, OPCODE_BITMAP
, 7 );
675 struct gl_image
*image
= gl_unpack_bitmap( ctx
, width
, height
,
680 n
[1].i
= (GLint
) width
;
681 n
[2].i
= (GLint
) height
;
686 n
[7].data
= (void *) image
;
688 if (ctx
->ExecuteFlag
) {
689 (*ctx
->Exec
.Bitmap
)( ctx
, width
, height
,
690 xorig
, yorig
, xmove
, ymove
, bitmap
, packing
);
695 static void save_BlendEquation( GLcontext
*ctx
, GLenum mode
)
698 FLUSH_VB(ctx
, "dlist");
699 n
= alloc_instruction( ctx
, OPCODE_BLEND_EQUATION
, 1 );
703 if (ctx
->ExecuteFlag
) {
704 (*ctx
->Exec
.BlendEquation
)( ctx
, mode
);
709 static void save_BlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
712 FLUSH_VB(ctx
, "dlist");
713 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC
, 2 );
718 if (ctx
->ExecuteFlag
) {
719 (*ctx
->Exec
.BlendFunc
)( ctx
, sfactor
, dfactor
);
724 static void save_BlendFuncSeparate( GLcontext
*ctx
,
725 GLenum sfactorRGB
, GLenum dfactorRGB
,
726 GLenum sfactorA
, GLenum dfactorA
)
729 FLUSH_VB(ctx
, "dlist");
730 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC_SEPARATE
, 4 );
737 if (ctx
->ExecuteFlag
) {
738 (*ctx
->Exec
.BlendFuncSeparate
)( ctx
, sfactorRGB
, dfactorRGB
,
744 static void save_BlendColor( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
745 GLfloat blue
, GLfloat alpha
)
748 FLUSH_VB(ctx
, "dlist");
749 n
= alloc_instruction( ctx
, OPCODE_BLEND_COLOR
, 4 );
756 if (ctx
->ExecuteFlag
) {
757 (*ctx
->Exec
.BlendColor
)( ctx
, red
, green
, blue
, alpha
);
762 static void save_CallList( GLcontext
*ctx
, GLuint list
)
765 FLUSH_VB(ctx
, "dlist");
766 n
= alloc_instruction( ctx
, OPCODE_CALL_LIST
, 1 );
770 if (ctx
->ExecuteFlag
) {
771 (*ctx
->Exec
.CallList
)( ctx
, list
);
776 static void save_CallLists( GLcontext
*ctx
,
777 GLsizei n
, GLenum type
, const GLvoid
*lists
)
780 FLUSH_VB(ctx
, "dlist");
783 GLuint list
= translate_id( i
, type
, lists
);
784 Node
*n
= alloc_instruction( ctx
, OPCODE_CALL_LIST_OFFSET
, 1 );
789 if (ctx
->ExecuteFlag
) {
790 (*ctx
->Exec
.CallLists
)( ctx
, n
, type
, lists
);
795 static void save_Clear( GLcontext
*ctx
, GLbitfield mask
)
798 FLUSH_VB(ctx
, "dlist");
799 n
= alloc_instruction( ctx
, OPCODE_CLEAR
, 1 );
803 if (ctx
->ExecuteFlag
) {
804 (*ctx
->Exec
.Clear
)( ctx
, mask
);
809 static void save_ClearAccum( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
810 GLfloat blue
, GLfloat alpha
)
813 FLUSH_VB(ctx
, "dlist");
814 n
= alloc_instruction( ctx
, OPCODE_CLEAR_ACCUM
, 4 );
821 if (ctx
->ExecuteFlag
) {
822 (*ctx
->Exec
.ClearAccum
)( ctx
, red
, green
, blue
, alpha
);
827 static void save_ClearColor( GLcontext
*ctx
, GLclampf red
, GLclampf green
,
828 GLclampf blue
, GLclampf alpha
)
831 FLUSH_VB(ctx
, "dlist");
832 n
= alloc_instruction( ctx
, OPCODE_CLEAR_COLOR
, 4 );
839 if (ctx
->ExecuteFlag
) {
840 (*ctx
->Exec
.ClearColor
)( ctx
, red
, green
, blue
, alpha
);
845 static void save_ClearDepth( GLcontext
*ctx
, GLclampd depth
)
848 FLUSH_VB(ctx
, "dlist");
849 n
= alloc_instruction( ctx
, OPCODE_CLEAR_DEPTH
, 1 );
851 n
[1].f
= (GLfloat
) depth
;
853 if (ctx
->ExecuteFlag
) {
854 (*ctx
->Exec
.ClearDepth
)( ctx
, depth
);
859 static void save_ClearIndex( GLcontext
*ctx
, GLfloat c
)
862 FLUSH_VB(ctx
, "dlist");
863 n
= alloc_instruction( ctx
, OPCODE_CLEAR_INDEX
, 1 );
867 if (ctx
->ExecuteFlag
) {
868 (*ctx
->Exec
.ClearIndex
)( ctx
, c
);
873 static void save_ClearStencil( GLcontext
*ctx
, GLint s
)
876 FLUSH_VB(ctx
, "dlist");
877 n
= alloc_instruction( ctx
, OPCODE_CLEAR_STENCIL
, 1 );
881 if (ctx
->ExecuteFlag
) {
882 (*ctx
->Exec
.ClearStencil
)( ctx
, s
);
887 static void save_ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*equ
)
890 FLUSH_VB(ctx
, "dlist");
891 n
= alloc_instruction( ctx
, OPCODE_CLIP_PLANE
, 5 );
899 if (ctx
->ExecuteFlag
) {
900 (*ctx
->Exec
.ClipPlane
)( ctx
, plane
, equ
);
906 static void save_ColorMask( GLcontext
*ctx
, GLboolean red
, GLboolean green
,
907 GLboolean blue
, GLboolean alpha
)
910 FLUSH_VB(ctx
, "dlist");
911 n
= alloc_instruction( ctx
, OPCODE_COLOR_MASK
, 4 );
918 if (ctx
->ExecuteFlag
) {
919 (*ctx
->Exec
.ColorMask
)( ctx
, red
, green
, blue
, alpha
);
924 static void save_ColorMaterial( GLcontext
*ctx
, GLenum face
, GLenum mode
)
927 FLUSH_VB(ctx
, "dlist");
928 n
= alloc_instruction( ctx
, OPCODE_COLOR_MATERIAL
, 2 );
933 if (ctx
->ExecuteFlag
) {
934 (*ctx
->Exec
.ColorMaterial
)( ctx
, face
, mode
);
939 static void save_ColorTable( GLcontext
*ctx
, GLenum target
, GLenum internalFormat
,
940 struct gl_image
*table
)
943 FLUSH_VB(ctx
, "dlist");
944 n
= alloc_instruction( ctx
, OPCODE_COLOR_TABLE
, 3 );
947 n
[2].e
= internalFormat
;
948 n
[3].data
= (GLvoid
*) table
;
950 /* must retain this image */
954 if (ctx
->ExecuteFlag
) {
955 (*ctx
->Exec
.ColorTable
)( ctx
, target
, internalFormat
, table
);
960 static void save_ColorSubTable( GLcontext
*ctx
, GLenum target
,
961 GLsizei start
, struct gl_image
*data
)
964 FLUSH_VB(ctx
, "dlist");
965 n
= alloc_instruction( ctx
, OPCODE_COLOR_SUB_TABLE
, 3 );
969 n
[3].data
= (GLvoid
*) data
;
971 /* must retain this image */
975 if (ctx
->ExecuteFlag
) {
976 (*ctx
->Exec
.ColorSubTable
)( ctx
, target
, start
, data
);
982 static void save_CopyPixels( GLcontext
*ctx
, GLint x
, GLint y
,
983 GLsizei width
, GLsizei height
, GLenum type
)
986 FLUSH_VB(ctx
, "dlist");
987 n
= alloc_instruction( ctx
, OPCODE_COPY_PIXELS
, 5 );
991 n
[3].i
= (GLint
) width
;
992 n
[4].i
= (GLint
) height
;
995 if (ctx
->ExecuteFlag
) {
996 (*ctx
->Exec
.CopyPixels
)( ctx
, x
, y
, width
, height
, type
);
1002 static void save_CopyTexImage1D( GLcontext
*ctx
,
1003 GLenum target
, GLint level
,
1004 GLenum internalformat
,
1005 GLint x
, GLint y
, GLsizei width
,
1009 FLUSH_VB(ctx
, "dlist");
1010 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE1D
, 7 );
1014 n
[3].e
= internalformat
;
1020 if (ctx
->ExecuteFlag
) {
1021 (*ctx
->Exec
.CopyTexImage1D
)( ctx
, target
, level
, internalformat
,
1022 x
, y
, width
, border
);
1027 static void save_CopyTexImage2D( GLcontext
*ctx
,
1028 GLenum target
, GLint level
,
1029 GLenum internalformat
,
1030 GLint x
, GLint y
, GLsizei width
,
1031 GLsizei height
, GLint border
)
1034 FLUSH_VB(ctx
, "dlist");
1035 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE2D
, 8 );
1039 n
[3].e
= internalformat
;
1046 if (ctx
->ExecuteFlag
) {
1047 (*ctx
->Exec
.CopyTexImage2D
)( ctx
, target
, level
, internalformat
,
1048 x
, y
, width
, height
, border
);
1054 static void save_CopyTexSubImage1D( GLcontext
*ctx
,
1055 GLenum target
, GLint level
,
1056 GLint xoffset
, GLint x
, GLint y
,
1060 FLUSH_VB(ctx
, "dlist");
1061 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE1D
, 6 );
1070 if (ctx
->ExecuteFlag
) {
1071 (*ctx
->Exec
.CopyTexSubImage1D
)( ctx
, target
, level
, xoffset
, x
, y
, width
);
1076 static void save_CopyTexSubImage2D( GLcontext
*ctx
,
1077 GLenum target
, GLint level
,
1078 GLint xoffset
, GLint yoffset
,
1080 GLsizei width
, GLint height
)
1083 FLUSH_VB(ctx
, "dlist");
1084 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE2D
, 8 );
1095 if (ctx
->ExecuteFlag
) {
1096 (*ctx
->Exec
.CopyTexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
1097 x
, y
, width
, height
);
1102 static void save_CopyTexSubImage3D( GLcontext
*ctx
,
1103 GLenum target
, GLint level
,
1104 GLint xoffset
, GLint yoffset
,
1107 GLsizei width
, GLint height
)
1110 FLUSH_VB(ctx
, "dlist");
1111 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE3D
, 9 );
1123 if (ctx
->ExecuteFlag
) {
1124 (*ctx
->Exec
.CopyTexSubImage3D
)(ctx
, target
, level
, xoffset
, yoffset
,
1125 zoffset
, x
, y
, width
, height
);
1130 static void save_CullFace( GLcontext
*ctx
, GLenum mode
)
1133 FLUSH_VB(ctx
, "dlist");
1134 n
= alloc_instruction( ctx
, OPCODE_CULL_FACE
, 1 );
1138 if (ctx
->ExecuteFlag
) {
1139 (*ctx
->Exec
.CullFace
)( ctx
, mode
);
1144 static void save_DepthFunc( GLcontext
*ctx
, GLenum func
)
1147 FLUSH_VB(ctx
, "dlist");
1148 n
= alloc_instruction( ctx
, OPCODE_DEPTH_FUNC
, 1 );
1152 if (ctx
->ExecuteFlag
) {
1153 (*ctx
->Exec
.DepthFunc
)( ctx
, func
);
1158 static void save_DepthMask( GLcontext
*ctx
, GLboolean mask
)
1161 FLUSH_VB(ctx
, "dlist");
1162 n
= alloc_instruction( ctx
, OPCODE_DEPTH_MASK
, 1 );
1166 if (ctx
->ExecuteFlag
) {
1167 (*ctx
->Exec
.DepthMask
)( ctx
, mask
);
1172 static void save_DepthRange( GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
)
1175 FLUSH_VB(ctx
, "dlist");
1176 n
= alloc_instruction( ctx
, OPCODE_DEPTH_RANGE
, 2 );
1178 n
[1].f
= (GLfloat
) nearval
;
1179 n
[2].f
= (GLfloat
) farval
;
1181 if (ctx
->ExecuteFlag
) {
1182 (*ctx
->Exec
.DepthRange
)( ctx
, nearval
, farval
);
1187 static void save_Disable( GLcontext
*ctx
, GLenum cap
)
1190 FLUSH_VB(ctx
, "dlist");
1191 n
= alloc_instruction( ctx
, OPCODE_DISABLE
, 1 );
1195 if (ctx
->ExecuteFlag
) {
1196 (*ctx
->Exec
.Disable
)( ctx
, cap
);
1201 static void save_DrawBuffer( GLcontext
*ctx
, GLenum mode
)
1204 FLUSH_VB(ctx
, "dlist");
1205 n
= alloc_instruction( ctx
, OPCODE_DRAW_BUFFER
, 1 );
1209 if (ctx
->ExecuteFlag
) {
1210 (*ctx
->Exec
.DrawBuffer
)( ctx
, mode
);
1215 static void save_DrawPixels( GLcontext
*ctx
, struct gl_image
*image
)
1218 FLUSH_VB(ctx
, "dlist");
1219 n
= alloc_instruction( ctx
, OPCODE_DRAW_PIXELS
, 1 );
1221 n
[1].data
= (GLvoid
*) image
;
1224 image
->RefCount
= 1;
1226 if (ctx
->ExecuteFlag
) {
1227 (*ctx
->Exec
.DrawPixels
)( ctx
, image
);
1233 static void save_Enable( GLcontext
*ctx
, GLenum cap
)
1236 FLUSH_VB(ctx
, "dlist");
1237 n
= alloc_instruction( ctx
, OPCODE_ENABLE
, 1 );
1241 if (ctx
->ExecuteFlag
) {
1242 (*ctx
->Exec
.Enable
)( ctx
, cap
);
1248 static void save_EvalMesh1( GLcontext
*ctx
,
1249 GLenum mode
, GLint i1
, GLint i2
)
1252 FLUSH_VB(ctx
, "dlist");
1253 n
= alloc_instruction( ctx
, OPCODE_EVALMESH1
, 3 );
1259 if (ctx
->ExecuteFlag
) {
1260 (*ctx
->Exec
.EvalMesh1
)( ctx
, mode
, i1
, i2
);
1265 static void save_EvalMesh2( GLcontext
*ctx
,
1266 GLenum mode
, GLint i1
, GLint i2
, GLint j1
, GLint j2
)
1269 FLUSH_VB(ctx
, "dlist");
1270 n
= alloc_instruction( ctx
, OPCODE_EVALMESH2
, 5 );
1278 if (ctx
->ExecuteFlag
) {
1279 (*ctx
->Exec
.EvalMesh2
)( ctx
, mode
, i1
, i2
, j1
, j2
);
1286 static void save_Fogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
)
1289 FLUSH_VB(ctx
, "dlist");
1290 n
= alloc_instruction( ctx
, OPCODE_FOG
, 5 );
1298 if (ctx
->ExecuteFlag
) {
1299 (*ctx
->Exec
.Fogfv
)( ctx
, pname
, params
);
1304 static void save_FrontFace( GLcontext
*ctx
, GLenum mode
)
1307 FLUSH_VB(ctx
, "dlist");
1308 n
= alloc_instruction( ctx
, OPCODE_FRONT_FACE
, 1 );
1312 if (ctx
->ExecuteFlag
) {
1313 (*ctx
->Exec
.FrontFace
)( ctx
, mode
);
1318 static void save_Frustum( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1319 GLdouble bottom
, GLdouble top
,
1320 GLdouble nearval
, GLdouble farval
)
1323 FLUSH_VB(ctx
, "dlist");
1324 n
= alloc_instruction( ctx
, OPCODE_FRUSTUM
, 6 );
1333 if (ctx
->ExecuteFlag
) {
1334 (*ctx
->Exec
.Frustum
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1339 static GLboolean
save_Hint( GLcontext
*ctx
, GLenum target
, GLenum mode
)
1342 FLUSH_VB(ctx
, "dlist");
1343 n
= alloc_instruction( ctx
, OPCODE_HINT
, 2 );
1348 if (ctx
->ExecuteFlag
) {
1349 return (*ctx
->Exec
.Hint
)( ctx
, target
, mode
);
1351 return GL_TRUE
; /* not queried */
1356 static void save_IndexMask( GLcontext
*ctx
, GLuint mask
)
1359 FLUSH_VB(ctx
, "dlist");
1360 n
= alloc_instruction( ctx
, OPCODE_INDEX_MASK
, 1 );
1364 if (ctx
->ExecuteFlag
) {
1365 (*ctx
->Exec
.IndexMask
)( ctx
, mask
);
1370 static void save_InitNames( GLcontext
*ctx
)
1372 FLUSH_VB(ctx
, "dlist");
1373 (void) alloc_instruction( ctx
, OPCODE_INIT_NAMES
, 0 );
1374 if (ctx
->ExecuteFlag
) {
1375 (*ctx
->Exec
.InitNames
)( ctx
);
1380 static void save_Lightfv( GLcontext
*ctx
, GLenum light
, GLenum pname
,
1381 const GLfloat
*params
, GLint numparams
)
1384 FLUSH_VB(ctx
, "dlist");
1385 n
= alloc_instruction( ctx
, OPCODE_LIGHT
, 6 );
1390 for (i
=0;i
<numparams
;i
++) {
1391 n
[3+i
].f
= params
[i
];
1394 if (ctx
->ExecuteFlag
) {
1395 (*ctx
->Exec
.Lightfv
)( ctx
, light
, pname
, params
, numparams
);
1400 static void save_LightModelfv( GLcontext
*ctx
,
1401 GLenum pname
, const GLfloat
*params
)
1404 FLUSH_VB(ctx
, "dlist");
1405 n
= alloc_instruction( ctx
, OPCODE_LIGHT_MODEL
, 5 );
1413 if (ctx
->ExecuteFlag
) {
1414 (*ctx
->Exec
.LightModelfv
)( ctx
, pname
, params
);
1419 static void save_LineStipple( GLcontext
*ctx
, GLint factor
, GLushort pattern
)
1422 FLUSH_VB(ctx
, "dlist");
1423 n
= alloc_instruction( ctx
, OPCODE_LINE_STIPPLE
, 2 );
1428 if (ctx
->ExecuteFlag
) {
1429 (*ctx
->Exec
.LineStipple
)( ctx
, factor
, pattern
);
1434 static void save_LineWidth( GLcontext
*ctx
, GLfloat width
)
1437 FLUSH_VB(ctx
, "dlist");
1438 n
= alloc_instruction( ctx
, OPCODE_LINE_WIDTH
, 1 );
1442 if (ctx
->ExecuteFlag
) {
1443 (*ctx
->Exec
.LineWidth
)( ctx
, width
);
1448 static void save_ListBase( GLcontext
*ctx
, GLuint base
)
1451 FLUSH_VB(ctx
, "dlist");
1452 n
= alloc_instruction( ctx
, OPCODE_LIST_BASE
, 1 );
1456 if (ctx
->ExecuteFlag
) {
1457 (*ctx
->Exec
.ListBase
)( ctx
, base
);
1462 static void save_LoadIdentity( GLcontext
*ctx
)
1464 FLUSH_VB(ctx
, "dlist");
1465 (void) alloc_instruction( ctx
, OPCODE_LOAD_IDENTITY
, 0 );
1466 if (ctx
->ExecuteFlag
) {
1467 (*ctx
->Exec
.LoadIdentity
)( ctx
);
1472 static void save_LoadMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1475 FLUSH_VB(ctx
, "dlist");
1476 n
= alloc_instruction( ctx
, OPCODE_LOAD_MATRIX
, 16 );
1479 for (i
=0;i
<16;i
++) {
1483 if (ctx
->ExecuteFlag
) {
1484 (*ctx
->Exec
.LoadMatrixf
)( ctx
, m
);
1489 static void save_LoadName( GLcontext
*ctx
, GLuint name
)
1492 FLUSH_VB(ctx
, "dlist");
1493 n
= alloc_instruction( ctx
, OPCODE_LOAD_NAME
, 1 );
1497 if (ctx
->ExecuteFlag
) {
1498 (*ctx
->Exec
.LoadName
)( ctx
, name
);
1503 static void save_LogicOp( GLcontext
*ctx
, GLenum opcode
)
1506 FLUSH_VB(ctx
, "dlist");
1507 n
= alloc_instruction( ctx
, OPCODE_LOGIC_OP
, 1 );
1511 if (ctx
->ExecuteFlag
) {
1512 (*ctx
->Exec
.LogicOp
)( ctx
, opcode
);
1517 static void save_Map1f( GLcontext
*ctx
,
1518 GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
1519 GLint order
, const GLfloat
*points
, GLboolean retain
)
1522 FLUSH_VB(ctx
, "dlist");
1523 n
= alloc_instruction( ctx
, OPCODE_MAP1
, 6 );
1530 n
[6].data
= (void *) points
;
1532 if (ctx
->ExecuteFlag
) {
1533 (*ctx
->Exec
.Map1f
)( ctx
, target
, u1
, u2
, stride
, order
, points
, GL_TRUE
);
1539 static void save_Map2f( GLcontext
*ctx
, GLenum target
,
1540 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
1541 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
1542 const GLfloat
*points
, GLboolean retain
)
1545 FLUSH_VB(ctx
, "dlist");
1546 n
= alloc_instruction( ctx
, OPCODE_MAP2
, 10 );
1557 n
[10].data
= (void *) points
;
1559 if (ctx
->ExecuteFlag
) {
1560 (*ctx
->Exec
.Map2f
)( ctx
, target
,
1561 u1
, u2
, ustride
, uorder
,
1562 v1
, v2
, vstride
, vorder
, points
, GL_TRUE
);
1568 static void save_MapGrid1f( GLcontext
*ctx
, GLint un
, GLfloat u1
, GLfloat u2
)
1571 FLUSH_VB(ctx
, "dlist");
1572 n
= alloc_instruction( ctx
, OPCODE_MAPGRID1
, 3 );
1578 if (ctx
->ExecuteFlag
) {
1579 (*ctx
->Exec
.MapGrid1f
)( ctx
, un
, u1
, u2
);
1584 static void save_MapGrid2f( GLcontext
*ctx
,
1585 GLint un
, GLfloat u1
, GLfloat u2
,
1586 GLint vn
, GLfloat v1
, GLfloat v2
)
1589 FLUSH_VB(ctx
, "dlist");
1590 n
= alloc_instruction( ctx
, OPCODE_MAPGRID2
, 6 );
1599 if (ctx
->ExecuteFlag
) {
1600 (*ctx
->Exec
.MapGrid2f
)( ctx
, un
, u1
, u2
, vn
, v1
, v2
);
1605 static void save_MatrixMode( GLcontext
*ctx
, GLenum mode
)
1608 FLUSH_VB(ctx
, "dlist");
1609 n
= alloc_instruction( ctx
, OPCODE_MATRIX_MODE
, 1 );
1613 if (ctx
->ExecuteFlag
) {
1614 (*ctx
->Exec
.MatrixMode
)( ctx
, mode
);
1619 static void save_MultMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1622 FLUSH_VB(ctx
, "dlist");
1623 n
= alloc_instruction( ctx
, OPCODE_MULT_MATRIX
, 16 );
1626 for (i
=0;i
<16;i
++) {
1630 if (ctx
->ExecuteFlag
) {
1631 (*ctx
->Exec
.MultMatrixf
)( ctx
, m
);
1636 static void save_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
1638 /* It's an error to call this function while building a display list */
1639 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
1646 static void save_Ortho( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1647 GLdouble bottom
, GLdouble top
,
1648 GLdouble nearval
, GLdouble farval
)
1651 FLUSH_VB(ctx
, "dlist");
1652 n
= alloc_instruction( ctx
, OPCODE_ORTHO
, 6 );
1661 if (ctx
->ExecuteFlag
) {
1662 (*ctx
->Exec
.Ortho
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1667 static void save_PixelMapfv( GLcontext
*ctx
,
1668 GLenum map
, GLint mapsize
, const GLfloat
*values
)
1671 FLUSH_VB(ctx
, "dlist");
1672 n
= alloc_instruction( ctx
, OPCODE_PIXEL_MAP
, 3 );
1676 n
[3].data
= (void *) MALLOC( mapsize
* sizeof(GLfloat
) );
1677 MEMCPY( n
[3].data
, (void *) values
, mapsize
* sizeof(GLfloat
) );
1679 if (ctx
->ExecuteFlag
) {
1680 (*ctx
->Exec
.PixelMapfv
)( ctx
, map
, mapsize
, values
);
1685 static void save_PixelTransferf( GLcontext
*ctx
, GLenum pname
, GLfloat param
)
1688 FLUSH_VB(ctx
, "dlist");
1689 n
= alloc_instruction( ctx
, OPCODE_PIXEL_TRANSFER
, 2 );
1694 if (ctx
->ExecuteFlag
) {
1695 (*ctx
->Exec
.PixelTransferf
)( ctx
, pname
, param
);
1700 static void save_PixelZoom( GLcontext
*ctx
, GLfloat xfactor
, GLfloat yfactor
)
1703 FLUSH_VB(ctx
, "dlist");
1704 n
= alloc_instruction( ctx
, OPCODE_PIXEL_ZOOM
, 2 );
1709 if (ctx
->ExecuteFlag
) {
1710 (*ctx
->Exec
.PixelZoom
)( ctx
, xfactor
, yfactor
);
1715 static void save_PointParameterfvEXT( GLcontext
*ctx
, GLenum pname
,
1716 const GLfloat
*params
)
1719 FLUSH_VB(ctx
, "dlist");
1720 n
= alloc_instruction( ctx
, OPCODE_POINT_PARAMETERS
, 4 );
1727 if (ctx
->ExecuteFlag
) {
1728 (*ctx
->Exec
.PointParameterfvEXT
)( ctx
, pname
, params
);
1733 static void save_PointSize( GLcontext
*ctx
, GLfloat size
)
1736 FLUSH_VB(ctx
, "dlist");
1737 n
= alloc_instruction( ctx
, OPCODE_POINT_SIZE
, 1 );
1741 if (ctx
->ExecuteFlag
) {
1742 (*ctx
->Exec
.PointSize
)( ctx
, size
);
1747 static void save_PolygonMode( GLcontext
*ctx
, GLenum face
, GLenum mode
)
1750 FLUSH_VB(ctx
, "dlist");
1751 n
= alloc_instruction( ctx
, OPCODE_POLYGON_MODE
, 2 );
1756 if (ctx
->ExecuteFlag
) {
1757 (*ctx
->Exec
.PolygonMode
)( ctx
, face
, mode
);
1763 * Polygon stipple must have been upacked already!
1765 static void save_PolygonStipple( GLcontext
*ctx
, const GLuint
*pattern
)
1768 FLUSH_VB(ctx
, "dlist");
1769 n
= alloc_instruction( ctx
, OPCODE_POLYGON_STIPPLE
, 1 );
1772 n
[1].data
= MALLOC( 32 * 4 );
1773 data
= n
[1].data
; /* This needed for Acorn compiler */
1774 MEMCPY( data
, pattern
, 32 * 4 );
1776 if (ctx
->ExecuteFlag
) {
1777 (*ctx
->Exec
.PolygonStipple
)( ctx
, pattern
);
1782 static void save_PolygonOffset( GLcontext
*ctx
, GLfloat factor
, GLfloat units
)
1785 FLUSH_VB(ctx
, "dlist");
1786 n
= alloc_instruction( ctx
, OPCODE_POLYGON_OFFSET
, 2 );
1791 if (ctx
->ExecuteFlag
) {
1792 (*ctx
->Exec
.PolygonOffset
)( ctx
, factor
, units
);
1797 static void save_PopAttrib( GLcontext
*ctx
)
1799 FLUSH_VB(ctx
, "dlist");
1800 (void) alloc_instruction( ctx
, OPCODE_POP_ATTRIB
, 0 );
1801 if (ctx
->ExecuteFlag
) {
1802 (*ctx
->Exec
.PopAttrib
)( ctx
);
1807 static void save_PopMatrix( GLcontext
*ctx
)
1809 FLUSH_VB(ctx
, "dlist");
1810 (void) alloc_instruction( ctx
, OPCODE_POP_MATRIX
, 0 );
1811 if (ctx
->ExecuteFlag
) {
1812 (*ctx
->Exec
.PopMatrix
)( ctx
);
1817 static void save_PopName( GLcontext
*ctx
)
1819 FLUSH_VB(ctx
, "dlist");
1820 (void) alloc_instruction( ctx
, OPCODE_POP_NAME
, 0 );
1821 if (ctx
->ExecuteFlag
) {
1822 (*ctx
->Exec
.PopName
)( ctx
);
1827 static void save_PrioritizeTextures( GLcontext
*ctx
,
1828 GLsizei num
, const GLuint
*textures
,
1829 const GLclampf
*priorities
)
1832 FLUSH_VB(ctx
, "dlist");
1834 for (i
=0;i
<num
;i
++) {
1836 n
= alloc_instruction( ctx
, OPCODE_PRIORITIZE_TEXTURE
, 2 );
1838 n
[1].ui
= textures
[i
];
1839 n
[2].f
= priorities
[i
];
1842 if (ctx
->ExecuteFlag
) {
1843 (*ctx
->Exec
.PrioritizeTextures
)( ctx
, num
, textures
, priorities
);
1848 static void save_PushAttrib( GLcontext
*ctx
, GLbitfield mask
)
1851 FLUSH_VB(ctx
, "dlist");
1852 n
= alloc_instruction( ctx
, OPCODE_PUSH_ATTRIB
, 1 );
1856 if (ctx
->ExecuteFlag
) {
1857 (*ctx
->Exec
.PushAttrib
)( ctx
, mask
);
1862 static void save_PushMatrix( GLcontext
*ctx
)
1864 FLUSH_VB(ctx
, "dlist");
1865 (void) alloc_instruction( ctx
, OPCODE_PUSH_MATRIX
, 0 );
1866 if (ctx
->ExecuteFlag
) {
1867 (*ctx
->Exec
.PushMatrix
)( ctx
);
1872 static void save_PushName( GLcontext
*ctx
, GLuint name
)
1875 FLUSH_VB(ctx
, "dlist");
1876 n
= alloc_instruction( ctx
, OPCODE_PUSH_NAME
, 1 );
1880 if (ctx
->ExecuteFlag
) {
1881 (*ctx
->Exec
.PushName
)( ctx
, name
);
1886 static void save_RasterPos4f( GLcontext
*ctx
,
1887 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
1890 FLUSH_VB(ctx
, "dlist");
1891 n
= alloc_instruction( ctx
, OPCODE_RASTER_POS
, 4 );
1898 if (ctx
->ExecuteFlag
) {
1899 (*ctx
->Exec
.RasterPos4f
)( ctx
, x
, y
, z
, w
);
1904 static void save_PassThrough( GLcontext
*ctx
, GLfloat token
)
1907 FLUSH_VB(ctx
, "dlist");
1908 n
= alloc_instruction( ctx
, OPCODE_PASSTHROUGH
, 1 );
1912 if (ctx
->ExecuteFlag
) {
1913 (*ctx
->Exec
.PassThrough
)( ctx
, token
);
1918 static void save_ReadBuffer( GLcontext
*ctx
, GLenum mode
)
1921 FLUSH_VB(ctx
, "dlist");
1922 n
= alloc_instruction( ctx
, OPCODE_READ_BUFFER
, 1 );
1926 if (ctx
->ExecuteFlag
) {
1927 (*ctx
->Exec
.ReadBuffer
)( ctx
, mode
);
1932 static void save_Rectf( GLcontext
*ctx
,
1933 GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
1936 FLUSH_VB(ctx
, "dlist");
1937 n
= alloc_instruction( ctx
, OPCODE_RECTF
, 4 );
1944 if (ctx
->ExecuteFlag
) {
1945 (*ctx
->Exec
.Rectf
)( ctx
, x1
, y1
, x2
, y2
);
1950 static void save_Rotatef( GLcontext
*ctx
, GLfloat angle
,
1951 GLfloat x
, GLfloat y
, GLfloat z
)
1954 gl_rotation_matrix( angle
, x
, y
, z
, m
);
1955 save_MultMatrixf( ctx
, m
); /* save and maybe execute */
1959 static void save_Scalef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
1962 FLUSH_VB(ctx
, "dlist");
1963 n
= alloc_instruction( ctx
, OPCODE_SCALE
, 3 );
1969 if (ctx
->ExecuteFlag
) {
1970 (*ctx
->Exec
.Scalef
)( ctx
, x
, y
, z
);
1975 static void save_Scissor( GLcontext
*ctx
,
1976 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1979 FLUSH_VB(ctx
, "dlist");
1980 n
= alloc_instruction( ctx
, OPCODE_SCISSOR
, 4 );
1987 if (ctx
->ExecuteFlag
) {
1988 (*ctx
->Exec
.Scissor
)( ctx
, x
, y
, width
, height
);
1993 static void save_ShadeModel( GLcontext
*ctx
, GLenum mode
)
1996 FLUSH_VB(ctx
, "dlist");
1997 n
= alloc_instruction( ctx
, OPCODE_SHADE_MODEL
, 1 );
2001 if (ctx
->ExecuteFlag
) {
2002 (*ctx
->Exec
.ShadeModel
)( ctx
, mode
);
2007 static void save_StencilFunc( GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
)
2010 FLUSH_VB(ctx
, "dlist");
2011 n
= alloc_instruction( ctx
, OPCODE_STENCIL_FUNC
, 3 );
2017 if (ctx
->ExecuteFlag
) {
2018 (*ctx
->Exec
.StencilFunc
)( ctx
, func
, ref
, mask
);
2023 static void save_StencilMask( GLcontext
*ctx
, GLuint mask
)
2026 FLUSH_VB(ctx
, "dlist");
2027 n
= alloc_instruction( ctx
, OPCODE_STENCIL_MASK
, 1 );
2031 if (ctx
->ExecuteFlag
) {
2032 (*ctx
->Exec
.StencilMask
)( ctx
, mask
);
2037 static void save_StencilOp( GLcontext
*ctx
,
2038 GLenum fail
, GLenum zfail
, GLenum zpass
)
2041 FLUSH_VB(ctx
, "dlist");
2042 n
= alloc_instruction( ctx
, OPCODE_STENCIL_OP
, 3 );
2048 if (ctx
->ExecuteFlag
) {
2049 (*ctx
->Exec
.StencilOp
)( ctx
, fail
, zfail
, zpass
);
2056 static void save_TexEnvfv( GLcontext
*ctx
,
2057 GLenum target
, GLenum pname
, const GLfloat
*params
)
2060 FLUSH_VB(ctx
, "dlist");
2061 n
= alloc_instruction( ctx
, OPCODE_TEXENV
, 6 );
2070 if (ctx
->ExecuteFlag
) {
2071 (*ctx
->Exec
.TexEnvfv
)( ctx
, target
, pname
, params
);
2076 static void save_TexGenfv( GLcontext
*ctx
,
2077 GLenum coord
, GLenum pname
, const GLfloat
*params
)
2080 FLUSH_VB(ctx
, "dlist");
2081 n
= alloc_instruction( ctx
, OPCODE_TEXGEN
, 6 );
2090 if (ctx
->ExecuteFlag
) {
2091 (*ctx
->Exec
.TexGenfv
)( ctx
, coord
, pname
, params
);
2096 static void save_TexParameterfv( GLcontext
*ctx
, GLenum target
,
2097 GLenum pname
, const GLfloat
*params
)
2100 FLUSH_VB(ctx
, "dlist");
2101 n
= alloc_instruction( ctx
, OPCODE_TEXPARAMETER
, 6 );
2110 if (ctx
->ExecuteFlag
) {
2111 (*ctx
->Exec
.TexParameterfv
)( ctx
, target
, pname
, params
);
2116 static void save_TexImage1D( GLcontext
*ctx
, GLenum target
,
2117 GLint level
, GLint components
,
2118 GLsizei width
, GLint border
,
2119 GLenum format
, GLenum type
,
2120 const GLvoid
*pixels
)
2122 FLUSH_VB(ctx
, "dlist");
2123 if (target
== GL_PROXY_TEXTURE_1D
) {
2124 (*ctx
->Exec
.TexImage1D
)( ctx
, target
, level
, components
, width
,
2125 border
, format
, type
, pixels
);
2129 GLvoid
*image
= _mesa_unpack_image(width
, 1, 1, format
, type
,
2130 pixels
, &ctx
->Unpack
);
2131 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE1D
, 8 );
2135 n
[3].i
= components
;
2136 n
[4].i
= (GLint
) width
;
2145 if (ctx
->ExecuteFlag
) {
2146 (*ctx
->Exec
.TexImage1D
)( ctx
, target
, level
, components
, width
,
2147 border
, format
, type
, pixels
);
2153 static void save_TexImage2D( GLcontext
*ctx
, GLenum target
,
2154 GLint level
, GLint components
,
2155 GLsizei width
, GLsizei height
, GLint border
,
2156 GLenum format
, GLenum type
,
2157 const GLvoid
*pixels
)
2159 FLUSH_VB(ctx
, "dlist");
2160 if (target
== GL_PROXY_TEXTURE_2D
) {
2161 (*ctx
->Exec
.TexImage2D
)( ctx
, target
, level
, components
, width
,
2162 height
, border
, format
, type
, pixels
);
2166 GLvoid
*image
= _mesa_unpack_image(width
, height
, 1, format
, type
,
2167 pixels
, &ctx
->Unpack
);
2168 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE2D
, 9 );
2172 n
[3].i
= components
;
2173 n
[4].i
= (GLint
) width
;
2174 n
[5].i
= (GLint
) height
;
2183 if (ctx
->ExecuteFlag
) {
2184 (*ctx
->Exec
.TexImage2D
)( ctx
, target
, level
, components
, width
,
2185 height
, border
, format
, type
, pixels
);
2191 static void save_TexImage3D( GLcontext
*ctx
, GLenum target
,
2192 GLint level
, GLint components
,
2193 GLsizei width
, GLsizei height
, GLsizei depth
,
2195 GLenum format
, GLenum type
,
2196 const GLvoid
*pixels
)
2198 FLUSH_VB(ctx
, "dlist");
2199 if (target
== GL_PROXY_TEXTURE_3D
) {
2200 (*ctx
->Exec
.TexImage3D
)( ctx
, target
, level
, components
, width
,
2201 height
, depth
, border
, format
, type
, pixels
);
2204 GLvoid
*image
= _mesa_unpack_image(width
, height
, depth
, format
, type
,
2205 pixels
, &ctx
->Unpack
);
2207 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE3D
, 10 );
2211 n
[3].i
= components
;
2212 n
[4].i
= (GLint
) width
;
2213 n
[5].i
= (GLint
) height
;
2214 n
[6].i
= (GLint
) depth
;
2223 if (ctx
->ExecuteFlag
) {
2224 (*ctx
->Exec
.TexImage3D
)( ctx
, target
, level
, components
, width
,
2225 height
, depth
, border
, format
, type
, pixels
);
2231 static void save_TexSubImage1D( GLcontext
*ctx
,
2232 GLenum target
, GLint level
, GLint xoffset
,
2233 GLsizei width
, GLenum format
, GLenum type
,
2234 const GLvoid
*pixels
)
2237 GLvoid
*image
= _mesa_unpack_image(width
, 1, 1, format
, type
,
2238 pixels
, &ctx
->Unpack
);
2239 FLUSH_VB(ctx
, "dlist");
2240 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE1D
, 7 );
2245 n
[4].i
= (GLint
) width
;
2253 if (ctx
->ExecuteFlag
) {
2254 (*ctx
->Exec
.TexSubImage1D
)( ctx
, target
, level
, xoffset
, width
,
2255 format
, type
, pixels
);
2260 static void save_TexSubImage2D( GLcontext
*ctx
,
2261 GLenum target
, GLint level
,
2262 GLint xoffset
, GLint yoffset
,
2263 GLsizei width
, GLsizei height
,
2264 GLenum format
, GLenum type
,
2265 const GLvoid
*pixels
)
2268 GLvoid
*image
= _mesa_unpack_image(width
, height
, 1, format
, type
,
2269 pixels
, &ctx
->Unpack
);
2270 FLUSH_VB(ctx
, "dlist");
2271 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE2D
, 9 );
2277 n
[5].i
= (GLint
) width
;
2278 n
[6].i
= (GLint
) height
;
2286 if (ctx
->ExecuteFlag
) {
2287 (*ctx
->Exec
.TexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
2288 width
, height
, format
, type
, pixels
);
2293 static void save_TexSubImage3D( GLcontext
*ctx
,
2294 GLenum target
, GLint level
,
2295 GLint xoffset
, GLint yoffset
,GLint zoffset
,
2296 GLsizei width
, GLsizei height
, GLsizei depth
,
2297 GLenum format
, GLenum type
,
2298 const GLvoid
*pixels
)
2301 GLvoid
*image
= _mesa_unpack_image(width
, height
, depth
, format
, type
,
2302 pixels
, &ctx
->Unpack
);
2303 FLUSH_VB(ctx
, "dlist");
2304 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE3D
, 11 );
2311 n
[6].i
= (GLint
) width
;
2312 n
[7].i
= (GLint
) height
;
2313 n
[8].i
= (GLint
) depth
;
2321 if (ctx
->ExecuteFlag
) {
2322 (*ctx
->Exec
.TexSubImage3D
)(ctx
, target
, level
, xoffset
, yoffset
, zoffset
,
2323 width
, height
, depth
, format
, type
, pixels
);
2328 static void save_Translatef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
2331 FLUSH_VB(ctx
, "dlist");
2332 n
= alloc_instruction( ctx
, OPCODE_TRANSLATE
, 3 );
2338 if (ctx
->ExecuteFlag
) {
2339 (*ctx
->Exec
.Translatef
)( ctx
, x
, y
, z
);
2345 static void save_Viewport( GLcontext
*ctx
,
2346 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
2349 FLUSH_VB(ctx
, "dlist");
2350 n
= alloc_instruction( ctx
, OPCODE_VIEWPORT
, 4 );
2354 n
[3].i
= (GLint
) width
;
2355 n
[4].i
= (GLint
) height
;
2357 if (ctx
->ExecuteFlag
) {
2358 (*ctx
->Exec
.Viewport
)( ctx
, x
, y
, width
, height
);
2363 static void save_WindowPos4fMESA( GLcontext
*ctx
,
2364 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
2367 FLUSH_VB(ctx
, "dlist");
2368 n
= alloc_instruction( ctx
, OPCODE_WINDOW_POS
, 4 );
2375 if (ctx
->ExecuteFlag
) {
2376 (*ctx
->Exec
.WindowPos4fMESA
)( ctx
, x
, y
, z
, w
);
2385 /* GL_ARB_multitexture */
2386 static void save_ActiveTexture( GLcontext
*ctx
, GLenum target
)
2389 FLUSH_VB(ctx
, "dlist");
2390 n
= alloc_instruction( ctx
, OPCODE_ACTIVE_TEXTURE
, 1 );
2394 if (ctx
->ExecuteFlag
) {
2395 (*ctx
->Exec
.ActiveTexture
)( ctx
, target
);
2400 /* GL_ARB_multitexture */
2401 static void save_ClientActiveTexture( GLcontext
*ctx
, GLenum target
)
2404 FLUSH_VB(ctx
, "dlist");
2405 n
= alloc_instruction( ctx
, OPCODE_CLIENT_ACTIVE_TEXTURE
, 1 );
2409 if (ctx
->ExecuteFlag
) {
2410 (*ctx
->Exec
.ClientActiveTexture
)( ctx
, target
);
2416 void gl_compile_cassette( GLcontext
*ctx
)
2418 Node
*n
= alloc_instruction( ctx
, OPCODE_VERTEX_CASSETTE
, 8 );
2419 struct immediate
*im
= ctx
->input
;
2425 /* Do some easy optimizations of the cassette.
2428 if (0 && im
->v
.Obj
.size
< 4 && im
->Count
> 15) {
2429 im
->Bounds
= (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat
));
2430 (gl_calc_bound_tab
[im
->v
.Obj
.size
])( im
->Bounds
, &im
->v
.Obj
);
2434 n
[1].data
= (void *)im
;
2435 n
[2].ui
= im
->Start
;
2436 n
[3].ui
= im
->Count
;
2437 n
[4].ui
= im
->BeginState
;
2438 n
[5].ui
= im
->OrFlag
;
2439 n
[6].ui
= im
->AndFlag
;
2440 n
[7].ui
= im
->LastData
;
2441 n
[8].ui
= im
->LastPrimitive
;
2443 if (im
->Count
> VB_MAX
- 4) {
2445 struct immediate
*new_im
= gl_immediate_alloc(ctx
);
2446 if (!new_im
) return;
2447 SET_IMMEDIATE( ctx
, new_im
);
2448 gl_reset_input( ctx
);
2452 im
->Start
= im
->Count
; /* don't clear anything in reset_input */
2455 im
->Primitive
[im
->Start
] = ctx
->Current
.Primitive
;
2456 im
->LastPrimitive
= im
->Start
;
2457 im
->BeginState
= VERT_BEGIN_0
;
2462 fprintf(stderr
, "in compile_cassette, BeginState is %x\n",
2467 /* KW: Compile commands
2469 * Will appear in the list before the vertex buffer containing the
2470 * command that provoked the error. I don't see this as a problem.
2472 void gl_save_error( GLcontext
*ctx
, GLenum error
, const char *s
)
2475 n
= alloc_instruction( ctx
, OPCODE_ERROR
, 2 );
2478 n
[2].data
= (void *) s
;
2480 /* execute already done */
2483 /**********************************************************************/
2484 /* Display list execution */
2485 /**********************************************************************/
2489 * Execute a display list. Note that the ListBase offset must have already
2490 * been added before calling this function. I.e. the list argument is
2491 * the absolute list number, not relative to ListBase.
2492 * Input: list - display list number
2494 static void execute_list( GLcontext
*ctx
, GLuint list
)
2496 static struct gl_pixelstore_attrib defaultPacking
= {
2501 0, /* ImageHeight */
2503 GL_FALSE
, /* SwapBytes */
2504 GL_FALSE
/* LsbFirst */
2510 if (!gl_IsList(ctx
,list
))
2513 /* mesa_print_display_list( list ); */
2517 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
2521 opcode
= n
[0].opcode
;
2525 gl_error( ctx
, n
[1].e
, (const char *) n
[2].data
);
2527 case OPCODE_VERTEX_CASSETTE
: {
2528 struct immediate
*IM
;
2531 gl_update_state(ctx
);
2532 if (ctx
->CompileCVAFlag
) {
2533 ctx
->CompileCVAFlag
= 0;
2534 ctx
->CVA
.elt
.pipeline_valid
= 0;
2536 if (!ctx
->CVA
.elt
.pipeline_valid
)
2537 gl_build_immediate_pipeline( ctx
);
2540 IM
= (struct immediate
*) n
[1].data
;
2541 IM
->Start
= n
[2].ui
;
2542 IM
->Count
= n
[3].ui
;
2543 IM
->BeginState
= n
[4].ui
;
2544 IM
->OrFlag
= n
[5].ui
;
2545 IM
->AndFlag
= n
[6].ui
;
2546 IM
->LastData
= n
[7].ui
;
2547 IM
->LastPrimitive
= n
[8].ui
;
2549 if ((MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
) &&
2550 (MESA_VERBOSE
& VERBOSE_IMMEDIATE
))
2551 gl_print_cassette( (struct immediate
*) n
[1].data
, 0, ~0 );
2554 fprintf(stderr
, "Run cassette %d, rows %d..%d, beginstate %x\n",
2556 IM
->Start
, IM
->Count
, IM
->BeginState
);
2558 gl_fixup_cassette( ctx
, (struct immediate
*) n
[1].data
);
2559 gl_execute_cassette( ctx
, (struct immediate
*) n
[1].data
);
2563 gl_Accum( ctx
, n
[1].e
, n
[2].f
);
2565 case OPCODE_ALPHA_FUNC
:
2566 gl_AlphaFunc( ctx
, n
[1].e
, n
[2].f
);
2568 case OPCODE_BIND_TEXTURE
:
2569 gl_BindTexture( ctx
, n
[1].e
, n
[2].ui
);
2573 const struct gl_image
*image
= (struct gl_image
*) n
[7].data
;
2574 const GLubyte
*bitmap
= image
? image
->Data
: NULL
;
2575 gl_Bitmap( ctx
, (GLsizei
) n
[1].i
, (GLsizei
) n
[2].i
,
2576 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
,
2577 bitmap
, &defaultPacking
);
2580 case OPCODE_BLEND_COLOR
:
2581 gl_BlendColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2583 case OPCODE_BLEND_EQUATION
:
2584 gl_BlendEquation( ctx
, n
[1].e
);
2586 case OPCODE_BLEND_FUNC
:
2587 gl_BlendFunc( ctx
, n
[1].e
, n
[2].e
);
2589 case OPCODE_BLEND_FUNC_SEPARATE
:
2590 gl_BlendFuncSeparate( ctx
, n
[1].e
, n
[2].e
, n
[3].e
, n
[4].e
);
2592 case OPCODE_CALL_LIST
:
2593 /* Generated by glCallList(), don't add ListBase */
2594 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2595 execute_list( ctx
, n
[1].ui
);
2598 case OPCODE_CALL_LIST_OFFSET
:
2599 /* Generated by glCallLists() so we must add ListBase */
2600 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2601 execute_list( ctx
, ctx
->List
.ListBase
+ n
[1].ui
);
2605 gl_Clear( ctx
, n
[1].bf
);
2607 case OPCODE_CLEAR_COLOR
:
2608 gl_ClearColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2610 case OPCODE_CLEAR_ACCUM
:
2611 gl_ClearAccum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2613 case OPCODE_CLEAR_DEPTH
:
2614 gl_ClearDepth( ctx
, (GLclampd
) n
[1].f
);
2616 case OPCODE_CLEAR_INDEX
:
2617 gl_ClearIndex( ctx
, n
[1].ui
);
2619 case OPCODE_CLEAR_STENCIL
:
2620 gl_ClearStencil( ctx
, n
[1].i
);
2622 case OPCODE_CLIP_PLANE
:
2629 gl_ClipPlane( ctx
, n
[1].e
, equ
);
2632 case OPCODE_COLOR_MASK
:
2633 gl_ColorMask( ctx
, n
[1].b
, n
[2].b
, n
[3].b
, n
[4].b
);
2635 case OPCODE_COLOR_MATERIAL
:
2636 gl_ColorMaterial( ctx
, n
[1].e
, n
[2].e
);
2638 case OPCODE_COLOR_TABLE
:
2639 gl_ColorTable( ctx
, n
[1].e
, n
[2].e
, (struct gl_image
*) n
[3].data
);
2641 case OPCODE_COLOR_SUB_TABLE
:
2642 gl_ColorSubTable( ctx
, n
[1].e
, n
[2].i
,
2643 (struct gl_image
*) n
[3].data
);
2645 case OPCODE_COPY_PIXELS
:
2646 gl_CopyPixels( ctx
, n
[1].i
, n
[2].i
,
2647 (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
, n
[5].e
);
2649 case OPCODE_COPY_TEX_IMAGE1D
:
2650 gl_CopyTexImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2651 n
[5].i
, n
[6].i
, n
[7].i
);
2653 case OPCODE_COPY_TEX_IMAGE2D
:
2654 gl_CopyTexImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2655 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2657 case OPCODE_COPY_TEX_SUB_IMAGE1D
:
2658 gl_CopyTexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2661 case OPCODE_COPY_TEX_SUB_IMAGE2D
:
2662 gl_CopyTexSubImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2663 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2665 case OPCODE_COPY_TEX_SUB_IMAGE3D
:
2666 gl_CopyTexSubImage3D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2667 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
, n
[9].i
);
2669 case OPCODE_CULL_FACE
:
2670 gl_CullFace( ctx
, n
[1].e
);
2672 case OPCODE_DEPTH_FUNC
:
2673 gl_DepthFunc( ctx
, n
[1].e
);
2675 case OPCODE_DEPTH_MASK
:
2676 gl_DepthMask( ctx
, n
[1].b
);
2678 case OPCODE_DEPTH_RANGE
:
2679 gl_DepthRange( ctx
, (GLclampd
) n
[1].f
, (GLclampd
) n
[2].f
);
2681 case OPCODE_DISABLE
:
2682 gl_Disable( ctx
, n
[1].e
);
2684 case OPCODE_DRAW_BUFFER
:
2685 gl_DrawBuffer( ctx
, n
[1].e
);
2687 case OPCODE_DRAW_PIXELS
:
2688 gl_DrawPixels( ctx
, (struct gl_image
*) n
[1].data
);
2691 gl_Enable( ctx
, n
[1].e
);
2693 case OPCODE_EVALMESH1
:
2694 gl_EvalMesh1( ctx
, n
[1].e
, n
[2].i
, n
[3].i
);
2696 case OPCODE_EVALMESH2
:
2697 gl_EvalMesh2( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
);
2706 gl_Fogfv( ctx
, n
[1].e
, p
);
2709 case OPCODE_FRONT_FACE
:
2710 gl_FrontFace( ctx
, n
[1].e
);
2712 case OPCODE_FRUSTUM
:
2713 gl_Frustum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2716 gl_Hint( ctx
, n
[1].e
, n
[2].e
);
2718 case OPCODE_INDEX_MASK
:
2719 gl_IndexMask( ctx
, n
[1].ui
);
2721 case OPCODE_INIT_NAMES
:
2722 gl_InitNames( ctx
);
2731 gl_Lightfv( ctx
, n
[1].e
, n
[2].e
, p
, 4 );
2734 case OPCODE_LIGHT_MODEL
:
2741 gl_LightModelfv( ctx
, n
[1].e
, p
);
2744 case OPCODE_LINE_STIPPLE
:
2745 gl_LineStipple( ctx
, n
[1].i
, n
[2].us
);
2747 case OPCODE_LINE_WIDTH
:
2748 gl_LineWidth( ctx
, n
[1].f
);
2750 case OPCODE_LIST_BASE
:
2751 gl_ListBase( ctx
, n
[1].ui
);
2753 case OPCODE_LOAD_IDENTITY
:
2754 gl_LoadIdentity( ctx
);
2756 case OPCODE_LOAD_MATRIX
:
2757 if (sizeof(Node
)==sizeof(GLfloat
)) {
2758 gl_LoadMatrixf( ctx
, &n
[1].f
);
2763 for (i
=0;i
<16;i
++) {
2766 gl_LoadMatrixf( ctx
, m
);
2769 case OPCODE_LOAD_NAME
:
2770 gl_LoadName( ctx
, n
[1].ui
);
2772 case OPCODE_LOGIC_OP
:
2773 gl_LogicOp( ctx
, n
[1].e
);
2776 gl_Map1f( ctx
, n
[1].e
, n
[2].f
, n
[3].f
,
2777 n
[4].i
, n
[5].i
, (GLfloat
*) n
[6].data
, GL_TRUE
);
2780 gl_Map2f( ctx
, n
[1].e
,
2781 n
[2].f
, n
[3].f
, /* u1, u2 */
2782 n
[6].i
, n
[8].i
, /* ustride, uorder */
2783 n
[4].f
, n
[5].f
, /* v1, v2 */
2784 n
[7].i
, n
[9].i
, /* vstride, vorder */
2785 (GLfloat
*) n
[10].data
,
2788 case OPCODE_MAPGRID1
:
2789 gl_MapGrid1f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
);
2791 case OPCODE_MAPGRID2
:
2792 gl_MapGrid2f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
, n
[4].i
, n
[5].f
, n
[6].f
);
2794 case OPCODE_MATRIX_MODE
:
2795 gl_MatrixMode( ctx
, n
[1].e
);
2797 case OPCODE_MULT_MATRIX
:
2798 if (sizeof(Node
)==sizeof(GLfloat
)) {
2799 gl_MultMatrixf( ctx
, &n
[1].f
);
2804 for (i
=0;i
<16;i
++) {
2807 gl_MultMatrixf( ctx
, m
);
2811 gl_Ortho( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2813 case OPCODE_PASSTHROUGH
:
2814 gl_PassThrough( ctx
, n
[1].f
);
2816 case OPCODE_PIXEL_MAP
:
2817 gl_PixelMapfv( ctx
, n
[1].e
, n
[2].i
, (GLfloat
*) n
[3].data
);
2819 case OPCODE_PIXEL_TRANSFER
:
2820 gl_PixelTransferf( ctx
, n
[1].e
, n
[2].f
);
2822 case OPCODE_PIXEL_ZOOM
:
2823 gl_PixelZoom( ctx
, n
[1].f
, n
[2].f
);
2825 case OPCODE_POINT_SIZE
:
2826 gl_PointSize( ctx
, n
[1].f
);
2828 case OPCODE_POINT_PARAMETERS
:
2834 gl_PointParameterfvEXT( ctx
, n
[1].e
, params
);
2837 case OPCODE_POLYGON_MODE
:
2838 gl_PolygonMode( ctx
, n
[1].e
, n
[2].e
);
2840 case OPCODE_POLYGON_STIPPLE
:
2841 gl_PolygonStipple( ctx
, (GLuint
*) n
[1].data
);
2843 case OPCODE_POLYGON_OFFSET
:
2844 gl_PolygonOffset( ctx
, n
[1].f
, n
[2].f
);
2846 case OPCODE_POP_ATTRIB
:
2847 gl_PopAttrib( ctx
);
2849 case OPCODE_POP_MATRIX
:
2850 gl_PopMatrix( ctx
);
2852 case OPCODE_POP_NAME
:
2855 case OPCODE_PRIORITIZE_TEXTURE
:
2856 gl_PrioritizeTextures( ctx
, 1, &n
[1].ui
, &n
[2].f
);
2858 case OPCODE_PUSH_ATTRIB
:
2859 gl_PushAttrib( ctx
, n
[1].bf
);
2861 case OPCODE_PUSH_MATRIX
:
2862 gl_PushMatrix( ctx
);
2864 case OPCODE_PUSH_NAME
:
2865 gl_PushName( ctx
, n
[1].ui
);
2867 case OPCODE_RASTER_POS
:
2868 gl_RasterPos4f( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2870 case OPCODE_READ_BUFFER
:
2871 gl_ReadBuffer( ctx
, n
[1].e
);
2874 gl_Rectf( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2877 gl_Scalef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
2879 case OPCODE_SCISSOR
:
2880 gl_Scissor( ctx
, n
[1].i
, n
[2].i
, n
[3].i
, n
[4].i
);
2882 case OPCODE_SHADE_MODEL
:
2883 gl_ShadeModel( ctx
, n
[1].e
);
2885 case OPCODE_STENCIL_FUNC
:
2886 gl_StencilFunc( ctx
, n
[1].e
, n
[2].i
, n
[3].ui
);
2888 case OPCODE_STENCIL_MASK
:
2889 gl_StencilMask( ctx
, n
[1].ui
);
2891 case OPCODE_STENCIL_OP
:
2892 gl_StencilOp( ctx
, n
[1].e
, n
[2].e
, n
[3].e
);
2901 gl_TexEnvfv( ctx
, n
[1].e
, n
[2].e
, params
);
2911 gl_TexGenfv( ctx
, n
[1].e
, n
[2].e
, params
);
2914 case OPCODE_TEXPARAMETER
:
2921 gl_TexParameterfv( ctx
, n
[1].e
, n
[2].e
, params
);
2924 case OPCODE_TEX_IMAGE1D
:
2926 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2927 ctx
->Unpack
= defaultPacking
;
2929 n
[1].e
, /* target */
2931 n
[3].i
, /* components */
2933 n
[5].e
, /* border */
2934 n
[6].e
, /* format */
2937 ctx
->Unpack
= save
; /* restore */
2940 case OPCODE_TEX_IMAGE2D
:
2942 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2943 ctx
->Unpack
= defaultPacking
;
2945 n
[1].e
, /* target */
2947 n
[3].i
, /* components */
2949 n
[5].i
, /* height */
2950 n
[6].e
, /* border */
2951 n
[7].e
, /* format */
2954 ctx
->Unpack
= save
; /* restore */
2957 case OPCODE_TEX_IMAGE3D
:
2959 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2960 ctx
->Unpack
= defaultPacking
;
2962 n
[1].e
, /* target */
2964 n
[3].i
, /* components */
2966 n
[5].i
, /* height */
2968 n
[7].e
, /* border */
2969 n
[8].e
, /* format */
2972 ctx
->Unpack
= save
; /* restore */
2975 case OPCODE_TEX_SUB_IMAGE1D
:
2977 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2978 ctx
->Unpack
= defaultPacking
;
2979 gl_TexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].e
,
2980 n
[6].e
, n
[7].data
);
2981 ctx
->Unpack
= save
; /* restore */
2984 case OPCODE_TEX_SUB_IMAGE2D
:
2986 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2987 ctx
->Unpack
= defaultPacking
;
2988 (*ctx
->Exec
.TexSubImage2D
)( ctx
, n
[1].e
, n
[2].i
, n
[3].i
,
2990 n
[6].i
, n
[7].e
, n
[8].e
, n
[9].data
);
2991 ctx
->Unpack
= save
; /* restore */
2994 case OPCODE_TEX_SUB_IMAGE3D
:
2996 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2997 ctx
->Unpack
= defaultPacking
;
2998 gl_TexSubImage3D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
,
2999 n
[6].i
, n
[7].i
, n
[8].i
, n
[9].e
, n
[10].e
,
3001 ctx
->Unpack
= save
; /* restore */
3004 case OPCODE_TRANSLATE
:
3005 gl_Translatef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
3007 case OPCODE_VIEWPORT
:
3009 n
[1].i
, n
[2].i
, (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
);
3011 case OPCODE_WINDOW_POS
:
3012 gl_WindowPos4fMESA( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
3014 case OPCODE_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
3015 gl_ActiveTexture( ctx
, n
[1].e
);
3017 case OPCODE_CLIENT_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
3018 gl_ClientActiveTexture( ctx
, n
[1].e
);
3020 case OPCODE_CONTINUE
:
3021 n
= (Node
*) n
[1].next
;
3023 case OPCODE_END_OF_LIST
:
3029 sprintf(msg
, "Error in execute_list: opcode=%d", (int) opcode
);
3030 gl_problem( ctx
, msg
);
3035 /* increment n to point to next compiled command */
3036 if (opcode
!=OPCODE_CONTINUE
) {
3037 n
+= InstSize
[opcode
];
3048 /**********************************************************************/
3050 /**********************************************************************/
3056 * Test if a display list number is valid.
3058 GLboolean
gl_IsList( GLcontext
*ctx
, GLuint list
)
3060 if (list
> 0 && HashLookup(ctx
->Shared
->DisplayList
, list
)) {
3071 * Delete a sequence of consecutive display lists.
3073 void gl_DeleteLists( GLcontext
*ctx
, GLuint list
, GLsizei range
)
3077 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glDeleteLists");
3079 gl_error( ctx
, GL_INVALID_VALUE
, "glDeleteLists" );
3082 for (i
=list
;i
<list
+range
;i
++) {
3083 gl_destroy_list( ctx
, i
);
3090 * Return a display list number, n, such that lists n through n+range-1
3093 GLuint
gl_GenLists( GLcontext
*ctx
, GLsizei range
)
3097 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx
, "glGenLists", 0);
3099 gl_error( ctx
, GL_INVALID_VALUE
, "glGenLists" );
3106 base
= HashFindFreeKeyBlock(ctx
->Shared
->DisplayList
, range
);
3108 /* reserve the list IDs by with empty/dummy lists */
3110 for (i
=0; i
<range
; i
++) {
3111 HashInsert(ctx
->Shared
->DisplayList
, base
+i
, make_empty_list());
3120 * Begin a new display list.
3122 void gl_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
3124 struct immediate
*IM
;
3125 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glNewList");
3127 if (MESA_VERBOSE
&VERBOSE_API
)
3128 fprintf(stderr
, "glNewList %u %s\n", list
, gl_lookup_enum_by_nr(mode
));
3131 gl_error( ctx
, GL_INVALID_VALUE
, "glNewList" );
3135 if (mode
!=GL_COMPILE
&& mode
!=GL_COMPILE_AND_EXECUTE
) {
3136 gl_error( ctx
, GL_INVALID_ENUM
, "glNewList" );
3140 if (ctx
->CurrentListPtr
) {
3141 /* already compiling a display list */
3142 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
3146 /* Allocate new display list */
3147 ctx
->CurrentListNum
= list
;
3148 ctx
->CurrentBlock
= (Node
*) MALLOC( sizeof(Node
) * BLOCK_SIZE
);
3149 ctx
->CurrentListPtr
= ctx
->CurrentBlock
;
3150 ctx
->CurrentPos
= 0;
3152 IM
= gl_immediate_alloc( ctx
);
3153 SET_IMMEDIATE( ctx
, IM
);
3154 gl_reset_input( ctx
);
3156 ctx
->CompileFlag
= GL_TRUE
;
3157 ctx
->CompileCVAFlag
= GL_FALSE
;
3158 ctx
->ExecuteFlag
= (mode
== GL_COMPILE_AND_EXECUTE
);
3159 ctx
->API
= ctx
->Save
; /* Switch the API function pointers */
3165 * End definition of current display list.
3167 void gl_EndList( GLcontext
*ctx
)
3169 if (MESA_VERBOSE
&VERBOSE_API
)
3170 fprintf(stderr
, "glEndList\n");
3172 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
, "glEndList" );
3174 /* Check that a list is under construction */
3175 if (!ctx
->CurrentListPtr
) {
3176 gl_error( ctx
, GL_INVALID_OPERATION
, "glEndList" );
3180 (void) alloc_instruction( ctx
, OPCODE_END_OF_LIST
, 0 );
3182 /* Destroy old list, if any */
3183 gl_destroy_list(ctx
, ctx
->CurrentListNum
);
3184 /* Install the list */
3185 HashInsert(ctx
->Shared
->DisplayList
, ctx
->CurrentListNum
, ctx
->CurrentListPtr
);
3188 if (MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
)
3189 mesa_print_display_list(ctx
->CurrentListNum
);
3191 ctx
->CurrentListNum
= 0;
3192 ctx
->CurrentListPtr
= NULL
;
3193 ctx
->ExecuteFlag
= GL_TRUE
;
3194 ctx
->CompileFlag
= GL_FALSE
;
3195 /* ctx->CompileCVAFlag = ...; */
3197 /* KW: Put back the old input pointer.
3199 if (--ctx
->input
->ref_count
== 0)
3200 gl_immediate_free( ctx
->input
);
3202 SET_IMMEDIATE( ctx
, ctx
->VB
->IM
);
3203 gl_reset_input( ctx
);
3205 /* Haven't tracked down why this is needed.
3209 ctx
->API
= ctx
->Exec
; /* Switch the API function pointers */
3214 void gl_CallList( GLcontext
*ctx
, GLuint list
)
3216 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
3217 /* execute the display list, and restore the CompileFlag. */
3218 GLboolean save_compile_flag
;
3220 if (MESA_VERBOSE
&VERBOSE_API
) {
3221 fprintf(stderr
, "glCallList %u\n", list
);
3222 mesa_print_display_list( list
);
3225 save_compile_flag
= ctx
->CompileFlag
;
3226 ctx
->CompileFlag
= GL_FALSE
;
3228 FLUSH_VB( ctx
, "call list" );
3229 execute_list( ctx
, list
);
3230 ctx
->CompileFlag
= save_compile_flag
;
3232 /* also restore API function pointers to point to "save" versions */
3233 if (save_compile_flag
)
3234 ctx
->API
= ctx
->Save
;
3240 * Execute glCallLists: call multiple display lists.
3242 void gl_CallLists( GLcontext
*ctx
,
3243 GLsizei n
, GLenum type
, const GLvoid
*lists
)
3247 GLboolean save_compile_flag
;
3249 /* Save the CompileFlag status, turn it off, execute display list,
3250 * and restore the CompileFlag.
3252 save_compile_flag
= ctx
->CompileFlag
;
3253 ctx
->CompileFlag
= GL_FALSE
;
3255 FLUSH_VB( ctx
, "call lists" );
3258 list
= translate_id( i
, type
, lists
);
3259 execute_list( ctx
, ctx
->List
.ListBase
+ list
);
3262 ctx
->CompileFlag
= save_compile_flag
;
3264 /* also restore API function pointers to point to "save" versions */
3265 if (save_compile_flag
)
3266 ctx
->API
= ctx
->Save
;
3269 /* RESET_IMMEDIATE( ctx ); */
3275 * Set the offset added to list numbers in glCallLists.
3277 void gl_ListBase( GLcontext
*ctx
, GLuint base
)
3279 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glListBase");
3280 ctx
->List
.ListBase
= base
;
3289 * Assign all the pointers in 'table' to point to Mesa's display list
3290 * building functions.
3292 void gl_init_dlist_pointers( struct gl_api_table
*table
)
3294 table
->Accum
= save_Accum
;
3295 table
->AlphaFunc
= save_AlphaFunc
;
3296 table
->AreTexturesResident
= gl_AreTexturesResident
;
3297 table
->BindTexture
= save_BindTexture
;
3298 table
->Bitmap
= save_Bitmap
;
3299 table
->BlendColor
= save_BlendColor
;
3300 table
->BlendEquation
= save_BlendEquation
;
3301 table
->BlendFunc
= save_BlendFunc
;
3302 table
->BlendFuncSeparate
= save_BlendFuncSeparate
;
3303 table
->CallList
= save_CallList
;
3304 table
->CallLists
= save_CallLists
;
3305 table
->Clear
= save_Clear
;
3306 table
->ClearAccum
= save_ClearAccum
;
3307 table
->ClearColor
= save_ClearColor
;
3308 table
->ClearDepth
= save_ClearDepth
;
3309 table
->ClearIndex
= save_ClearIndex
;
3310 table
->ClearStencil
= save_ClearStencil
;
3311 table
->ClipPlane
= save_ClipPlane
;
3312 table
->ColorMask
= save_ColorMask
;
3313 table
->ColorMaterial
= save_ColorMaterial
;
3314 table
->ColorTable
= save_ColorTable
;
3315 table
->ColorSubTable
= save_ColorSubTable
;
3316 table
->CopyPixels
= save_CopyPixels
;
3317 table
->CopyTexImage1D
= save_CopyTexImage1D
;
3318 table
->CopyTexImage2D
= save_CopyTexImage2D
;
3319 table
->CopyTexSubImage1D
= save_CopyTexSubImage1D
;
3320 table
->CopyTexSubImage2D
= save_CopyTexSubImage2D
;
3321 table
->CopyTexSubImage3D
= save_CopyTexSubImage3D
;
3322 table
->CullFace
= save_CullFace
;
3323 table
->DeleteLists
= gl_DeleteLists
; /* NOT SAVED */
3324 table
->DeleteTextures
= gl_DeleteTextures
; /* NOT SAVED */
3325 table
->DepthFunc
= save_DepthFunc
;
3326 table
->DepthMask
= save_DepthMask
;
3327 table
->DepthRange
= save_DepthRange
;
3328 table
->Disable
= save_Disable
;
3329 table
->DisableClientState
= gl_DisableClientState
; /* NOT SAVED */
3330 table
->DrawBuffer
= save_DrawBuffer
;
3331 table
->DrawPixels
= save_DrawPixels
;
3332 table
->Enable
= save_Enable
;
3333 table
->Error
= gl_save_error
;
3334 table
->EnableClientState
= gl_EnableClientState
; /* NOT SAVED */
3335 table
->EndList
= gl_EndList
; /* NOT SAVED */
3336 table
->EvalMesh1
= save_EvalMesh1
;
3337 table
->EvalMesh2
= save_EvalMesh2
;
3338 table
->FeedbackBuffer
= gl_FeedbackBuffer
; /* NOT SAVED */
3339 table
->Finish
= gl_Finish
; /* NOT SAVED */
3340 table
->Flush
= gl_Flush
; /* NOT SAVED */
3341 table
->Fogfv
= save_Fogfv
;
3342 table
->FrontFace
= save_FrontFace
;
3343 table
->Frustum
= save_Frustum
;
3344 table
->GenLists
= gl_GenLists
; /* NOT SAVED */
3345 table
->GenTextures
= gl_GenTextures
; /* NOT SAVED */
3347 /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
3348 table
->GetBooleanv
= gl_GetBooleanv
;
3349 table
->GetClipPlane
= gl_GetClipPlane
;
3350 table
->GetColorTable
= gl_GetColorTable
;
3351 table
->GetColorTableParameteriv
= gl_GetColorTableParameteriv
;
3352 table
->GetDoublev
= gl_GetDoublev
;
3353 table
->GetError
= gl_GetError
;
3354 table
->GetFloatv
= gl_GetFloatv
;
3355 table
->GetIntegerv
= gl_GetIntegerv
;
3356 table
->GetString
= gl_GetString
;
3357 table
->GetLightfv
= gl_GetLightfv
;
3358 table
->GetLightiv
= gl_GetLightiv
;
3359 table
->GetMapdv
= gl_GetMapdv
;
3360 table
->GetMapfv
= gl_GetMapfv
;
3361 table
->GetMapiv
= gl_GetMapiv
;
3362 table
->GetMaterialfv
= gl_GetMaterialfv
;
3363 table
->GetMaterialiv
= gl_GetMaterialiv
;
3364 table
->GetPixelMapfv
= gl_GetPixelMapfv
;
3365 table
->GetPixelMapuiv
= gl_GetPixelMapuiv
;
3366 table
->GetPixelMapusv
= gl_GetPixelMapusv
;
3367 table
->GetPointerv
= gl_GetPointerv
;
3368 table
->GetPolygonStipple
= gl_GetPolygonStipple
;
3369 table
->GetTexEnvfv
= gl_GetTexEnvfv
;
3370 table
->GetTexEnviv
= gl_GetTexEnviv
;
3371 table
->GetTexGendv
= gl_GetTexGendv
;
3372 table
->GetTexGenfv
= gl_GetTexGenfv
;
3373 table
->GetTexGeniv
= gl_GetTexGeniv
;
3374 table
->GetTexImage
= gl_GetTexImage
;
3375 table
->GetTexLevelParameterfv
= gl_GetTexLevelParameterfv
;
3376 table
->GetTexLevelParameteriv
= gl_GetTexLevelParameteriv
;
3377 table
->GetTexParameterfv
= gl_GetTexParameterfv
;
3378 table
->GetTexParameteriv
= gl_GetTexParameteriv
;
3380 table
->Hint
= save_Hint
;
3381 table
->IndexMask
= save_IndexMask
;
3382 table
->InitNames
= save_InitNames
;
3383 table
->IsEnabled
= gl_IsEnabled
; /* NOT SAVED */
3384 table
->IsTexture
= gl_IsTexture
; /* NOT SAVED */
3385 table
->IsList
= gl_IsList
; /* NOT SAVED */
3386 table
->LightModelfv
= save_LightModelfv
;
3387 table
->Lightfv
= save_Lightfv
;
3388 table
->LineStipple
= save_LineStipple
;
3389 table
->LineWidth
= save_LineWidth
;
3390 table
->ListBase
= save_ListBase
;
3391 table
->LoadIdentity
= save_LoadIdentity
;
3392 table
->LoadMatrixf
= save_LoadMatrixf
;
3393 table
->LoadName
= save_LoadName
;
3394 table
->LogicOp
= save_LogicOp
;
3395 table
->Map1f
= save_Map1f
;
3396 table
->Map2f
= save_Map2f
;
3397 table
->MapGrid1f
= save_MapGrid1f
;
3398 table
->MapGrid2f
= save_MapGrid2f
;
3399 table
->MatrixMode
= save_MatrixMode
;
3400 table
->MultMatrixf
= save_MultMatrixf
;
3401 table
->NewList
= save_NewList
;
3402 table
->Ortho
= save_Ortho
;
3403 table
->PointParameterfvEXT
= save_PointParameterfvEXT
;
3404 table
->PassThrough
= save_PassThrough
;
3405 table
->PixelMapfv
= save_PixelMapfv
;
3406 table
->PixelStorei
= gl_PixelStorei
; /* NOT SAVED */
3407 table
->PixelTransferf
= save_PixelTransferf
;
3408 table
->PixelZoom
= save_PixelZoom
;
3409 table
->PointSize
= save_PointSize
;
3410 table
->PolygonMode
= save_PolygonMode
;
3411 table
->PolygonOffset
= save_PolygonOffset
;
3412 table
->PolygonStipple
= save_PolygonStipple
;
3413 table
->PopAttrib
= save_PopAttrib
;
3414 table
->PopClientAttrib
= gl_PopClientAttrib
; /* NOT SAVED */
3415 table
->PopMatrix
= save_PopMatrix
;
3416 table
->PopName
= save_PopName
;
3417 table
->PrioritizeTextures
= save_PrioritizeTextures
;
3418 table
->PushAttrib
= save_PushAttrib
;
3419 table
->PushClientAttrib
= gl_PushClientAttrib
; /* NOT SAVED */
3420 table
->PushMatrix
= save_PushMatrix
;
3421 table
->PushName
= save_PushName
;
3422 table
->RasterPos4f
= save_RasterPos4f
;
3423 table
->ReadBuffer
= save_ReadBuffer
;
3424 table
->ReadPixels
= gl_ReadPixels
; /* NOT SAVED */
3425 table
->Rectf
= save_Rectf
;
3426 table
->RenderMode
= gl_RenderMode
; /* NOT SAVED */
3427 table
->Rotatef
= save_Rotatef
;
3428 table
->Scalef
= save_Scalef
;
3429 table
->Scissor
= save_Scissor
;
3430 table
->SelectBuffer
= gl_SelectBuffer
; /* NOT SAVED */
3431 table
->ShadeModel
= save_ShadeModel
;
3432 table
->StencilFunc
= save_StencilFunc
;
3433 table
->StencilMask
= save_StencilMask
;
3434 table
->StencilOp
= save_StencilOp
;
3435 table
->TexEnvfv
= save_TexEnvfv
;
3436 table
->TexGenfv
= save_TexGenfv
;
3437 table
->TexImage1D
= save_TexImage1D
;
3438 table
->TexImage2D
= save_TexImage2D
;
3439 table
->TexImage3D
= save_TexImage3D
;
3440 table
->TexSubImage1D
= save_TexSubImage1D
;
3441 table
->TexSubImage2D
= save_TexSubImage2D
;
3442 table
->TexSubImage3D
= save_TexSubImage3D
;
3443 table
->TexParameterfv
= save_TexParameterfv
;
3444 table
->Translatef
= save_Translatef
;
3445 table
->Viewport
= save_Viewport
;
3447 /* GL_MESA_window_pos extension */
3448 table
->WindowPos4fMESA
= save_WindowPos4fMESA
;
3450 /* GL_MESA_resize_buffers extension */
3451 table
->ResizeBuffersMESA
= gl_ResizeBuffersMESA
;
3453 /* GL_ARB_multitexture */
3454 table
->ActiveTexture
= save_ActiveTexture
;
3455 table
->ClientActiveTexture
= save_ClientActiveTexture
;
3463 static const char *enum_string( GLenum k
)
3465 return gl_lookup_enum_by_nr( k
);
3470 * Print the commands in a display list. For debugging only.
3471 * TODO: many commands aren't handled yet.
3473 static void print_list( GLcontext
*ctx
, FILE *f
, GLuint list
)
3479 if (!glIsList(list
)) {
3480 fprintf(f
,"%u is not a display list ID\n",list
);
3484 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
3486 fprintf( f
, "START-LIST %u, address %p\n", list
, (void*)n
);
3488 done
= n
? GL_FALSE
: GL_TRUE
;
3490 opcode
= n
[0].opcode
;
3494 fprintf(f
,"accum %s %g\n", enum_string(n
[1].e
), n
[2].f
);
3497 fprintf(f
,"Bitmap %d %d %g %g %g %g %p\n", n
[1].i
, n
[2].i
,
3498 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
, (void *) n
[7].data
);
3500 case OPCODE_CALL_LIST
:
3501 fprintf(f
,"CallList %d\n", (int) n
[1].ui
);
3503 case OPCODE_CALL_LIST_OFFSET
:
3504 fprintf(f
,"CallList %d + offset %u = %u\n", (int) n
[1].ui
,
3505 ctx
->List
.ListBase
, ctx
->List
.ListBase
+ n
[1].ui
);
3507 case OPCODE_DISABLE
:
3508 fprintf(f
,"Disable %s\n", enum_string(n
[1].e
));
3511 fprintf(f
,"Enable %s\n", enum_string(n
[1].e
));
3513 case OPCODE_FRUSTUM
:
3514 fprintf(f
,"Frustum %g %g %g %g %g %g\n",
3515 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3517 case OPCODE_LINE_STIPPLE
:
3518 fprintf(f
,"LineStipple %d %x\n", n
[1].i
, (int) n
[2].us
);
3520 case OPCODE_LOAD_IDENTITY
:
3521 fprintf(f
,"LoadIdentity\n");
3523 case OPCODE_LOAD_MATRIX
:
3524 fprintf(f
,"LoadMatrix\n");
3525 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3526 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3527 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3528 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3530 case OPCODE_MULT_MATRIX
:
3531 fprintf(f
,"MultMatrix (or Rotate)\n");
3532 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3533 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3534 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3535 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3538 fprintf(f
,"Ortho %g %g %g %g %g %g\n",
3539 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3541 case OPCODE_POP_ATTRIB
:
3542 fprintf(f
,"PopAttrib\n");
3544 case OPCODE_POP_MATRIX
:
3545 fprintf(f
,"PopMatrix\n");
3547 case OPCODE_POP_NAME
:
3548 fprintf(f
,"PopName\n");
3550 case OPCODE_PUSH_ATTRIB
:
3551 fprintf(f
,"PushAttrib %x\n", n
[1].bf
);
3553 case OPCODE_PUSH_MATRIX
:
3554 fprintf(f
,"PushMatrix\n");
3556 case OPCODE_PUSH_NAME
:
3557 fprintf(f
,"PushName %d\n", (int) n
[1].ui
);
3559 case OPCODE_RASTER_POS
:
3560 fprintf(f
,"RasterPos %g %g %g %g\n", n
[1].f
, n
[2].f
,n
[3].f
,n
[4].f
);
3563 fprintf( f
, "Rectf %g %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
3566 fprintf(f
,"Scale %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3568 case OPCODE_TRANSLATE
:
3569 fprintf(f
,"Translate %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3571 case OPCODE_BIND_TEXTURE
:
3572 fprintf(f
,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n
[1].ui
),
3575 case OPCODE_SHADE_MODEL
:
3576 fprintf(f
,"ShadeModel %s\n", gl_lookup_enum_by_nr(n
[1].ui
));
3580 * meta opcodes/commands
3583 fprintf(f
,"Error: %s %s\n", enum_string(n
[1].e
), (const char *)n
[2].data
);
3585 case OPCODE_VERTEX_CASSETTE
:
3586 fprintf(f
,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
3587 ((struct immediate
*) n
[1].data
)->id
,
3590 /* gl_print_cassette( (struct immediate *) n[1].data, */
3593 case OPCODE_CONTINUE
:
3594 fprintf(f
,"DISPLAY-LIST-CONTINUE\n");
3595 n
= (Node
*) n
[1].next
;
3597 case OPCODE_END_OF_LIST
:
3598 fprintf(f
,"END-LIST %u\n", list
);
3602 if (opcode
< 0 || opcode
> OPCODE_END_OF_LIST
) {
3603 fprintf(f
,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
3608 fprintf(f
,"command %d, %u operands\n",opcode
,InstSize
[opcode
]);
3612 /* increment n to point to next compiled command */
3613 if (opcode
!=OPCODE_CONTINUE
) {
3614 n
+= InstSize
[opcode
];
3627 * Clients may call this function to help debug display list problems.
3628 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
3629 * changed, or break in the future without notice.
3631 void mesa_print_display_list( GLuint list
)
3634 print_list( CC
, stderr
, list
);