1 /* $Id: dlist.c,v 1.14 1999/11/08 07:36:44 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"
95 Functions which aren't compiled but executed immediately:
110 Functions which cause errors if called while compiling a display list:
117 * Display list instructions are stored as sequences of "nodes". Nodes
118 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
119 * are linked together with a pointer.
123 /* How many nodes to allocate at a time:
124 * - reduced now that we hold vertices etc. elsewhere.
126 #define BLOCK_SIZE 64
130 * Display list opcodes.
132 * The fact that these identifiers are assigned consecutive
133 * integer values starting at 0 is very important, see InstSize array usage)
135 * KW: Commented out opcodes now handled by vertex-cassettes.
143 OPCODE_BLEND_EQUATION
,
145 OPCODE_BLEND_FUNC_SEPARATE
,
147 OPCODE_CALL_LIST_OFFSET
,
153 OPCODE_CLEAR_STENCIL
,
156 OPCODE_COLOR_MATERIAL
,
158 OPCODE_COLOR_SUB_TABLE
,
160 OPCODE_COPY_TEX_IMAGE1D
,
161 OPCODE_COPY_TEX_IMAGE2D
,
162 OPCODE_COPY_TEX_IMAGE3D
,
163 OPCODE_COPY_TEX_SUB_IMAGE1D
,
164 OPCODE_COPY_TEX_SUB_IMAGE2D
,
165 OPCODE_COPY_TEX_SUB_IMAGE3D
,
191 OPCODE_LOAD_IDENTITY
,
204 OPCODE_PIXEL_TRANSFER
,
207 OPCODE_POINT_PARAMETERS
,
209 OPCODE_POLYGON_STIPPLE
,
210 OPCODE_POLYGON_OFFSET
,
214 OPCODE_PRIORITIZE_TEXTURE
,
223 OPCODE_SELECT_TEXTURE_SGIS
,
224 OPCODE_SELECT_TEXTURE_COORD_SET
,
235 OPCODE_TEX_SUB_IMAGE1D
,
236 OPCODE_TEX_SUB_IMAGE2D
,
237 OPCODE_TEX_SUB_IMAGE3D
,
241 /* GL_ARB_multitexture */
242 OPCODE_ACTIVE_TEXTURE
,
243 OPCODE_CLIENT_ACTIVE_TEXTURE
,
244 /* The following three are meta instructions */
245 OPCODE_ERROR
, /* raise compiled-in error */
246 OPCODE_VERTEX_CASSETTE
, /* render prebuilt vertex buffer */
253 * Each instruction in the display list is stored as a sequence of
254 * contiguous nodes in memory.
255 * Each node is the union of a variety of datatypes.
269 void *next
; /* If prev node's opcode==OPCODE_CONTINUE */
274 /* Number of nodes of storage needed for each instruction: */
275 static GLuint InstSize
[ OPCODE_END_OF_LIST
+1 ];
277 void mesa_print_display_list( GLuint list
);
280 /**********************************************************************/
281 /***** Private *****/
282 /**********************************************************************/
286 * Allocate space for a display list instruction.
287 * Input: opcode - type of instruction
288 * argcount - number of arguments following the instruction
289 * Return: pointer to first node in the instruction
291 static Node
*alloc_instruction( GLcontext
*ctx
, OpCode opcode
, GLint argcount
)
294 GLuint count
= InstSize
[opcode
];
296 assert( (GLint
) count
== argcount
+1 );
298 if (ctx
->CurrentPos
+ count
+ 2 > BLOCK_SIZE
) {
299 /* This block is full. Allocate a new block and chain to it */
300 n
= ctx
->CurrentBlock
+ ctx
->CurrentPos
;
301 n
[0].opcode
= OPCODE_CONTINUE
;
302 newblock
= (Node
*) MALLOC( sizeof(Node
) * BLOCK_SIZE
);
304 gl_error( ctx
, GL_OUT_OF_MEMORY
, "Building display list" );
307 n
[1].next
= (Node
*) newblock
;
308 ctx
->CurrentBlock
= newblock
;
312 n
= ctx
->CurrentBlock
+ ctx
->CurrentPos
;
313 ctx
->CurrentPos
+= count
;
315 n
[0].opcode
= opcode
;
323 * Make an empty display list. This is used by glGenLists() to
324 * reserver display list IDs.
326 static Node
*make_empty_list( void )
328 Node
*n
= (Node
*) MALLOC( sizeof(Node
) );
329 n
[0].opcode
= OPCODE_END_OF_LIST
;
336 * Destroy all nodes in a display list.
337 * Input: list - display list number
339 void gl_destroy_list( GLcontext
*ctx
, GLuint list
)
347 block
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
350 done
= block
? GL_FALSE
: GL_TRUE
;
352 switch (n
[0].opcode
) {
353 /* special cases first */
354 case OPCODE_VERTEX_CASSETTE
:
355 if ( ! -- ((struct immediate
*) n
[1].data
)->ref_count
)
356 gl_immediate_free( (struct immediate
*) n
[1].data
);
357 n
+= InstSize
[n
[0].opcode
];
360 gl_free_control_points( ctx
, n
[1].e
, (GLfloat
*) n
[6].data
);
361 n
+= InstSize
[n
[0].opcode
];
364 gl_free_control_points( ctx
, n
[1].e
, (GLfloat
*) n
[10].data
);
365 n
+= InstSize
[n
[0].opcode
];
367 case OPCODE_DRAW_PIXELS
:
368 gl_free_image( (struct gl_image
*) n
[1].data
);
369 n
+= InstSize
[n
[0].opcode
];
372 gl_free_image( (struct gl_image
*) n
[7].data
);
373 n
+= InstSize
[n
[0].opcode
];
375 case OPCODE_COLOR_TABLE
:
376 gl_free_image( (struct gl_image
*) n
[3].data
);
377 n
+= InstSize
[n
[0].opcode
];
379 case OPCODE_COLOR_SUB_TABLE
:
380 gl_free_image( (struct gl_image
*) n
[3].data
);
381 n
+= InstSize
[n
[0].opcode
];
383 case OPCODE_POLYGON_STIPPLE
:
385 n
+= InstSize
[n
[0].opcode
];
387 case OPCODE_TEX_IMAGE1D
:
389 n
+= InstSize
[n
[0].opcode
];
391 case OPCODE_TEX_IMAGE2D
:
393 n
+= InstSize
[n
[0].opcode
];
395 case OPCODE_TEX_IMAGE3D
:
397 n
+= InstSize
[n
[0].opcode
];
399 case OPCODE_TEX_SUB_IMAGE1D
:
401 n
+= InstSize
[n
[0].opcode
];
403 case OPCODE_TEX_SUB_IMAGE2D
:
405 n
+= InstSize
[n
[0].opcode
];
407 case OPCODE_TEX_SUB_IMAGE3D
:
409 n
+= InstSize
[n
[0].opcode
];
411 case OPCODE_CONTINUE
:
412 n
= (Node
*) n
[1].next
;
416 case OPCODE_END_OF_LIST
:
421 /* Most frequent case */
422 n
+= InstSize
[n
[0].opcode
];
427 HashRemove(ctx
->Shared
->DisplayList
, list
);
433 * Translate the nth element of list from type to GLuint.
435 static GLuint
translate_id( GLsizei n
, GLenum type
, const GLvoid
*list
)
447 bptr
= (GLbyte
*) list
;
448 return (GLuint
) *(bptr
+n
);
449 case GL_UNSIGNED_BYTE
:
450 ubptr
= (GLubyte
*) list
;
451 return (GLuint
) *(ubptr
+n
);
453 sptr
= (GLshort
*) list
;
454 return (GLuint
) *(sptr
+n
);
455 case GL_UNSIGNED_SHORT
:
456 usptr
= (GLushort
*) list
;
457 return (GLuint
) *(usptr
+n
);
459 iptr
= (GLint
*) list
;
460 return (GLuint
) *(iptr
+n
);
461 case GL_UNSIGNED_INT
:
462 uiptr
= (GLuint
*) list
;
463 return (GLuint
) *(uiptr
+n
);
465 fptr
= (GLfloat
*) list
;
466 return (GLuint
) *(fptr
+n
);
468 ubptr
= ((GLubyte
*) list
) + 2*n
;
469 return (GLuint
) *ubptr
* 256 + (GLuint
) *(ubptr
+1);
471 ubptr
= ((GLubyte
*) list
) + 3*n
;
472 return (GLuint
) *ubptr
* 65536
473 + (GLuint
) *(ubptr
+1) * 256
474 + (GLuint
) *(ubptr
+2);
476 ubptr
= ((GLubyte
*) list
) + 4*n
;
477 return (GLuint
) *ubptr
* 16777216
478 + (GLuint
) *(ubptr
+1) * 65536
479 + (GLuint
) *(ubptr
+2) * 256
480 + (GLuint
) *(ubptr
+3);
489 /**********************************************************************/
491 /**********************************************************************/
493 void gl_init_lists( void )
495 static int init_flag
= 0;
498 InstSize
[OPCODE_ACCUM
] = 3;
499 InstSize
[OPCODE_ALPHA_FUNC
] = 3;
500 InstSize
[OPCODE_BIND_TEXTURE
] = 3;
501 InstSize
[OPCODE_BITMAP
] = 8;
502 InstSize
[OPCODE_BLEND_COLOR
] = 5;
503 InstSize
[OPCODE_BLEND_EQUATION
] = 2;
504 InstSize
[OPCODE_BLEND_FUNC
] = 3;
505 InstSize
[OPCODE_BLEND_FUNC_SEPARATE
] = 5;
506 InstSize
[OPCODE_CALL_LIST
] = 2;
507 InstSize
[OPCODE_CALL_LIST_OFFSET
] = 2;
508 InstSize
[OPCODE_CLEAR
] = 2;
509 InstSize
[OPCODE_CLEAR_ACCUM
] = 5;
510 InstSize
[OPCODE_CLEAR_COLOR
] = 5;
511 InstSize
[OPCODE_CLEAR_DEPTH
] = 2;
512 InstSize
[OPCODE_CLEAR_INDEX
] = 2;
513 InstSize
[OPCODE_CLEAR_STENCIL
] = 2;
514 InstSize
[OPCODE_CLIP_PLANE
] = 6;
515 InstSize
[OPCODE_COLOR_MASK
] = 5;
516 InstSize
[OPCODE_COLOR_MATERIAL
] = 3;
517 InstSize
[OPCODE_COLOR_TABLE
] = 4;
518 InstSize
[OPCODE_COLOR_SUB_TABLE
] = 4;
519 InstSize
[OPCODE_COPY_PIXELS
] = 6;
520 InstSize
[OPCODE_COPY_TEX_IMAGE1D
] = 8;
521 InstSize
[OPCODE_COPY_TEX_IMAGE2D
] = 9;
522 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE1D
] = 7;
523 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE2D
] = 9;
524 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE3D
] = 10;
525 InstSize
[OPCODE_CULL_FACE
] = 2;
526 InstSize
[OPCODE_DEPTH_FUNC
] = 2;
527 InstSize
[OPCODE_DEPTH_MASK
] = 2;
528 InstSize
[OPCODE_DEPTH_RANGE
] = 3;
529 InstSize
[OPCODE_DISABLE
] = 2;
530 InstSize
[OPCODE_DRAW_BUFFER
] = 2;
531 InstSize
[OPCODE_DRAW_PIXELS
] = 2;
532 InstSize
[OPCODE_ENABLE
] = 2;
533 InstSize
[OPCODE_EVALCOORD1
] = 2;
534 InstSize
[OPCODE_EVALCOORD2
] = 3;
535 InstSize
[OPCODE_EVALMESH1
] = 4;
536 InstSize
[OPCODE_EVALMESH2
] = 6;
537 InstSize
[OPCODE_EVALPOINT1
] = 2;
538 InstSize
[OPCODE_EVALPOINT2
] = 3;
539 InstSize
[OPCODE_FOG
] = 6;
540 InstSize
[OPCODE_FRONT_FACE
] = 2;
541 InstSize
[OPCODE_FRUSTUM
] = 7;
542 InstSize
[OPCODE_HINT
] = 3;
543 InstSize
[OPCODE_INDEX_MASK
] = 2;
544 InstSize
[OPCODE_INIT_NAMES
] = 1;
545 InstSize
[OPCODE_LIGHT
] = 7;
546 InstSize
[OPCODE_LIGHT_MODEL
] = 6;
547 InstSize
[OPCODE_LINE_STIPPLE
] = 3;
548 InstSize
[OPCODE_LINE_WIDTH
] = 2;
549 InstSize
[OPCODE_LIST_BASE
] = 2;
550 InstSize
[OPCODE_LOAD_IDENTITY
] = 1;
551 InstSize
[OPCODE_LOAD_MATRIX
] = 17;
552 InstSize
[OPCODE_LOAD_NAME
] = 2;
553 InstSize
[OPCODE_LOGIC_OP
] = 2;
554 InstSize
[OPCODE_MAP1
] = 7;
555 InstSize
[OPCODE_MAP2
] = 11;
556 InstSize
[OPCODE_MAPGRID1
] = 4;
557 InstSize
[OPCODE_MAPGRID2
] = 7;
558 InstSize
[OPCODE_MATRIX_MODE
] = 2;
559 InstSize
[OPCODE_MULT_MATRIX
] = 17;
560 InstSize
[OPCODE_ORTHO
] = 7;
561 InstSize
[OPCODE_PASSTHROUGH
] = 2;
562 InstSize
[OPCODE_PIXEL_MAP
] = 4;
563 InstSize
[OPCODE_PIXEL_TRANSFER
] = 3;
564 InstSize
[OPCODE_PIXEL_ZOOM
] = 3;
565 InstSize
[OPCODE_POINT_SIZE
] = 2;
566 InstSize
[OPCODE_POINT_PARAMETERS
] = 5;
567 InstSize
[OPCODE_POLYGON_MODE
] = 3;
568 InstSize
[OPCODE_POLYGON_STIPPLE
] = 2;
569 InstSize
[OPCODE_POLYGON_OFFSET
] = 3;
570 InstSize
[OPCODE_POP_ATTRIB
] = 1;
571 InstSize
[OPCODE_POP_MATRIX
] = 1;
572 InstSize
[OPCODE_POP_NAME
] = 1;
573 InstSize
[OPCODE_PRIORITIZE_TEXTURE
] = 3;
574 InstSize
[OPCODE_PUSH_ATTRIB
] = 2;
575 InstSize
[OPCODE_PUSH_MATRIX
] = 1;
576 InstSize
[OPCODE_PUSH_NAME
] = 2;
577 InstSize
[OPCODE_RASTER_POS
] = 5;
578 InstSize
[OPCODE_RECTF
] = 5;
579 InstSize
[OPCODE_READ_BUFFER
] = 2;
580 InstSize
[OPCODE_SCALE
] = 4;
581 InstSize
[OPCODE_SCISSOR
] = 5;
582 InstSize
[OPCODE_STENCIL_FUNC
] = 4;
583 InstSize
[OPCODE_STENCIL_MASK
] = 2;
584 InstSize
[OPCODE_STENCIL_OP
] = 4;
585 InstSize
[OPCODE_SHADE_MODEL
] = 2;
586 InstSize
[OPCODE_TEXENV
] = 7;
587 InstSize
[OPCODE_TEXGEN
] = 7;
588 InstSize
[OPCODE_TEXPARAMETER
] = 7;
589 InstSize
[OPCODE_TEX_IMAGE1D
] = 9;
590 InstSize
[OPCODE_TEX_IMAGE2D
] = 10;
591 InstSize
[OPCODE_TEX_IMAGE3D
] = 11;
592 InstSize
[OPCODE_TEX_SUB_IMAGE1D
] = 8;
593 InstSize
[OPCODE_TEX_SUB_IMAGE2D
] = 10;
594 InstSize
[OPCODE_TEX_SUB_IMAGE3D
] = 12;
595 InstSize
[OPCODE_TRANSLATE
] = 4;
596 InstSize
[OPCODE_VIEWPORT
] = 5;
597 InstSize
[OPCODE_WINDOW_POS
] = 5;
598 InstSize
[OPCODE_CONTINUE
] = 2;
599 InstSize
[OPCODE_ERROR
] = 3;
600 InstSize
[OPCODE_VERTEX_CASSETTE
] = 9;
601 InstSize
[OPCODE_END_OF_LIST
] = 1;
602 /* GL_ARB_multitexture */
603 InstSize
[OPCODE_ACTIVE_TEXTURE
] = 2;
604 InstSize
[OPCODE_CLIENT_ACTIVE_TEXTURE
] = 2;
611 * Display List compilation functions
616 static void save_Accum( GLcontext
*ctx
, GLenum op
, GLfloat value
)
619 FLUSH_VB(ctx
, "dlist");
620 n
= alloc_instruction( ctx
, OPCODE_ACCUM
, 2 );
625 if (ctx
->ExecuteFlag
) {
626 (*ctx
->Exec
.Accum
)( ctx
, op
, value
);
631 static void save_AlphaFunc( GLcontext
*ctx
, GLenum func
, GLclampf ref
)
634 FLUSH_VB(ctx
, "dlist");
635 n
= alloc_instruction( ctx
, OPCODE_ALPHA_FUNC
, 2 );
638 n
[2].f
= (GLfloat
) ref
;
640 if (ctx
->ExecuteFlag
) {
641 (*ctx
->Exec
.AlphaFunc
)( ctx
, func
, ref
);
645 static void save_BindTexture( GLcontext
*ctx
, GLenum target
, GLuint texture
)
648 FLUSH_VB(ctx
, "dlist");
649 n
= alloc_instruction( ctx
, OPCODE_BIND_TEXTURE
, 2 );
654 if (ctx
->ExecuteFlag
) {
655 (*ctx
->Exec
.BindTexture
)( ctx
, target
, texture
);
660 static void save_Bitmap( GLcontext
*ctx
,
661 GLsizei width
, GLsizei height
,
662 GLfloat xorig
, GLfloat yorig
,
663 GLfloat xmove
, GLfloat ymove
,
664 const GLubyte
*bitmap
,
665 const struct gl_pixelstore_attrib
*packing
)
668 FLUSH_VB(ctx
, "dlist");
669 n
= alloc_instruction( ctx
, OPCODE_BITMAP
, 7 );
671 struct gl_image
*image
= gl_unpack_bitmap( ctx
, width
, height
,
676 n
[1].i
= (GLint
) width
;
677 n
[2].i
= (GLint
) height
;
682 n
[7].data
= (void *) image
;
684 if (ctx
->ExecuteFlag
) {
685 (*ctx
->Exec
.Bitmap
)( ctx
, width
, height
,
686 xorig
, yorig
, xmove
, ymove
, bitmap
, packing
);
691 static void save_BlendEquation( GLcontext
*ctx
, GLenum mode
)
694 FLUSH_VB(ctx
, "dlist");
695 n
= alloc_instruction( ctx
, OPCODE_BLEND_EQUATION
, 1 );
699 if (ctx
->ExecuteFlag
) {
700 (*ctx
->Exec
.BlendEquation
)( ctx
, mode
);
705 static void save_BlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
708 FLUSH_VB(ctx
, "dlist");
709 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC
, 2 );
714 if (ctx
->ExecuteFlag
) {
715 (*ctx
->Exec
.BlendFunc
)( ctx
, sfactor
, dfactor
);
720 static void save_BlendFuncSeparate( GLcontext
*ctx
,
721 GLenum sfactorRGB
, GLenum dfactorRGB
,
722 GLenum sfactorA
, GLenum dfactorA
)
725 FLUSH_VB(ctx
, "dlist");
726 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC_SEPARATE
, 4 );
733 if (ctx
->ExecuteFlag
) {
734 (*ctx
->Exec
.BlendFuncSeparate
)( ctx
, sfactorRGB
, dfactorRGB
,
740 static void save_BlendColor( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
741 GLfloat blue
, GLfloat alpha
)
744 FLUSH_VB(ctx
, "dlist");
745 n
= alloc_instruction( ctx
, OPCODE_BLEND_COLOR
, 4 );
752 if (ctx
->ExecuteFlag
) {
753 (*ctx
->Exec
.BlendColor
)( ctx
, red
, green
, blue
, alpha
);
758 static void save_CallList( GLcontext
*ctx
, GLuint list
)
761 FLUSH_VB(ctx
, "dlist");
762 n
= alloc_instruction( ctx
, OPCODE_CALL_LIST
, 1 );
766 if (ctx
->ExecuteFlag
) {
767 (*ctx
->Exec
.CallList
)( ctx
, list
);
772 static void save_CallLists( GLcontext
*ctx
,
773 GLsizei n
, GLenum type
, const GLvoid
*lists
)
776 FLUSH_VB(ctx
, "dlist");
779 GLuint list
= translate_id( i
, type
, lists
);
780 Node
*n
= alloc_instruction( ctx
, OPCODE_CALL_LIST_OFFSET
, 1 );
785 if (ctx
->ExecuteFlag
) {
786 (*ctx
->Exec
.CallLists
)( ctx
, n
, type
, lists
);
791 static void save_Clear( GLcontext
*ctx
, GLbitfield mask
)
794 FLUSH_VB(ctx
, "dlist");
795 n
= alloc_instruction( ctx
, OPCODE_CLEAR
, 1 );
799 if (ctx
->ExecuteFlag
) {
800 (*ctx
->Exec
.Clear
)( ctx
, mask
);
805 static void save_ClearAccum( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
806 GLfloat blue
, GLfloat alpha
)
809 FLUSH_VB(ctx
, "dlist");
810 n
= alloc_instruction( ctx
, OPCODE_CLEAR_ACCUM
, 4 );
817 if (ctx
->ExecuteFlag
) {
818 (*ctx
->Exec
.ClearAccum
)( ctx
, red
, green
, blue
, alpha
);
823 static void save_ClearColor( GLcontext
*ctx
, GLclampf red
, GLclampf green
,
824 GLclampf blue
, GLclampf alpha
)
827 FLUSH_VB(ctx
, "dlist");
828 n
= alloc_instruction( ctx
, OPCODE_CLEAR_COLOR
, 4 );
835 if (ctx
->ExecuteFlag
) {
836 (*ctx
->Exec
.ClearColor
)( ctx
, red
, green
, blue
, alpha
);
841 static void save_ClearDepth( GLcontext
*ctx
, GLclampd depth
)
844 FLUSH_VB(ctx
, "dlist");
845 n
= alloc_instruction( ctx
, OPCODE_CLEAR_DEPTH
, 1 );
847 n
[1].f
= (GLfloat
) depth
;
849 if (ctx
->ExecuteFlag
) {
850 (*ctx
->Exec
.ClearDepth
)( ctx
, depth
);
855 static void save_ClearIndex( GLcontext
*ctx
, GLfloat c
)
858 FLUSH_VB(ctx
, "dlist");
859 n
= alloc_instruction( ctx
, OPCODE_CLEAR_INDEX
, 1 );
863 if (ctx
->ExecuteFlag
) {
864 (*ctx
->Exec
.ClearIndex
)( ctx
, c
);
869 static void save_ClearStencil( GLcontext
*ctx
, GLint s
)
872 FLUSH_VB(ctx
, "dlist");
873 n
= alloc_instruction( ctx
, OPCODE_CLEAR_STENCIL
, 1 );
877 if (ctx
->ExecuteFlag
) {
878 (*ctx
->Exec
.ClearStencil
)( ctx
, s
);
883 static void save_ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*equ
)
886 FLUSH_VB(ctx
, "dlist");
887 n
= alloc_instruction( ctx
, OPCODE_CLIP_PLANE
, 5 );
895 if (ctx
->ExecuteFlag
) {
896 (*ctx
->Exec
.ClipPlane
)( ctx
, plane
, equ
);
902 static void save_ColorMask( GLcontext
*ctx
, GLboolean red
, GLboolean green
,
903 GLboolean blue
, GLboolean alpha
)
906 FLUSH_VB(ctx
, "dlist");
907 n
= alloc_instruction( ctx
, OPCODE_COLOR_MASK
, 4 );
914 if (ctx
->ExecuteFlag
) {
915 (*ctx
->Exec
.ColorMask
)( ctx
, red
, green
, blue
, alpha
);
920 static void save_ColorMaterial( GLcontext
*ctx
, GLenum face
, GLenum mode
)
923 FLUSH_VB(ctx
, "dlist");
924 n
= alloc_instruction( ctx
, OPCODE_COLOR_MATERIAL
, 2 );
929 if (ctx
->ExecuteFlag
) {
930 (*ctx
->Exec
.ColorMaterial
)( ctx
, face
, mode
);
935 static void save_ColorTable( GLcontext
*ctx
, GLenum target
, GLenum internalFormat
,
936 struct gl_image
*table
)
939 FLUSH_VB(ctx
, "dlist");
940 n
= alloc_instruction( ctx
, OPCODE_COLOR_TABLE
, 3 );
943 n
[2].e
= internalFormat
;
944 n
[3].data
= (GLvoid
*) table
;
946 /* must retain this image */
950 if (ctx
->ExecuteFlag
) {
951 (*ctx
->Exec
.ColorTable
)( ctx
, target
, internalFormat
, table
);
956 static void save_ColorSubTable( GLcontext
*ctx
, GLenum target
,
957 GLsizei start
, struct gl_image
*data
)
960 FLUSH_VB(ctx
, "dlist");
961 n
= alloc_instruction( ctx
, OPCODE_COLOR_SUB_TABLE
, 3 );
965 n
[3].data
= (GLvoid
*) data
;
967 /* must retain this image */
971 if (ctx
->ExecuteFlag
) {
972 (*ctx
->Exec
.ColorSubTable
)( ctx
, target
, start
, data
);
978 static void save_CopyPixels( GLcontext
*ctx
, GLint x
, GLint y
,
979 GLsizei width
, GLsizei height
, GLenum type
)
982 FLUSH_VB(ctx
, "dlist");
983 n
= alloc_instruction( ctx
, OPCODE_COPY_PIXELS
, 5 );
987 n
[3].i
= (GLint
) width
;
988 n
[4].i
= (GLint
) height
;
991 if (ctx
->ExecuteFlag
) {
992 (*ctx
->Exec
.CopyPixels
)( ctx
, x
, y
, width
, height
, type
);
998 static void save_CopyTexImage1D( GLcontext
*ctx
,
999 GLenum target
, GLint level
,
1000 GLenum internalformat
,
1001 GLint x
, GLint y
, GLsizei width
,
1005 FLUSH_VB(ctx
, "dlist");
1006 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE1D
, 7 );
1010 n
[3].e
= internalformat
;
1016 if (ctx
->ExecuteFlag
) {
1017 (*ctx
->Exec
.CopyTexImage1D
)( ctx
, target
, level
, internalformat
,
1018 x
, y
, width
, border
);
1023 static void save_CopyTexImage2D( GLcontext
*ctx
,
1024 GLenum target
, GLint level
,
1025 GLenum internalformat
,
1026 GLint x
, GLint y
, GLsizei width
,
1027 GLsizei height
, GLint border
)
1030 FLUSH_VB(ctx
, "dlist");
1031 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE2D
, 8 );
1035 n
[3].e
= internalformat
;
1042 if (ctx
->ExecuteFlag
) {
1043 (*ctx
->Exec
.CopyTexImage2D
)( ctx
, target
, level
, internalformat
,
1044 x
, y
, width
, height
, border
);
1050 static void save_CopyTexSubImage1D( GLcontext
*ctx
,
1051 GLenum target
, GLint level
,
1052 GLint xoffset
, GLint x
, GLint y
,
1056 FLUSH_VB(ctx
, "dlist");
1057 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE1D
, 6 );
1066 if (ctx
->ExecuteFlag
) {
1067 (*ctx
->Exec
.CopyTexSubImage1D
)( ctx
, target
, level
, xoffset
, x
, y
, width
);
1072 static void save_CopyTexSubImage2D( GLcontext
*ctx
,
1073 GLenum target
, GLint level
,
1074 GLint xoffset
, GLint yoffset
,
1076 GLsizei width
, GLint height
)
1079 FLUSH_VB(ctx
, "dlist");
1080 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE2D
, 8 );
1091 if (ctx
->ExecuteFlag
) {
1092 (*ctx
->Exec
.CopyTexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
1093 x
, y
, width
, height
);
1098 static void save_CopyTexSubImage3D( GLcontext
*ctx
,
1099 GLenum target
, GLint level
,
1100 GLint xoffset
, GLint yoffset
,
1103 GLsizei width
, GLint height
)
1106 FLUSH_VB(ctx
, "dlist");
1107 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE3D
, 9 );
1119 if (ctx
->ExecuteFlag
) {
1120 (*ctx
->Exec
.CopyTexSubImage3D
)(ctx
, target
, level
, xoffset
, yoffset
,
1121 zoffset
, x
, y
, width
, height
);
1126 static void save_CullFace( GLcontext
*ctx
, GLenum mode
)
1129 FLUSH_VB(ctx
, "dlist");
1130 n
= alloc_instruction( ctx
, OPCODE_CULL_FACE
, 1 );
1134 if (ctx
->ExecuteFlag
) {
1135 (*ctx
->Exec
.CullFace
)( ctx
, mode
);
1140 static void save_DepthFunc( GLcontext
*ctx
, GLenum func
)
1143 FLUSH_VB(ctx
, "dlist");
1144 n
= alloc_instruction( ctx
, OPCODE_DEPTH_FUNC
, 1 );
1148 if (ctx
->ExecuteFlag
) {
1149 (*ctx
->Exec
.DepthFunc
)( ctx
, func
);
1154 static void save_DepthMask( GLcontext
*ctx
, GLboolean mask
)
1157 FLUSH_VB(ctx
, "dlist");
1158 n
= alloc_instruction( ctx
, OPCODE_DEPTH_MASK
, 1 );
1162 if (ctx
->ExecuteFlag
) {
1163 (*ctx
->Exec
.DepthMask
)( ctx
, mask
);
1168 static void save_DepthRange( GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
)
1171 FLUSH_VB(ctx
, "dlist");
1172 n
= alloc_instruction( ctx
, OPCODE_DEPTH_RANGE
, 2 );
1174 n
[1].f
= (GLfloat
) nearval
;
1175 n
[2].f
= (GLfloat
) farval
;
1177 if (ctx
->ExecuteFlag
) {
1178 (*ctx
->Exec
.DepthRange
)( ctx
, nearval
, farval
);
1183 static void save_Disable( GLcontext
*ctx
, GLenum cap
)
1186 FLUSH_VB(ctx
, "dlist");
1187 n
= alloc_instruction( ctx
, OPCODE_DISABLE
, 1 );
1191 if (ctx
->ExecuteFlag
) {
1192 (*ctx
->Exec
.Disable
)( ctx
, cap
);
1197 static void save_DrawBuffer( GLcontext
*ctx
, GLenum mode
)
1200 FLUSH_VB(ctx
, "dlist");
1201 n
= alloc_instruction( ctx
, OPCODE_DRAW_BUFFER
, 1 );
1205 if (ctx
->ExecuteFlag
) {
1206 (*ctx
->Exec
.DrawBuffer
)( ctx
, mode
);
1211 static void save_DrawPixels( GLcontext
*ctx
, struct gl_image
*image
)
1214 FLUSH_VB(ctx
, "dlist");
1215 n
= alloc_instruction( ctx
, OPCODE_DRAW_PIXELS
, 1 );
1217 n
[1].data
= (GLvoid
*) image
;
1220 image
->RefCount
= 1;
1222 if (ctx
->ExecuteFlag
) {
1223 (*ctx
->Exec
.DrawPixels
)( ctx
, image
);
1229 static void save_Enable( GLcontext
*ctx
, GLenum cap
)
1232 FLUSH_VB(ctx
, "dlist");
1233 n
= alloc_instruction( ctx
, OPCODE_ENABLE
, 1 );
1237 if (ctx
->ExecuteFlag
) {
1238 (*ctx
->Exec
.Enable
)( ctx
, cap
);
1244 static void save_EvalMesh1( GLcontext
*ctx
,
1245 GLenum mode
, GLint i1
, GLint i2
)
1248 FLUSH_VB(ctx
, "dlist");
1249 n
= alloc_instruction( ctx
, OPCODE_EVALMESH1
, 3 );
1255 if (ctx
->ExecuteFlag
) {
1256 (*ctx
->Exec
.EvalMesh1
)( ctx
, mode
, i1
, i2
);
1261 static void save_EvalMesh2( GLcontext
*ctx
,
1262 GLenum mode
, GLint i1
, GLint i2
, GLint j1
, GLint j2
)
1265 FLUSH_VB(ctx
, "dlist");
1266 n
= alloc_instruction( ctx
, OPCODE_EVALMESH2
, 5 );
1274 if (ctx
->ExecuteFlag
) {
1275 (*ctx
->Exec
.EvalMesh2
)( ctx
, mode
, i1
, i2
, j1
, j2
);
1282 static void save_Fogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
)
1285 FLUSH_VB(ctx
, "dlist");
1286 n
= alloc_instruction( ctx
, OPCODE_FOG
, 5 );
1294 if (ctx
->ExecuteFlag
) {
1295 (*ctx
->Exec
.Fogfv
)( ctx
, pname
, params
);
1300 static void save_FrontFace( GLcontext
*ctx
, GLenum mode
)
1303 FLUSH_VB(ctx
, "dlist");
1304 n
= alloc_instruction( ctx
, OPCODE_FRONT_FACE
, 1 );
1308 if (ctx
->ExecuteFlag
) {
1309 (*ctx
->Exec
.FrontFace
)( ctx
, mode
);
1314 static void save_Frustum( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1315 GLdouble bottom
, GLdouble top
,
1316 GLdouble nearval
, GLdouble farval
)
1319 FLUSH_VB(ctx
, "dlist");
1320 n
= alloc_instruction( ctx
, OPCODE_FRUSTUM
, 6 );
1329 if (ctx
->ExecuteFlag
) {
1330 (*ctx
->Exec
.Frustum
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1335 static GLboolean
save_Hint( GLcontext
*ctx
, GLenum target
, GLenum mode
)
1338 FLUSH_VB(ctx
, "dlist");
1339 n
= alloc_instruction( ctx
, OPCODE_HINT
, 2 );
1344 if (ctx
->ExecuteFlag
) {
1345 return (*ctx
->Exec
.Hint
)( ctx
, target
, mode
);
1347 return GL_TRUE
; /* not queried */
1352 static void save_IndexMask( GLcontext
*ctx
, GLuint mask
)
1355 FLUSH_VB(ctx
, "dlist");
1356 n
= alloc_instruction( ctx
, OPCODE_INDEX_MASK
, 1 );
1360 if (ctx
->ExecuteFlag
) {
1361 (*ctx
->Exec
.IndexMask
)( ctx
, mask
);
1366 static void save_InitNames( GLcontext
*ctx
)
1368 FLUSH_VB(ctx
, "dlist");
1369 (void) alloc_instruction( ctx
, OPCODE_INIT_NAMES
, 0 );
1370 if (ctx
->ExecuteFlag
) {
1371 (*ctx
->Exec
.InitNames
)( ctx
);
1376 static void save_Lightfv( GLcontext
*ctx
, GLenum light
, GLenum pname
,
1377 const GLfloat
*params
, GLint numparams
)
1380 FLUSH_VB(ctx
, "dlist");
1381 n
= alloc_instruction( ctx
, OPCODE_LIGHT
, 6 );
1386 for (i
=0;i
<numparams
;i
++) {
1387 n
[3+i
].f
= params
[i
];
1390 if (ctx
->ExecuteFlag
) {
1391 (*ctx
->Exec
.Lightfv
)( ctx
, light
, pname
, params
, numparams
);
1396 static void save_LightModelfv( GLcontext
*ctx
,
1397 GLenum pname
, const GLfloat
*params
)
1400 FLUSH_VB(ctx
, "dlist");
1401 n
= alloc_instruction( ctx
, OPCODE_LIGHT_MODEL
, 5 );
1409 if (ctx
->ExecuteFlag
) {
1410 (*ctx
->Exec
.LightModelfv
)( ctx
, pname
, params
);
1415 static void save_LineStipple( GLcontext
*ctx
, GLint factor
, GLushort pattern
)
1418 FLUSH_VB(ctx
, "dlist");
1419 n
= alloc_instruction( ctx
, OPCODE_LINE_STIPPLE
, 2 );
1424 if (ctx
->ExecuteFlag
) {
1425 (*ctx
->Exec
.LineStipple
)( ctx
, factor
, pattern
);
1430 static void save_LineWidth( GLcontext
*ctx
, GLfloat width
)
1433 FLUSH_VB(ctx
, "dlist");
1434 n
= alloc_instruction( ctx
, OPCODE_LINE_WIDTH
, 1 );
1438 if (ctx
->ExecuteFlag
) {
1439 (*ctx
->Exec
.LineWidth
)( ctx
, width
);
1444 static void save_ListBase( GLcontext
*ctx
, GLuint base
)
1447 FLUSH_VB(ctx
, "dlist");
1448 n
= alloc_instruction( ctx
, OPCODE_LIST_BASE
, 1 );
1452 if (ctx
->ExecuteFlag
) {
1453 (*ctx
->Exec
.ListBase
)( ctx
, base
);
1458 static void save_LoadIdentity( GLcontext
*ctx
)
1460 FLUSH_VB(ctx
, "dlist");
1461 (void) alloc_instruction( ctx
, OPCODE_LOAD_IDENTITY
, 0 );
1462 if (ctx
->ExecuteFlag
) {
1463 (*ctx
->Exec
.LoadIdentity
)( ctx
);
1468 static void save_LoadMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1471 FLUSH_VB(ctx
, "dlist");
1472 n
= alloc_instruction( ctx
, OPCODE_LOAD_MATRIX
, 16 );
1475 for (i
=0;i
<16;i
++) {
1479 if (ctx
->ExecuteFlag
) {
1480 (*ctx
->Exec
.LoadMatrixf
)( ctx
, m
);
1485 static void save_LoadName( GLcontext
*ctx
, GLuint name
)
1488 FLUSH_VB(ctx
, "dlist");
1489 n
= alloc_instruction( ctx
, OPCODE_LOAD_NAME
, 1 );
1493 if (ctx
->ExecuteFlag
) {
1494 (*ctx
->Exec
.LoadName
)( ctx
, name
);
1499 static void save_LogicOp( GLcontext
*ctx
, GLenum opcode
)
1502 FLUSH_VB(ctx
, "dlist");
1503 n
= alloc_instruction( ctx
, OPCODE_LOGIC_OP
, 1 );
1507 if (ctx
->ExecuteFlag
) {
1508 (*ctx
->Exec
.LogicOp
)( ctx
, opcode
);
1513 static void save_Map1f( GLcontext
*ctx
,
1514 GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
1515 GLint order
, const GLfloat
*points
, GLboolean retain
)
1518 FLUSH_VB(ctx
, "dlist");
1519 n
= alloc_instruction( ctx
, OPCODE_MAP1
, 6 );
1526 n
[6].data
= (void *) points
;
1528 if (ctx
->ExecuteFlag
) {
1529 (*ctx
->Exec
.Map1f
)( ctx
, target
, u1
, u2
, stride
, order
, points
, GL_TRUE
);
1535 static void save_Map2f( GLcontext
*ctx
, GLenum target
,
1536 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
1537 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
1538 const GLfloat
*points
, GLboolean retain
)
1541 FLUSH_VB(ctx
, "dlist");
1542 n
= alloc_instruction( ctx
, OPCODE_MAP2
, 10 );
1553 n
[10].data
= (void *) points
;
1555 if (ctx
->ExecuteFlag
) {
1556 (*ctx
->Exec
.Map2f
)( ctx
, target
,
1557 u1
, u2
, ustride
, uorder
,
1558 v1
, v2
, vstride
, vorder
, points
, GL_TRUE
);
1564 static void save_MapGrid1f( GLcontext
*ctx
, GLint un
, GLfloat u1
, GLfloat u2
)
1567 FLUSH_VB(ctx
, "dlist");
1568 n
= alloc_instruction( ctx
, OPCODE_MAPGRID1
, 3 );
1574 if (ctx
->ExecuteFlag
) {
1575 (*ctx
->Exec
.MapGrid1f
)( ctx
, un
, u1
, u2
);
1580 static void save_MapGrid2f( GLcontext
*ctx
,
1581 GLint un
, GLfloat u1
, GLfloat u2
,
1582 GLint vn
, GLfloat v1
, GLfloat v2
)
1585 FLUSH_VB(ctx
, "dlist");
1586 n
= alloc_instruction( ctx
, OPCODE_MAPGRID2
, 6 );
1595 if (ctx
->ExecuteFlag
) {
1596 (*ctx
->Exec
.MapGrid2f
)( ctx
, un
, u1
, u2
, vn
, v1
, v2
);
1601 static void save_MatrixMode( GLcontext
*ctx
, GLenum mode
)
1604 FLUSH_VB(ctx
, "dlist");
1605 n
= alloc_instruction( ctx
, OPCODE_MATRIX_MODE
, 1 );
1609 if (ctx
->ExecuteFlag
) {
1610 (*ctx
->Exec
.MatrixMode
)( ctx
, mode
);
1615 static void save_MultMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1618 FLUSH_VB(ctx
, "dlist");
1619 n
= alloc_instruction( ctx
, OPCODE_MULT_MATRIX
, 16 );
1622 for (i
=0;i
<16;i
++) {
1626 if (ctx
->ExecuteFlag
) {
1627 (*ctx
->Exec
.MultMatrixf
)( ctx
, m
);
1632 static void save_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
1634 /* It's an error to call this function while building a display list */
1635 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
1642 static void save_Ortho( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1643 GLdouble bottom
, GLdouble top
,
1644 GLdouble nearval
, GLdouble farval
)
1647 FLUSH_VB(ctx
, "dlist");
1648 n
= alloc_instruction( ctx
, OPCODE_ORTHO
, 6 );
1657 if (ctx
->ExecuteFlag
) {
1658 (*ctx
->Exec
.Ortho
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1663 static void save_PixelMapfv( GLcontext
*ctx
,
1664 GLenum map
, GLint mapsize
, const GLfloat
*values
)
1667 FLUSH_VB(ctx
, "dlist");
1668 n
= alloc_instruction( ctx
, OPCODE_PIXEL_MAP
, 3 );
1672 n
[3].data
= (void *) MALLOC( mapsize
* sizeof(GLfloat
) );
1673 MEMCPY( n
[3].data
, (void *) values
, mapsize
* sizeof(GLfloat
) );
1675 if (ctx
->ExecuteFlag
) {
1676 (*ctx
->Exec
.PixelMapfv
)( ctx
, map
, mapsize
, values
);
1681 static void save_PixelTransferf( GLcontext
*ctx
, GLenum pname
, GLfloat param
)
1684 FLUSH_VB(ctx
, "dlist");
1685 n
= alloc_instruction( ctx
, OPCODE_PIXEL_TRANSFER
, 2 );
1690 if (ctx
->ExecuteFlag
) {
1691 (*ctx
->Exec
.PixelTransferf
)( ctx
, pname
, param
);
1696 static void save_PixelZoom( GLcontext
*ctx
, GLfloat xfactor
, GLfloat yfactor
)
1699 FLUSH_VB(ctx
, "dlist");
1700 n
= alloc_instruction( ctx
, OPCODE_PIXEL_ZOOM
, 2 );
1705 if (ctx
->ExecuteFlag
) {
1706 (*ctx
->Exec
.PixelZoom
)( ctx
, xfactor
, yfactor
);
1711 static void save_PointParameterfvEXT( GLcontext
*ctx
, GLenum pname
,
1712 const GLfloat
*params
)
1715 FLUSH_VB(ctx
, "dlist");
1716 n
= alloc_instruction( ctx
, OPCODE_POINT_PARAMETERS
, 4 );
1723 if (ctx
->ExecuteFlag
) {
1724 (*ctx
->Exec
.PointParameterfvEXT
)( ctx
, pname
, params
);
1729 static void save_PointSize( GLcontext
*ctx
, GLfloat size
)
1732 FLUSH_VB(ctx
, "dlist");
1733 n
= alloc_instruction( ctx
, OPCODE_POINT_SIZE
, 1 );
1737 if (ctx
->ExecuteFlag
) {
1738 (*ctx
->Exec
.PointSize
)( ctx
, size
);
1743 static void save_PolygonMode( GLcontext
*ctx
, GLenum face
, GLenum mode
)
1746 FLUSH_VB(ctx
, "dlist");
1747 n
= alloc_instruction( ctx
, OPCODE_POLYGON_MODE
, 2 );
1752 if (ctx
->ExecuteFlag
) {
1753 (*ctx
->Exec
.PolygonMode
)( ctx
, face
, mode
);
1759 * Polygon stipple must have been upacked already!
1761 static void save_PolygonStipple( GLcontext
*ctx
, const GLuint
*pattern
)
1764 FLUSH_VB(ctx
, "dlist");
1765 n
= alloc_instruction( ctx
, OPCODE_POLYGON_STIPPLE
, 1 );
1768 n
[1].data
= MALLOC( 32 * 4 );
1769 data
= n
[1].data
; /* This needed for Acorn compiler */
1770 MEMCPY( data
, pattern
, 32 * 4 );
1772 if (ctx
->ExecuteFlag
) {
1773 (*ctx
->Exec
.PolygonStipple
)( ctx
, pattern
);
1778 static void save_PolygonOffset( GLcontext
*ctx
, GLfloat factor
, GLfloat units
)
1781 FLUSH_VB(ctx
, "dlist");
1782 n
= alloc_instruction( ctx
, OPCODE_POLYGON_OFFSET
, 2 );
1787 if (ctx
->ExecuteFlag
) {
1788 (*ctx
->Exec
.PolygonOffset
)( ctx
, factor
, units
);
1793 static void save_PopAttrib( GLcontext
*ctx
)
1795 FLUSH_VB(ctx
, "dlist");
1796 (void) alloc_instruction( ctx
, OPCODE_POP_ATTRIB
, 0 );
1797 if (ctx
->ExecuteFlag
) {
1798 (*ctx
->Exec
.PopAttrib
)( ctx
);
1803 static void save_PopMatrix( GLcontext
*ctx
)
1805 FLUSH_VB(ctx
, "dlist");
1806 (void) alloc_instruction( ctx
, OPCODE_POP_MATRIX
, 0 );
1807 if (ctx
->ExecuteFlag
) {
1808 (*ctx
->Exec
.PopMatrix
)( ctx
);
1813 static void save_PopName( GLcontext
*ctx
)
1815 FLUSH_VB(ctx
, "dlist");
1816 (void) alloc_instruction( ctx
, OPCODE_POP_NAME
, 0 );
1817 if (ctx
->ExecuteFlag
) {
1818 (*ctx
->Exec
.PopName
)( ctx
);
1823 static void save_PrioritizeTextures( GLcontext
*ctx
,
1824 GLsizei num
, const GLuint
*textures
,
1825 const GLclampf
*priorities
)
1828 FLUSH_VB(ctx
, "dlist");
1830 for (i
=0;i
<num
;i
++) {
1832 n
= alloc_instruction( ctx
, OPCODE_PRIORITIZE_TEXTURE
, 2 );
1834 n
[1].ui
= textures
[i
];
1835 n
[2].f
= priorities
[i
];
1838 if (ctx
->ExecuteFlag
) {
1839 (*ctx
->Exec
.PrioritizeTextures
)( ctx
, num
, textures
, priorities
);
1844 static void save_PushAttrib( GLcontext
*ctx
, GLbitfield mask
)
1847 FLUSH_VB(ctx
, "dlist");
1848 n
= alloc_instruction( ctx
, OPCODE_PUSH_ATTRIB
, 1 );
1852 if (ctx
->ExecuteFlag
) {
1853 (*ctx
->Exec
.PushAttrib
)( ctx
, mask
);
1858 static void save_PushMatrix( GLcontext
*ctx
)
1860 FLUSH_VB(ctx
, "dlist");
1861 (void) alloc_instruction( ctx
, OPCODE_PUSH_MATRIX
, 0 );
1862 if (ctx
->ExecuteFlag
) {
1863 (*ctx
->Exec
.PushMatrix
)( ctx
);
1868 static void save_PushName( GLcontext
*ctx
, GLuint name
)
1871 FLUSH_VB(ctx
, "dlist");
1872 n
= alloc_instruction( ctx
, OPCODE_PUSH_NAME
, 1 );
1876 if (ctx
->ExecuteFlag
) {
1877 (*ctx
->Exec
.PushName
)( ctx
, name
);
1882 static void save_RasterPos4f( GLcontext
*ctx
,
1883 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
1886 FLUSH_VB(ctx
, "dlist");
1887 n
= alloc_instruction( ctx
, OPCODE_RASTER_POS
, 4 );
1894 if (ctx
->ExecuteFlag
) {
1895 (*ctx
->Exec
.RasterPos4f
)( ctx
, x
, y
, z
, w
);
1900 static void save_PassThrough( GLcontext
*ctx
, GLfloat token
)
1903 FLUSH_VB(ctx
, "dlist");
1904 n
= alloc_instruction( ctx
, OPCODE_PASSTHROUGH
, 1 );
1908 if (ctx
->ExecuteFlag
) {
1909 (*ctx
->Exec
.PassThrough
)( ctx
, token
);
1914 static void save_ReadBuffer( GLcontext
*ctx
, GLenum mode
)
1917 FLUSH_VB(ctx
, "dlist");
1918 n
= alloc_instruction( ctx
, OPCODE_READ_BUFFER
, 1 );
1922 if (ctx
->ExecuteFlag
) {
1923 (*ctx
->Exec
.ReadBuffer
)( ctx
, mode
);
1928 static void save_Rectf( GLcontext
*ctx
,
1929 GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
1932 FLUSH_VB(ctx
, "dlist");
1933 n
= alloc_instruction( ctx
, OPCODE_RECTF
, 4 );
1940 if (ctx
->ExecuteFlag
) {
1941 (*ctx
->Exec
.Rectf
)( ctx
, x1
, y1
, x2
, y2
);
1946 static void save_Rotatef( GLcontext
*ctx
, GLfloat angle
,
1947 GLfloat x
, GLfloat y
, GLfloat z
)
1950 gl_rotation_matrix( angle
, x
, y
, z
, m
);
1951 save_MultMatrixf( ctx
, m
); /* save and maybe execute */
1955 static void save_Scalef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
1958 FLUSH_VB(ctx
, "dlist");
1959 n
= alloc_instruction( ctx
, OPCODE_SCALE
, 3 );
1965 if (ctx
->ExecuteFlag
) {
1966 (*ctx
->Exec
.Scalef
)( ctx
, x
, y
, z
);
1971 static void save_Scissor( GLcontext
*ctx
,
1972 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1975 FLUSH_VB(ctx
, "dlist");
1976 n
= alloc_instruction( ctx
, OPCODE_SCISSOR
, 4 );
1983 if (ctx
->ExecuteFlag
) {
1984 (*ctx
->Exec
.Scissor
)( ctx
, x
, y
, width
, height
);
1989 static void save_ShadeModel( GLcontext
*ctx
, GLenum mode
)
1992 FLUSH_VB(ctx
, "dlist");
1993 n
= alloc_instruction( ctx
, OPCODE_SHADE_MODEL
, 1 );
1997 if (ctx
->ExecuteFlag
) {
1998 (*ctx
->Exec
.ShadeModel
)( ctx
, mode
);
2003 static void save_StencilFunc( GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
)
2006 FLUSH_VB(ctx
, "dlist");
2007 n
= alloc_instruction( ctx
, OPCODE_STENCIL_FUNC
, 3 );
2013 if (ctx
->ExecuteFlag
) {
2014 (*ctx
->Exec
.StencilFunc
)( ctx
, func
, ref
, mask
);
2019 static void save_StencilMask( GLcontext
*ctx
, GLuint mask
)
2022 FLUSH_VB(ctx
, "dlist");
2023 n
= alloc_instruction( ctx
, OPCODE_STENCIL_MASK
, 1 );
2027 if (ctx
->ExecuteFlag
) {
2028 (*ctx
->Exec
.StencilMask
)( ctx
, mask
);
2033 static void save_StencilOp( GLcontext
*ctx
,
2034 GLenum fail
, GLenum zfail
, GLenum zpass
)
2037 FLUSH_VB(ctx
, "dlist");
2038 n
= alloc_instruction( ctx
, OPCODE_STENCIL_OP
, 3 );
2044 if (ctx
->ExecuteFlag
) {
2045 (*ctx
->Exec
.StencilOp
)( ctx
, fail
, zfail
, zpass
);
2052 static void save_TexEnvfv( GLcontext
*ctx
,
2053 GLenum target
, GLenum pname
, const GLfloat
*params
)
2056 FLUSH_VB(ctx
, "dlist");
2057 n
= alloc_instruction( ctx
, OPCODE_TEXENV
, 6 );
2066 if (ctx
->ExecuteFlag
) {
2067 (*ctx
->Exec
.TexEnvfv
)( ctx
, target
, pname
, params
);
2072 static void save_TexGenfv( GLcontext
*ctx
,
2073 GLenum coord
, GLenum pname
, const GLfloat
*params
)
2076 FLUSH_VB(ctx
, "dlist");
2077 n
= alloc_instruction( ctx
, OPCODE_TEXGEN
, 6 );
2086 if (ctx
->ExecuteFlag
) {
2087 (*ctx
->Exec
.TexGenfv
)( ctx
, coord
, pname
, params
);
2092 static void save_TexParameterfv( GLcontext
*ctx
, GLenum target
,
2093 GLenum pname
, const GLfloat
*params
)
2096 FLUSH_VB(ctx
, "dlist");
2097 n
= alloc_instruction( ctx
, OPCODE_TEXPARAMETER
, 6 );
2106 if (ctx
->ExecuteFlag
) {
2107 (*ctx
->Exec
.TexParameterfv
)( ctx
, target
, pname
, params
);
2112 static void save_TexImage1D( GLcontext
*ctx
, GLenum target
,
2113 GLint level
, GLint components
,
2114 GLsizei width
, GLint border
,
2115 GLenum format
, GLenum type
,
2116 const GLvoid
*pixels
)
2118 FLUSH_VB(ctx
, "dlist");
2119 if (target
== GL_PROXY_TEXTURE_1D
) {
2120 (*ctx
->Exec
.TexImage1D
)( ctx
, target
, level
, components
, width
,
2121 border
, format
, type
, pixels
);
2125 GLvoid
*image
= _mesa_unpack_image(width
, 1, 1, format
, type
,
2126 pixels
, &ctx
->Unpack
);
2127 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE1D
, 8 );
2131 n
[3].i
= components
;
2132 n
[4].i
= (GLint
) width
;
2141 if (ctx
->ExecuteFlag
) {
2142 (*ctx
->Exec
.TexImage1D
)( ctx
, target
, level
, components
, width
,
2143 border
, format
, type
, pixels
);
2149 static void save_TexImage2D( GLcontext
*ctx
, GLenum target
,
2150 GLint level
, GLint components
,
2151 GLsizei width
, GLsizei height
, GLint border
,
2152 GLenum format
, GLenum type
,
2153 const GLvoid
*pixels
)
2155 FLUSH_VB(ctx
, "dlist");
2156 if (target
== GL_PROXY_TEXTURE_2D
) {
2157 (*ctx
->Exec
.TexImage2D
)( ctx
, target
, level
, components
, width
,
2158 height
, border
, format
, type
, pixels
);
2162 GLvoid
*image
= _mesa_unpack_image(width
, height
, 1, format
, type
,
2163 pixels
, &ctx
->Unpack
);
2164 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE2D
, 9 );
2168 n
[3].i
= components
;
2169 n
[4].i
= (GLint
) width
;
2170 n
[5].i
= (GLint
) height
;
2179 if (ctx
->ExecuteFlag
) {
2180 (*ctx
->Exec
.TexImage2D
)( ctx
, target
, level
, components
, width
,
2181 height
, border
, format
, type
, pixels
);
2187 static void save_TexImage3D( GLcontext
*ctx
, GLenum target
,
2188 GLint level
, GLint components
,
2189 GLsizei width
, GLsizei height
, GLsizei depth
,
2191 GLenum format
, GLenum type
,
2192 const GLvoid
*pixels
)
2194 FLUSH_VB(ctx
, "dlist");
2195 if (target
== GL_PROXY_TEXTURE_3D
) {
2196 (*ctx
->Exec
.TexImage3D
)( ctx
, target
, level
, components
, width
,
2197 height
, depth
, border
, format
, type
, pixels
);
2200 GLvoid
*image
= _mesa_unpack_image(width
, height
, depth
, format
, type
,
2201 pixels
, &ctx
->Unpack
);
2203 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE3D
, 10 );
2207 n
[3].i
= components
;
2208 n
[4].i
= (GLint
) width
;
2209 n
[5].i
= (GLint
) height
;
2210 n
[6].i
= (GLint
) depth
;
2219 if (ctx
->ExecuteFlag
) {
2220 (*ctx
->Exec
.TexImage3D
)( ctx
, target
, level
, components
, width
,
2221 height
, depth
, border
, format
, type
, pixels
);
2227 static void save_TexSubImage1D( GLcontext
*ctx
,
2228 GLenum target
, GLint level
, GLint xoffset
,
2229 GLsizei width
, GLenum format
, GLenum type
,
2230 const GLvoid
*pixels
)
2233 GLvoid
*image
= _mesa_unpack_image(width
, 1, 1, format
, type
,
2234 pixels
, &ctx
->Unpack
);
2235 FLUSH_VB(ctx
, "dlist");
2236 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE1D
, 7 );
2241 n
[4].i
= (GLint
) width
;
2249 if (ctx
->ExecuteFlag
) {
2250 (*ctx
->Exec
.TexSubImage1D
)( ctx
, target
, level
, xoffset
, width
,
2251 format
, type
, pixels
);
2256 static void save_TexSubImage2D( GLcontext
*ctx
,
2257 GLenum target
, GLint level
,
2258 GLint xoffset
, GLint yoffset
,
2259 GLsizei width
, GLsizei height
,
2260 GLenum format
, GLenum type
,
2261 const GLvoid
*pixels
)
2264 GLvoid
*image
= _mesa_unpack_image(width
, height
, 1, format
, type
,
2265 pixels
, &ctx
->Unpack
);
2266 FLUSH_VB(ctx
, "dlist");
2267 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE2D
, 9 );
2273 n
[5].i
= (GLint
) width
;
2274 n
[6].i
= (GLint
) height
;
2282 if (ctx
->ExecuteFlag
) {
2283 (*ctx
->Exec
.TexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
2284 width
, height
, format
, type
, pixels
);
2289 static void save_TexSubImage3D( GLcontext
*ctx
,
2290 GLenum target
, GLint level
,
2291 GLint xoffset
, GLint yoffset
,GLint zoffset
,
2292 GLsizei width
, GLsizei height
, GLsizei depth
,
2293 GLenum format
, GLenum type
,
2294 const GLvoid
*pixels
)
2297 GLvoid
*image
= _mesa_unpack_image(width
, height
, depth
, format
, type
,
2298 pixels
, &ctx
->Unpack
);
2299 FLUSH_VB(ctx
, "dlist");
2300 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE3D
, 11 );
2307 n
[6].i
= (GLint
) width
;
2308 n
[7].i
= (GLint
) height
;
2309 n
[8].i
= (GLint
) depth
;
2317 if (ctx
->ExecuteFlag
) {
2318 (*ctx
->Exec
.TexSubImage3D
)(ctx
, target
, level
, xoffset
, yoffset
, zoffset
,
2319 width
, height
, depth
, format
, type
, pixels
);
2324 static void save_Translatef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
2327 FLUSH_VB(ctx
, "dlist");
2328 n
= alloc_instruction( ctx
, OPCODE_TRANSLATE
, 3 );
2334 if (ctx
->ExecuteFlag
) {
2335 (*ctx
->Exec
.Translatef
)( ctx
, x
, y
, z
);
2341 static void save_Viewport( GLcontext
*ctx
,
2342 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
2345 FLUSH_VB(ctx
, "dlist");
2346 n
= alloc_instruction( ctx
, OPCODE_VIEWPORT
, 4 );
2350 n
[3].i
= (GLint
) width
;
2351 n
[4].i
= (GLint
) height
;
2353 if (ctx
->ExecuteFlag
) {
2354 (*ctx
->Exec
.Viewport
)( ctx
, x
, y
, width
, height
);
2359 static void save_WindowPos4fMESA( GLcontext
*ctx
,
2360 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
2363 FLUSH_VB(ctx
, "dlist");
2364 n
= alloc_instruction( ctx
, OPCODE_WINDOW_POS
, 4 );
2371 if (ctx
->ExecuteFlag
) {
2372 (*ctx
->Exec
.WindowPos4fMESA
)( ctx
, x
, y
, z
, w
);
2381 /* GL_ARB_multitexture */
2382 static void save_ActiveTexture( GLcontext
*ctx
, GLenum target
)
2385 FLUSH_VB(ctx
, "dlist");
2386 n
= alloc_instruction( ctx
, OPCODE_ACTIVE_TEXTURE
, 1 );
2390 if (ctx
->ExecuteFlag
) {
2391 (*ctx
->Exec
.ActiveTexture
)( ctx
, target
);
2396 /* GL_ARB_multitexture */
2397 static void save_ClientActiveTexture( GLcontext
*ctx
, GLenum target
)
2400 FLUSH_VB(ctx
, "dlist");
2401 n
= alloc_instruction( ctx
, OPCODE_CLIENT_ACTIVE_TEXTURE
, 1 );
2405 if (ctx
->ExecuteFlag
) {
2406 (*ctx
->Exec
.ClientActiveTexture
)( ctx
, target
);
2412 void gl_compile_cassette( GLcontext
*ctx
)
2414 Node
*n
= alloc_instruction( ctx
, OPCODE_VERTEX_CASSETTE
, 8 );
2415 struct immediate
*im
= ctx
->input
;
2421 /* Do some easy optimizations of the cassette.
2424 if (0 && im
->v
.Obj
.size
< 4 && im
->Count
> 15) {
2425 im
->Bounds
= (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat
));
2426 (gl_calc_bound_tab
[im
->v
.Obj
.size
])( im
->Bounds
, &im
->v
.Obj
);
2430 n
[1].data
= (void *)im
;
2431 n
[2].ui
= im
->Start
;
2432 n
[3].ui
= im
->Count
;
2433 n
[4].ui
= im
->BeginState
;
2434 n
[5].ui
= im
->OrFlag
;
2435 n
[6].ui
= im
->AndFlag
;
2436 n
[7].ui
= im
->LastData
;
2437 n
[8].ui
= im
->LastPrimitive
;
2439 if (im
->Count
> VB_MAX
- 4) {
2441 struct immediate
*new_im
= gl_immediate_alloc(ctx
);
2442 if (!new_im
) return;
2443 SET_IMMEDIATE( ctx
, new_im
);
2444 gl_reset_input( ctx
);
2448 im
->Start
= im
->Count
; /* don't clear anything in reset_input */
2451 im
->Primitive
[im
->Start
] = ctx
->Current
.Primitive
;
2452 im
->LastPrimitive
= im
->Start
;
2453 im
->BeginState
= VERT_BEGIN_0
;
2458 fprintf(stderr
, "in compile_cassette, BeginState is %x\n",
2463 /* KW: Compile commands
2465 * Will appear in the list before the vertex buffer containing the
2466 * command that provoked the error. I don't see this as a problem.
2468 void gl_save_error( GLcontext
*ctx
, GLenum error
, const char *s
)
2471 n
= alloc_instruction( ctx
, OPCODE_ERROR
, 2 );
2474 n
[2].data
= (void *) s
;
2476 /* execute already done */
2479 /**********************************************************************/
2480 /* Display list execution */
2481 /**********************************************************************/
2485 * Execute a display list. Note that the ListBase offset must have already
2486 * been added before calling this function. I.e. the list argument is
2487 * the absolute list number, not relative to ListBase.
2488 * Input: list - display list number
2490 static void execute_list( GLcontext
*ctx
, GLuint list
)
2492 static struct gl_pixelstore_attrib defaultPacking
= {
2497 0, /* ImageHeight */
2499 GL_FALSE
, /* SwapBytes */
2500 GL_FALSE
/* LsbFirst */
2506 if (!gl_IsList(ctx
,list
))
2509 /* mesa_print_display_list( list ); */
2513 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
2517 opcode
= n
[0].opcode
;
2521 gl_error( ctx
, n
[1].e
, (const char *) n
[2].data
);
2523 case OPCODE_VERTEX_CASSETTE
: {
2524 struct immediate
*IM
;
2527 gl_update_state(ctx
);
2528 if (ctx
->CompileCVAFlag
) {
2529 ctx
->CompileCVAFlag
= 0;
2530 ctx
->CVA
.elt
.pipeline_valid
= 0;
2532 if (!ctx
->CVA
.elt
.pipeline_valid
)
2533 gl_build_immediate_pipeline( ctx
);
2536 IM
= (struct immediate
*) n
[1].data
;
2537 IM
->Start
= n
[2].ui
;
2538 IM
->Count
= n
[3].ui
;
2539 IM
->BeginState
= n
[4].ui
;
2540 IM
->OrFlag
= n
[5].ui
;
2541 IM
->AndFlag
= n
[6].ui
;
2542 IM
->LastData
= n
[7].ui
;
2543 IM
->LastPrimitive
= n
[8].ui
;
2545 if ((MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
) &&
2546 (MESA_VERBOSE
& VERBOSE_IMMEDIATE
))
2547 gl_print_cassette( (struct immediate
*) n
[1].data
, 0, ~0 );
2550 fprintf(stderr
, "Run cassette %d, rows %d..%d, beginstate %x\n",
2552 IM
->Start
, IM
->Count
, IM
->BeginState
);
2554 gl_fixup_cassette( ctx
, (struct immediate
*) n
[1].data
);
2555 gl_execute_cassette( ctx
, (struct immediate
*) n
[1].data
);
2559 gl_Accum( ctx
, n
[1].e
, n
[2].f
);
2561 case OPCODE_ALPHA_FUNC
:
2562 gl_AlphaFunc( ctx
, n
[1].e
, n
[2].f
);
2564 case OPCODE_BIND_TEXTURE
:
2565 gl_BindTexture( ctx
, n
[1].e
, n
[2].ui
);
2569 const struct gl_image
*image
= (struct gl_image
*) n
[7].data
;
2570 const GLubyte
*bitmap
= image
? image
->Data
: NULL
;
2571 gl_Bitmap( ctx
, (GLsizei
) n
[1].i
, (GLsizei
) n
[2].i
,
2572 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
,
2573 bitmap
, &defaultPacking
);
2576 case OPCODE_BLEND_COLOR
:
2577 gl_BlendColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2579 case OPCODE_BLEND_EQUATION
:
2580 gl_BlendEquation( ctx
, n
[1].e
);
2582 case OPCODE_BLEND_FUNC
:
2583 gl_BlendFunc( ctx
, n
[1].e
, n
[2].e
);
2585 case OPCODE_BLEND_FUNC_SEPARATE
:
2586 gl_BlendFuncSeparate( ctx
, n
[1].e
, n
[2].e
, n
[3].e
, n
[4].e
);
2588 case OPCODE_CALL_LIST
:
2589 /* Generated by glCallList(), don't add ListBase */
2590 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2591 execute_list( ctx
, n
[1].ui
);
2594 case OPCODE_CALL_LIST_OFFSET
:
2595 /* Generated by glCallLists() so we must add ListBase */
2596 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2597 execute_list( ctx
, ctx
->List
.ListBase
+ n
[1].ui
);
2601 gl_Clear( ctx
, n
[1].bf
);
2603 case OPCODE_CLEAR_COLOR
:
2604 gl_ClearColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2606 case OPCODE_CLEAR_ACCUM
:
2607 gl_ClearAccum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2609 case OPCODE_CLEAR_DEPTH
:
2610 gl_ClearDepth( ctx
, (GLclampd
) n
[1].f
);
2612 case OPCODE_CLEAR_INDEX
:
2613 gl_ClearIndex( ctx
, n
[1].ui
);
2615 case OPCODE_CLEAR_STENCIL
:
2616 gl_ClearStencil( ctx
, n
[1].i
);
2618 case OPCODE_CLIP_PLANE
:
2625 gl_ClipPlane( ctx
, n
[1].e
, equ
);
2628 case OPCODE_COLOR_MASK
:
2629 gl_ColorMask( ctx
, n
[1].b
, n
[2].b
, n
[3].b
, n
[4].b
);
2631 case OPCODE_COLOR_MATERIAL
:
2632 gl_ColorMaterial( ctx
, n
[1].e
, n
[2].e
);
2634 case OPCODE_COLOR_TABLE
:
2635 gl_ColorTable( ctx
, n
[1].e
, n
[2].e
, (struct gl_image
*) n
[3].data
);
2637 case OPCODE_COLOR_SUB_TABLE
:
2638 gl_ColorSubTable( ctx
, n
[1].e
, n
[2].i
,
2639 (struct gl_image
*) n
[3].data
);
2641 case OPCODE_COPY_PIXELS
:
2642 gl_CopyPixels( ctx
, n
[1].i
, n
[2].i
,
2643 (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
, n
[5].e
);
2645 case OPCODE_COPY_TEX_IMAGE1D
:
2646 gl_CopyTexImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2647 n
[5].i
, n
[6].i
, n
[7].i
);
2649 case OPCODE_COPY_TEX_IMAGE2D
:
2650 gl_CopyTexImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2651 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2653 case OPCODE_COPY_TEX_SUB_IMAGE1D
:
2654 gl_CopyTexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2657 case OPCODE_COPY_TEX_SUB_IMAGE2D
:
2658 gl_CopyTexSubImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2659 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2661 case OPCODE_COPY_TEX_SUB_IMAGE3D
:
2662 gl_CopyTexSubImage3D( 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
, n
[9].i
);
2665 case OPCODE_CULL_FACE
:
2666 gl_CullFace( ctx
, n
[1].e
);
2668 case OPCODE_DEPTH_FUNC
:
2669 gl_DepthFunc( ctx
, n
[1].e
);
2671 case OPCODE_DEPTH_MASK
:
2672 gl_DepthMask( ctx
, n
[1].b
);
2674 case OPCODE_DEPTH_RANGE
:
2675 gl_DepthRange( ctx
, (GLclampd
) n
[1].f
, (GLclampd
) n
[2].f
);
2677 case OPCODE_DISABLE
:
2678 gl_Disable( ctx
, n
[1].e
);
2680 case OPCODE_DRAW_BUFFER
:
2681 gl_DrawBuffer( ctx
, n
[1].e
);
2683 case OPCODE_DRAW_PIXELS
:
2684 gl_DrawPixels( ctx
, (struct gl_image
*) n
[1].data
);
2687 gl_Enable( ctx
, n
[1].e
);
2689 case OPCODE_EVALMESH1
:
2690 gl_EvalMesh1( ctx
, n
[1].e
, n
[2].i
, n
[3].i
);
2692 case OPCODE_EVALMESH2
:
2693 gl_EvalMesh2( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
);
2702 gl_Fogfv( ctx
, n
[1].e
, p
);
2705 case OPCODE_FRONT_FACE
:
2706 gl_FrontFace( ctx
, n
[1].e
);
2708 case OPCODE_FRUSTUM
:
2709 gl_Frustum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2712 gl_Hint( ctx
, n
[1].e
, n
[2].e
);
2714 case OPCODE_INDEX_MASK
:
2715 gl_IndexMask( ctx
, n
[1].ui
);
2717 case OPCODE_INIT_NAMES
:
2718 gl_InitNames( ctx
);
2727 gl_Lightfv( ctx
, n
[1].e
, n
[2].e
, p
, 4 );
2730 case OPCODE_LIGHT_MODEL
:
2737 gl_LightModelfv( ctx
, n
[1].e
, p
);
2740 case OPCODE_LINE_STIPPLE
:
2741 gl_LineStipple( ctx
, n
[1].i
, n
[2].us
);
2743 case OPCODE_LINE_WIDTH
:
2744 gl_LineWidth( ctx
, n
[1].f
);
2746 case OPCODE_LIST_BASE
:
2747 gl_ListBase( ctx
, n
[1].ui
);
2749 case OPCODE_LOAD_IDENTITY
:
2750 gl_LoadIdentity( ctx
);
2752 case OPCODE_LOAD_MATRIX
:
2753 if (sizeof(Node
)==sizeof(GLfloat
)) {
2754 gl_LoadMatrixf( ctx
, &n
[1].f
);
2759 for (i
=0;i
<16;i
++) {
2762 gl_LoadMatrixf( ctx
, m
);
2765 case OPCODE_LOAD_NAME
:
2766 gl_LoadName( ctx
, n
[1].ui
);
2768 case OPCODE_LOGIC_OP
:
2769 gl_LogicOp( ctx
, n
[1].e
);
2772 gl_Map1f( ctx
, n
[1].e
, n
[2].f
, n
[3].f
,
2773 n
[4].i
, n
[5].i
, (GLfloat
*) n
[6].data
, GL_TRUE
);
2776 gl_Map2f( ctx
, n
[1].e
,
2777 n
[2].f
, n
[3].f
, /* u1, u2 */
2778 n
[6].i
, n
[8].i
, /* ustride, uorder */
2779 n
[4].f
, n
[5].f
, /* v1, v2 */
2780 n
[7].i
, n
[9].i
, /* vstride, vorder */
2781 (GLfloat
*) n
[10].data
,
2784 case OPCODE_MAPGRID1
:
2785 gl_MapGrid1f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
);
2787 case OPCODE_MAPGRID2
:
2788 gl_MapGrid2f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
, n
[4].i
, n
[5].f
, n
[6].f
);
2790 case OPCODE_MATRIX_MODE
:
2791 gl_MatrixMode( ctx
, n
[1].e
);
2793 case OPCODE_MULT_MATRIX
:
2794 if (sizeof(Node
)==sizeof(GLfloat
)) {
2795 gl_MultMatrixf( ctx
, &n
[1].f
);
2800 for (i
=0;i
<16;i
++) {
2803 gl_MultMatrixf( ctx
, m
);
2807 gl_Ortho( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2809 case OPCODE_PASSTHROUGH
:
2810 gl_PassThrough( ctx
, n
[1].f
);
2812 case OPCODE_PIXEL_MAP
:
2813 gl_PixelMapfv( ctx
, n
[1].e
, n
[2].i
, (GLfloat
*) n
[3].data
);
2815 case OPCODE_PIXEL_TRANSFER
:
2816 gl_PixelTransferf( ctx
, n
[1].e
, n
[2].f
);
2818 case OPCODE_PIXEL_ZOOM
:
2819 gl_PixelZoom( ctx
, n
[1].f
, n
[2].f
);
2821 case OPCODE_POINT_SIZE
:
2822 gl_PointSize( ctx
, n
[1].f
);
2824 case OPCODE_POINT_PARAMETERS
:
2830 gl_PointParameterfvEXT( ctx
, n
[1].e
, params
);
2833 case OPCODE_POLYGON_MODE
:
2834 gl_PolygonMode( ctx
, n
[1].e
, n
[2].e
);
2836 case OPCODE_POLYGON_STIPPLE
:
2837 gl_PolygonStipple( ctx
, (GLuint
*) n
[1].data
);
2839 case OPCODE_POLYGON_OFFSET
:
2840 gl_PolygonOffset( ctx
, n
[1].f
, n
[2].f
);
2842 case OPCODE_POP_ATTRIB
:
2843 gl_PopAttrib( ctx
);
2845 case OPCODE_POP_MATRIX
:
2846 gl_PopMatrix( ctx
);
2848 case OPCODE_POP_NAME
:
2851 case OPCODE_PRIORITIZE_TEXTURE
:
2852 gl_PrioritizeTextures( ctx
, 1, &n
[1].ui
, &n
[2].f
);
2854 case OPCODE_PUSH_ATTRIB
:
2855 gl_PushAttrib( ctx
, n
[1].bf
);
2857 case OPCODE_PUSH_MATRIX
:
2858 gl_PushMatrix( ctx
);
2860 case OPCODE_PUSH_NAME
:
2861 gl_PushName( ctx
, n
[1].ui
);
2863 case OPCODE_RASTER_POS
:
2864 gl_RasterPos4f( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2866 case OPCODE_READ_BUFFER
:
2867 gl_ReadBuffer( ctx
, n
[1].e
);
2870 gl_Rectf( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2873 gl_Scalef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
2875 case OPCODE_SCISSOR
:
2876 gl_Scissor( ctx
, n
[1].i
, n
[2].i
, n
[3].i
, n
[4].i
);
2878 case OPCODE_SHADE_MODEL
:
2879 gl_ShadeModel( ctx
, n
[1].e
);
2881 case OPCODE_STENCIL_FUNC
:
2882 gl_StencilFunc( ctx
, n
[1].e
, n
[2].i
, n
[3].ui
);
2884 case OPCODE_STENCIL_MASK
:
2885 gl_StencilMask( ctx
, n
[1].ui
);
2887 case OPCODE_STENCIL_OP
:
2888 gl_StencilOp( ctx
, n
[1].e
, n
[2].e
, n
[3].e
);
2897 gl_TexEnvfv( ctx
, n
[1].e
, n
[2].e
, params
);
2907 gl_TexGenfv( ctx
, n
[1].e
, n
[2].e
, params
);
2910 case OPCODE_TEXPARAMETER
:
2917 gl_TexParameterfv( ctx
, n
[1].e
, n
[2].e
, params
);
2920 case OPCODE_TEX_IMAGE1D
:
2922 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2923 ctx
->Unpack
= defaultPacking
;
2925 n
[1].e
, /* target */
2927 n
[3].i
, /* components */
2929 n
[5].e
, /* border */
2930 n
[6].e
, /* format */
2933 ctx
->Unpack
= save
; /* restore */
2936 case OPCODE_TEX_IMAGE2D
:
2938 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2939 ctx
->Unpack
= defaultPacking
;
2941 n
[1].e
, /* target */
2943 n
[3].i
, /* components */
2945 n
[5].i
, /* height */
2946 n
[6].e
, /* border */
2947 n
[7].e
, /* format */
2950 ctx
->Unpack
= save
; /* restore */
2953 case OPCODE_TEX_IMAGE3D
:
2955 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2956 ctx
->Unpack
= defaultPacking
;
2958 n
[1].e
, /* target */
2960 n
[3].i
, /* components */
2962 n
[5].i
, /* height */
2964 n
[7].e
, /* border */
2965 n
[8].e
, /* format */
2968 ctx
->Unpack
= save
; /* restore */
2971 case OPCODE_TEX_SUB_IMAGE1D
:
2973 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2974 ctx
->Unpack
= defaultPacking
;
2975 gl_TexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].e
,
2976 n
[6].e
, n
[7].data
);
2977 ctx
->Unpack
= save
; /* restore */
2980 case OPCODE_TEX_SUB_IMAGE2D
:
2982 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2983 ctx
->Unpack
= defaultPacking
;
2984 (*ctx
->Exec
.TexSubImage2D
)( ctx
, n
[1].e
, n
[2].i
, n
[3].i
,
2986 n
[6].i
, n
[7].e
, n
[8].e
, n
[9].data
);
2987 ctx
->Unpack
= save
; /* restore */
2990 case OPCODE_TEX_SUB_IMAGE3D
:
2992 struct gl_pixelstore_attrib save
= ctx
->Unpack
;
2993 ctx
->Unpack
= defaultPacking
;
2994 gl_TexSubImage3D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
,
2995 n
[6].i
, n
[7].i
, n
[8].i
, n
[9].e
, n
[10].e
,
2997 ctx
->Unpack
= save
; /* restore */
3000 case OPCODE_TRANSLATE
:
3001 gl_Translatef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
3003 case OPCODE_VIEWPORT
:
3005 n
[1].i
, n
[2].i
, (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
);
3007 case OPCODE_WINDOW_POS
:
3008 gl_WindowPos4fMESA( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
3010 case OPCODE_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
3011 gl_ActiveTexture( ctx
, n
[1].e
);
3013 case OPCODE_CLIENT_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
3014 gl_ClientActiveTexture( ctx
, n
[1].e
);
3016 case OPCODE_CONTINUE
:
3017 n
= (Node
*) n
[1].next
;
3019 case OPCODE_END_OF_LIST
:
3025 sprintf(msg
, "Error in execute_list: opcode=%d", (int) opcode
);
3026 gl_problem( ctx
, msg
);
3031 /* increment n to point to next compiled command */
3032 if (opcode
!=OPCODE_CONTINUE
) {
3033 n
+= InstSize
[opcode
];
3044 /**********************************************************************/
3046 /**********************************************************************/
3052 * Test if a display list number is valid.
3054 GLboolean
gl_IsList( GLcontext
*ctx
, GLuint list
)
3056 if (list
> 0 && HashLookup(ctx
->Shared
->DisplayList
, list
)) {
3067 * Delete a sequence of consecutive display lists.
3069 void gl_DeleteLists( GLcontext
*ctx
, GLuint list
, GLsizei range
)
3073 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glDeleteLists");
3075 gl_error( ctx
, GL_INVALID_VALUE
, "glDeleteLists" );
3078 for (i
=list
;i
<list
+range
;i
++) {
3079 gl_destroy_list( ctx
, i
);
3086 * Return a display list number, n, such that lists n through n+range-1
3089 GLuint
gl_GenLists( GLcontext
*ctx
, GLsizei range
)
3093 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx
, "glGenLists", 0);
3095 gl_error( ctx
, GL_INVALID_VALUE
, "glGenLists" );
3102 base
= HashFindFreeKeyBlock(ctx
->Shared
->DisplayList
, range
);
3104 /* reserve the list IDs by with empty/dummy lists */
3106 for (i
=0; i
<range
; i
++) {
3107 HashInsert(ctx
->Shared
->DisplayList
, base
+i
, make_empty_list());
3116 * Begin a new display list.
3118 void gl_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
3120 struct immediate
*IM
;
3121 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glNewList");
3123 if (MESA_VERBOSE
&VERBOSE_API
)
3124 fprintf(stderr
, "glNewList %u %s\n", list
, gl_lookup_enum_by_nr(mode
));
3127 gl_error( ctx
, GL_INVALID_VALUE
, "glNewList" );
3131 if (mode
!=GL_COMPILE
&& mode
!=GL_COMPILE_AND_EXECUTE
) {
3132 gl_error( ctx
, GL_INVALID_ENUM
, "glNewList" );
3136 if (ctx
->CurrentListPtr
) {
3137 /* already compiling a display list */
3138 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
3142 /* Allocate new display list */
3143 ctx
->CurrentListNum
= list
;
3144 ctx
->CurrentBlock
= (Node
*) MALLOC( sizeof(Node
) * BLOCK_SIZE
);
3145 ctx
->CurrentListPtr
= ctx
->CurrentBlock
;
3146 ctx
->CurrentPos
= 0;
3148 IM
= gl_immediate_alloc( ctx
);
3149 SET_IMMEDIATE( ctx
, IM
);
3150 gl_reset_input( ctx
);
3152 ctx
->CompileFlag
= GL_TRUE
;
3153 ctx
->CompileCVAFlag
= GL_FALSE
;
3154 ctx
->ExecuteFlag
= (mode
== GL_COMPILE_AND_EXECUTE
);
3155 ctx
->API
= ctx
->Save
; /* Switch the API function pointers */
3161 * End definition of current display list.
3163 void gl_EndList( GLcontext
*ctx
)
3165 if (MESA_VERBOSE
&VERBOSE_API
)
3166 fprintf(stderr
, "glEndList\n");
3168 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
, "glEndList" );
3170 /* Check that a list is under construction */
3171 if (!ctx
->CurrentListPtr
) {
3172 gl_error( ctx
, GL_INVALID_OPERATION
, "glEndList" );
3176 (void) alloc_instruction( ctx
, OPCODE_END_OF_LIST
, 0 );
3178 /* Destroy old list, if any */
3179 gl_destroy_list(ctx
, ctx
->CurrentListNum
);
3180 /* Install the list */
3181 HashInsert(ctx
->Shared
->DisplayList
, ctx
->CurrentListNum
, ctx
->CurrentListPtr
);
3184 if (MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
)
3185 mesa_print_display_list(ctx
->CurrentListNum
);
3187 ctx
->CurrentListNum
= 0;
3188 ctx
->CurrentListPtr
= NULL
;
3189 ctx
->ExecuteFlag
= GL_TRUE
;
3190 ctx
->CompileFlag
= GL_FALSE
;
3191 /* ctx->CompileCVAFlag = ...; */
3193 /* KW: Put back the old input pointer.
3195 if (--ctx
->input
->ref_count
== 0)
3196 gl_immediate_free( ctx
->input
);
3198 SET_IMMEDIATE( ctx
, ctx
->VB
->IM
);
3199 gl_reset_input( ctx
);
3201 /* Haven't tracked down why this is needed.
3205 ctx
->API
= ctx
->Exec
; /* Switch the API function pointers */
3210 void gl_CallList( GLcontext
*ctx
, GLuint list
)
3212 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
3213 /* execute the display list, and restore the CompileFlag. */
3214 GLboolean save_compile_flag
;
3216 if (MESA_VERBOSE
&VERBOSE_API
) {
3217 fprintf(stderr
, "glCallList %u\n", list
);
3218 mesa_print_display_list( list
);
3221 save_compile_flag
= ctx
->CompileFlag
;
3222 ctx
->CompileFlag
= GL_FALSE
;
3224 FLUSH_VB( ctx
, "call list" );
3225 execute_list( ctx
, list
);
3226 ctx
->CompileFlag
= save_compile_flag
;
3228 /* also restore API function pointers to point to "save" versions */
3229 if (save_compile_flag
)
3230 ctx
->API
= ctx
->Save
;
3236 * Execute glCallLists: call multiple display lists.
3238 void gl_CallLists( GLcontext
*ctx
,
3239 GLsizei n
, GLenum type
, const GLvoid
*lists
)
3243 GLboolean save_compile_flag
;
3245 /* Save the CompileFlag status, turn it off, execute display list,
3246 * and restore the CompileFlag.
3248 save_compile_flag
= ctx
->CompileFlag
;
3249 ctx
->CompileFlag
= GL_FALSE
;
3251 FLUSH_VB( ctx
, "call lists" );
3254 list
= translate_id( i
, type
, lists
);
3255 execute_list( ctx
, ctx
->List
.ListBase
+ list
);
3258 ctx
->CompileFlag
= save_compile_flag
;
3260 /* also restore API function pointers to point to "save" versions */
3261 if (save_compile_flag
)
3262 ctx
->API
= ctx
->Save
;
3265 /* RESET_IMMEDIATE( ctx ); */
3271 * Set the offset added to list numbers in glCallLists.
3273 void gl_ListBase( GLcontext
*ctx
, GLuint base
)
3275 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glListBase");
3276 ctx
->List
.ListBase
= base
;
3285 * Assign all the pointers in 'table' to point to Mesa's display list
3286 * building functions.
3288 void gl_init_dlist_pointers( struct gl_api_table
*table
)
3290 table
->Accum
= save_Accum
;
3291 table
->AlphaFunc
= save_AlphaFunc
;
3292 table
->AreTexturesResident
= gl_AreTexturesResident
;
3293 table
->BindTexture
= save_BindTexture
;
3294 table
->Bitmap
= save_Bitmap
;
3295 table
->BlendColor
= save_BlendColor
;
3296 table
->BlendEquation
= save_BlendEquation
;
3297 table
->BlendFunc
= save_BlendFunc
;
3298 table
->BlendFuncSeparate
= save_BlendFuncSeparate
;
3299 table
->CallList
= save_CallList
;
3300 table
->CallLists
= save_CallLists
;
3301 table
->Clear
= save_Clear
;
3302 table
->ClearAccum
= save_ClearAccum
;
3303 table
->ClearColor
= save_ClearColor
;
3304 table
->ClearDepth
= save_ClearDepth
;
3305 table
->ClearIndex
= save_ClearIndex
;
3306 table
->ClearStencil
= save_ClearStencil
;
3307 table
->ClipPlane
= save_ClipPlane
;
3308 table
->ColorMask
= save_ColorMask
;
3309 table
->ColorMaterial
= save_ColorMaterial
;
3310 table
->ColorTable
= save_ColorTable
;
3311 table
->ColorSubTable
= save_ColorSubTable
;
3312 table
->CopyPixels
= save_CopyPixels
;
3313 table
->CopyTexImage1D
= save_CopyTexImage1D
;
3314 table
->CopyTexImage2D
= save_CopyTexImage2D
;
3315 table
->CopyTexSubImage1D
= save_CopyTexSubImage1D
;
3316 table
->CopyTexSubImage2D
= save_CopyTexSubImage2D
;
3317 table
->CopyTexSubImage3D
= save_CopyTexSubImage3D
;
3318 table
->CullFace
= save_CullFace
;
3319 table
->DeleteLists
= gl_DeleteLists
; /* NOT SAVED */
3320 table
->DeleteTextures
= gl_DeleteTextures
; /* NOT SAVED */
3321 table
->DepthFunc
= save_DepthFunc
;
3322 table
->DepthMask
= save_DepthMask
;
3323 table
->DepthRange
= save_DepthRange
;
3324 table
->Disable
= save_Disable
;
3325 table
->DisableClientState
= gl_DisableClientState
; /* NOT SAVED */
3326 table
->DrawBuffer
= save_DrawBuffer
;
3327 table
->DrawPixels
= save_DrawPixels
;
3328 table
->Enable
= save_Enable
;
3329 table
->Error
= gl_save_error
;
3330 table
->EnableClientState
= gl_EnableClientState
; /* NOT SAVED */
3331 table
->EndList
= gl_EndList
; /* NOT SAVED */
3332 table
->EvalMesh1
= save_EvalMesh1
;
3333 table
->EvalMesh2
= save_EvalMesh2
;
3334 table
->FeedbackBuffer
= gl_FeedbackBuffer
; /* NOT SAVED */
3335 table
->Finish
= gl_Finish
; /* NOT SAVED */
3336 table
->Flush
= gl_Flush
; /* NOT SAVED */
3337 table
->Fogfv
= save_Fogfv
;
3338 table
->FrontFace
= save_FrontFace
;
3339 table
->Frustum
= save_Frustum
;
3340 table
->GenLists
= gl_GenLists
; /* NOT SAVED */
3341 table
->GenTextures
= gl_GenTextures
; /* NOT SAVED */
3343 /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
3344 table
->GetBooleanv
= gl_GetBooleanv
;
3345 table
->GetClipPlane
= gl_GetClipPlane
;
3346 table
->GetColorTable
= gl_GetColorTable
;
3347 table
->GetColorTableParameteriv
= gl_GetColorTableParameteriv
;
3348 table
->GetDoublev
= gl_GetDoublev
;
3349 table
->GetError
= gl_GetError
;
3350 table
->GetFloatv
= gl_GetFloatv
;
3351 table
->GetIntegerv
= gl_GetIntegerv
;
3352 table
->GetString
= gl_GetString
;
3353 table
->GetLightfv
= gl_GetLightfv
;
3354 table
->GetLightiv
= gl_GetLightiv
;
3355 table
->GetMapdv
= gl_GetMapdv
;
3356 table
->GetMapfv
= gl_GetMapfv
;
3357 table
->GetMapiv
= gl_GetMapiv
;
3358 table
->GetMaterialfv
= gl_GetMaterialfv
;
3359 table
->GetMaterialiv
= gl_GetMaterialiv
;
3360 table
->GetPixelMapfv
= gl_GetPixelMapfv
;
3361 table
->GetPixelMapuiv
= gl_GetPixelMapuiv
;
3362 table
->GetPixelMapusv
= gl_GetPixelMapusv
;
3363 table
->GetPointerv
= gl_GetPointerv
;
3364 table
->GetPolygonStipple
= gl_GetPolygonStipple
;
3365 table
->GetTexEnvfv
= gl_GetTexEnvfv
;
3366 table
->GetTexEnviv
= gl_GetTexEnviv
;
3367 table
->GetTexGendv
= gl_GetTexGendv
;
3368 table
->GetTexGenfv
= gl_GetTexGenfv
;
3369 table
->GetTexGeniv
= gl_GetTexGeniv
;
3370 table
->GetTexImage
= gl_GetTexImage
;
3371 table
->GetTexLevelParameterfv
= gl_GetTexLevelParameterfv
;
3372 table
->GetTexLevelParameteriv
= gl_GetTexLevelParameteriv
;
3373 table
->GetTexParameterfv
= gl_GetTexParameterfv
;
3374 table
->GetTexParameteriv
= gl_GetTexParameteriv
;
3376 table
->Hint
= save_Hint
;
3377 table
->IndexMask
= save_IndexMask
;
3378 table
->InitNames
= save_InitNames
;
3379 table
->IsEnabled
= gl_IsEnabled
; /* NOT SAVED */
3380 table
->IsTexture
= gl_IsTexture
; /* NOT SAVED */
3381 table
->IsList
= gl_IsList
; /* NOT SAVED */
3382 table
->LightModelfv
= save_LightModelfv
;
3383 table
->Lightfv
= save_Lightfv
;
3384 table
->LineStipple
= save_LineStipple
;
3385 table
->LineWidth
= save_LineWidth
;
3386 table
->ListBase
= save_ListBase
;
3387 table
->LoadIdentity
= save_LoadIdentity
;
3388 table
->LoadMatrixf
= save_LoadMatrixf
;
3389 table
->LoadName
= save_LoadName
;
3390 table
->LogicOp
= save_LogicOp
;
3391 table
->Map1f
= save_Map1f
;
3392 table
->Map2f
= save_Map2f
;
3393 table
->MapGrid1f
= save_MapGrid1f
;
3394 table
->MapGrid2f
= save_MapGrid2f
;
3395 table
->MatrixMode
= save_MatrixMode
;
3396 table
->MultMatrixf
= save_MultMatrixf
;
3397 table
->NewList
= save_NewList
;
3398 table
->Ortho
= save_Ortho
;
3399 table
->PointParameterfvEXT
= save_PointParameterfvEXT
;
3400 table
->PassThrough
= save_PassThrough
;
3401 table
->PixelMapfv
= save_PixelMapfv
;
3402 table
->PixelStorei
= gl_PixelStorei
; /* NOT SAVED */
3403 table
->PixelTransferf
= save_PixelTransferf
;
3404 table
->PixelZoom
= save_PixelZoom
;
3405 table
->PointSize
= save_PointSize
;
3406 table
->PolygonMode
= save_PolygonMode
;
3407 table
->PolygonOffset
= save_PolygonOffset
;
3408 table
->PolygonStipple
= save_PolygonStipple
;
3409 table
->PopAttrib
= save_PopAttrib
;
3410 table
->PopClientAttrib
= gl_PopClientAttrib
; /* NOT SAVED */
3411 table
->PopMatrix
= save_PopMatrix
;
3412 table
->PopName
= save_PopName
;
3413 table
->PrioritizeTextures
= save_PrioritizeTextures
;
3414 table
->PushAttrib
= save_PushAttrib
;
3415 table
->PushClientAttrib
= gl_PushClientAttrib
; /* NOT SAVED */
3416 table
->PushMatrix
= save_PushMatrix
;
3417 table
->PushName
= save_PushName
;
3418 table
->RasterPos4f
= save_RasterPos4f
;
3419 table
->ReadBuffer
= save_ReadBuffer
;
3420 table
->ReadPixels
= gl_ReadPixels
; /* NOT SAVED */
3421 table
->Rectf
= save_Rectf
;
3422 table
->RenderMode
= gl_RenderMode
; /* NOT SAVED */
3423 table
->Rotatef
= save_Rotatef
;
3424 table
->Scalef
= save_Scalef
;
3425 table
->Scissor
= save_Scissor
;
3426 table
->SelectBuffer
= gl_SelectBuffer
; /* NOT SAVED */
3427 table
->ShadeModel
= save_ShadeModel
;
3428 table
->StencilFunc
= save_StencilFunc
;
3429 table
->StencilMask
= save_StencilMask
;
3430 table
->StencilOp
= save_StencilOp
;
3431 table
->TexEnvfv
= save_TexEnvfv
;
3432 table
->TexGenfv
= save_TexGenfv
;
3433 table
->TexImage1D
= save_TexImage1D
;
3434 table
->TexImage2D
= save_TexImage2D
;
3435 table
->TexImage3D
= save_TexImage3D
;
3436 table
->TexSubImage1D
= save_TexSubImage1D
;
3437 table
->TexSubImage2D
= save_TexSubImage2D
;
3438 table
->TexSubImage3D
= save_TexSubImage3D
;
3439 table
->TexParameterfv
= save_TexParameterfv
;
3440 table
->Translatef
= save_Translatef
;
3441 table
->Viewport
= save_Viewport
;
3443 /* GL_MESA_window_pos extension */
3444 table
->WindowPos4fMESA
= save_WindowPos4fMESA
;
3446 /* GL_MESA_resize_buffers extension */
3447 table
->ResizeBuffersMESA
= gl_ResizeBuffersMESA
;
3449 /* GL_ARB_multitexture */
3450 table
->ActiveTexture
= save_ActiveTexture
;
3451 table
->ClientActiveTexture
= save_ClientActiveTexture
;
3459 static const char *enum_string( GLenum k
)
3461 return gl_lookup_enum_by_nr( k
);
3466 * Print the commands in a display list. For debugging only.
3467 * TODO: many commands aren't handled yet.
3469 static void print_list( GLcontext
*ctx
, FILE *f
, GLuint list
)
3475 if (!glIsList(list
)) {
3476 fprintf(f
,"%u is not a display list ID\n",list
);
3480 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
3482 fprintf( f
, "START-LIST %u, address %p\n", list
, (void*)n
);
3484 done
= n
? GL_FALSE
: GL_TRUE
;
3486 opcode
= n
[0].opcode
;
3490 fprintf(f
,"accum %s %g\n", enum_string(n
[1].e
), n
[2].f
);
3493 fprintf(f
,"Bitmap %d %d %g %g %g %g %p\n", n
[1].i
, n
[2].i
,
3494 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
, (void *) n
[7].data
);
3496 case OPCODE_CALL_LIST
:
3497 fprintf(f
,"CallList %d\n", (int) n
[1].ui
);
3499 case OPCODE_CALL_LIST_OFFSET
:
3500 fprintf(f
,"CallList %d + offset %u = %u\n", (int) n
[1].ui
,
3501 ctx
->List
.ListBase
, ctx
->List
.ListBase
+ n
[1].ui
);
3503 case OPCODE_DISABLE
:
3504 fprintf(f
,"Disable %s\n", enum_string(n
[1].e
));
3507 fprintf(f
,"Enable %s\n", enum_string(n
[1].e
));
3509 case OPCODE_FRUSTUM
:
3510 fprintf(f
,"Frustum %g %g %g %g %g %g\n",
3511 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3513 case OPCODE_LINE_STIPPLE
:
3514 fprintf(f
,"LineStipple %d %x\n", n
[1].i
, (int) n
[2].us
);
3516 case OPCODE_LOAD_IDENTITY
:
3517 fprintf(f
,"LoadIdentity\n");
3519 case OPCODE_LOAD_MATRIX
:
3520 fprintf(f
,"LoadMatrix\n");
3521 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3522 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3523 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3524 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3526 case OPCODE_MULT_MATRIX
:
3527 fprintf(f
,"MultMatrix (or Rotate)\n");
3528 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3529 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3530 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3531 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3534 fprintf(f
,"Ortho %g %g %g %g %g %g\n",
3535 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3537 case OPCODE_POP_ATTRIB
:
3538 fprintf(f
,"PopAttrib\n");
3540 case OPCODE_POP_MATRIX
:
3541 fprintf(f
,"PopMatrix\n");
3543 case OPCODE_POP_NAME
:
3544 fprintf(f
,"PopName\n");
3546 case OPCODE_PUSH_ATTRIB
:
3547 fprintf(f
,"PushAttrib %x\n", n
[1].bf
);
3549 case OPCODE_PUSH_MATRIX
:
3550 fprintf(f
,"PushMatrix\n");
3552 case OPCODE_PUSH_NAME
:
3553 fprintf(f
,"PushName %d\n", (int) n
[1].ui
);
3555 case OPCODE_RASTER_POS
:
3556 fprintf(f
,"RasterPos %g %g %g %g\n", n
[1].f
, n
[2].f
,n
[3].f
,n
[4].f
);
3559 fprintf( f
, "Rectf %g %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
3562 fprintf(f
,"Scale %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3564 case OPCODE_TRANSLATE
:
3565 fprintf(f
,"Translate %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3567 case OPCODE_BIND_TEXTURE
:
3568 fprintf(f
,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n
[1].ui
),
3571 case OPCODE_SHADE_MODEL
:
3572 fprintf(f
,"ShadeModel %s\n", gl_lookup_enum_by_nr(n
[1].ui
));
3576 * meta opcodes/commands
3579 fprintf(f
,"Error: %s %s\n", enum_string(n
[1].e
), (const char *)n
[2].data
);
3581 case OPCODE_VERTEX_CASSETTE
:
3582 fprintf(f
,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
3583 ((struct immediate
*) n
[1].data
)->id
,
3586 /* gl_print_cassette( (struct immediate *) n[1].data, */
3589 case OPCODE_CONTINUE
:
3590 fprintf(f
,"DISPLAY-LIST-CONTINUE\n");
3591 n
= (Node
*) n
[1].next
;
3593 case OPCODE_END_OF_LIST
:
3594 fprintf(f
,"END-LIST %u\n", list
);
3598 if (opcode
< 0 || opcode
> OPCODE_END_OF_LIST
) {
3599 fprintf(f
,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
3604 fprintf(f
,"command %d, %u operands\n",opcode
,InstSize
[opcode
]);
3608 /* increment n to point to next compiled command */
3609 if (opcode
!=OPCODE_CONTINUE
) {
3610 n
+= InstSize
[opcode
];
3623 * Clients may call this function to help debug display list problems.
3624 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
3625 * changed, or break in the future without notice.
3627 void mesa_print_display_list( GLuint list
)
3630 print_list( CC
, stderr
, list
);