1 /* $Id: dlist.c,v 1.11 1999/10/19 18:37:03 keithw 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
:
392 gl_free_image( (struct gl_image
*) n
[8].data
);
393 n
+= InstSize
[n
[0].opcode
];
395 case OPCODE_TEX_IMAGE2D
:
396 gl_free_image( (struct gl_image
*) n
[9].data
);
397 n
+= InstSize
[n
[0].opcode
];
399 case OPCODE_TEX_SUB_IMAGE1D
:
401 struct gl_image
*image
;
402 image
= (struct gl_image
*) n
[7].data
;
403 gl_free_image( image
);
406 case OPCODE_TEX_SUB_IMAGE2D
:
408 struct gl_image
*image
;
409 image
= (struct gl_image
*) n
[9].data
;
410 gl_free_image( image
);
413 case OPCODE_CONTINUE
:
414 n
= (Node
*) n
[1].next
;
418 case OPCODE_END_OF_LIST
:
423 /* Most frequent case */
424 n
+= InstSize
[n
[0].opcode
];
429 HashRemove(ctx
->Shared
->DisplayList
, list
);
435 * Translate the nth element of list from type to GLuint.
437 static GLuint
translate_id( GLsizei n
, GLenum type
, const GLvoid
*list
)
449 bptr
= (GLbyte
*) list
;
450 return (GLuint
) *(bptr
+n
);
451 case GL_UNSIGNED_BYTE
:
452 ubptr
= (GLubyte
*) list
;
453 return (GLuint
) *(ubptr
+n
);
455 sptr
= (GLshort
*) list
;
456 return (GLuint
) *(sptr
+n
);
457 case GL_UNSIGNED_SHORT
:
458 usptr
= (GLushort
*) list
;
459 return (GLuint
) *(usptr
+n
);
461 iptr
= (GLint
*) list
;
462 return (GLuint
) *(iptr
+n
);
463 case GL_UNSIGNED_INT
:
464 uiptr
= (GLuint
*) list
;
465 return (GLuint
) *(uiptr
+n
);
467 fptr
= (GLfloat
*) list
;
468 return (GLuint
) *(fptr
+n
);
470 ubptr
= ((GLubyte
*) list
) + 2*n
;
471 return (GLuint
) *ubptr
* 256 + (GLuint
) *(ubptr
+1);
473 ubptr
= ((GLubyte
*) list
) + 3*n
;
474 return (GLuint
) *ubptr
* 65536
475 + (GLuint
) *(ubptr
+1) * 256
476 + (GLuint
) *(ubptr
+2);
478 ubptr
= ((GLubyte
*) list
) + 4*n
;
479 return (GLuint
) *ubptr
* 16777216
480 + (GLuint
) *(ubptr
+1) * 65536
481 + (GLuint
) *(ubptr
+2) * 256
482 + (GLuint
) *(ubptr
+3);
491 /**********************************************************************/
493 /**********************************************************************/
495 void gl_init_lists( void )
497 static int init_flag
= 0;
500 InstSize
[OPCODE_ACCUM
] = 3;
501 InstSize
[OPCODE_ALPHA_FUNC
] = 3;
502 InstSize
[OPCODE_BIND_TEXTURE
] = 3;
503 InstSize
[OPCODE_BITMAP
] = 8;
504 InstSize
[OPCODE_BLEND_COLOR
] = 5;
505 InstSize
[OPCODE_BLEND_EQUATION
] = 2;
506 InstSize
[OPCODE_BLEND_FUNC
] = 3;
507 InstSize
[OPCODE_BLEND_FUNC_SEPARATE
] = 5;
508 InstSize
[OPCODE_CALL_LIST
] = 2;
509 InstSize
[OPCODE_CALL_LIST_OFFSET
] = 2;
510 InstSize
[OPCODE_CLEAR
] = 2;
511 InstSize
[OPCODE_CLEAR_ACCUM
] = 5;
512 InstSize
[OPCODE_CLEAR_COLOR
] = 5;
513 InstSize
[OPCODE_CLEAR_DEPTH
] = 2;
514 InstSize
[OPCODE_CLEAR_INDEX
] = 2;
515 InstSize
[OPCODE_CLEAR_STENCIL
] = 2;
516 InstSize
[OPCODE_CLIP_PLANE
] = 6;
517 InstSize
[OPCODE_COLOR_MASK
] = 5;
518 InstSize
[OPCODE_COLOR_MATERIAL
] = 3;
519 InstSize
[OPCODE_COLOR_TABLE
] = 4;
520 InstSize
[OPCODE_COLOR_SUB_TABLE
] = 4;
521 InstSize
[OPCODE_COPY_PIXELS
] = 6;
522 InstSize
[OPCODE_COPY_TEX_IMAGE1D
] = 8;
523 InstSize
[OPCODE_COPY_TEX_IMAGE2D
] = 9;
524 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE1D
] = 7;
525 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE2D
] = 9;
526 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE3D
] = 10;
527 InstSize
[OPCODE_CULL_FACE
] = 2;
528 InstSize
[OPCODE_DEPTH_FUNC
] = 2;
529 InstSize
[OPCODE_DEPTH_MASK
] = 2;
530 InstSize
[OPCODE_DEPTH_RANGE
] = 3;
531 InstSize
[OPCODE_DISABLE
] = 2;
532 InstSize
[OPCODE_DRAW_BUFFER
] = 2;
533 InstSize
[OPCODE_DRAW_PIXELS
] = 2;
534 InstSize
[OPCODE_ENABLE
] = 2;
535 InstSize
[OPCODE_EVALCOORD1
] = 2;
536 InstSize
[OPCODE_EVALCOORD2
] = 3;
537 InstSize
[OPCODE_EVALMESH1
] = 4;
538 InstSize
[OPCODE_EVALMESH2
] = 6;
539 InstSize
[OPCODE_EVALPOINT1
] = 2;
540 InstSize
[OPCODE_EVALPOINT2
] = 3;
541 InstSize
[OPCODE_FOG
] = 6;
542 InstSize
[OPCODE_FRONT_FACE
] = 2;
543 InstSize
[OPCODE_FRUSTUM
] = 7;
544 InstSize
[OPCODE_HINT
] = 3;
545 InstSize
[OPCODE_INDEX_MASK
] = 2;
546 InstSize
[OPCODE_INIT_NAMES
] = 1;
547 InstSize
[OPCODE_LIGHT
] = 7;
548 InstSize
[OPCODE_LIGHT_MODEL
] = 6;
549 InstSize
[OPCODE_LINE_STIPPLE
] = 3;
550 InstSize
[OPCODE_LINE_WIDTH
] = 2;
551 InstSize
[OPCODE_LIST_BASE
] = 2;
552 InstSize
[OPCODE_LOAD_IDENTITY
] = 1;
553 InstSize
[OPCODE_LOAD_MATRIX
] = 17;
554 InstSize
[OPCODE_LOAD_NAME
] = 2;
555 InstSize
[OPCODE_LOGIC_OP
] = 2;
556 InstSize
[OPCODE_MAP1
] = 7;
557 InstSize
[OPCODE_MAP2
] = 11;
558 InstSize
[OPCODE_MAPGRID1
] = 4;
559 InstSize
[OPCODE_MAPGRID2
] = 7;
560 InstSize
[OPCODE_MATRIX_MODE
] = 2;
561 InstSize
[OPCODE_MULT_MATRIX
] = 17;
562 InstSize
[OPCODE_ORTHO
] = 7;
563 InstSize
[OPCODE_PASSTHROUGH
] = 2;
564 InstSize
[OPCODE_PIXEL_MAP
] = 4;
565 InstSize
[OPCODE_PIXEL_TRANSFER
] = 3;
566 InstSize
[OPCODE_PIXEL_ZOOM
] = 3;
567 InstSize
[OPCODE_POINT_SIZE
] = 2;
568 InstSize
[OPCODE_POINT_PARAMETERS
] = 5;
569 InstSize
[OPCODE_POLYGON_MODE
] = 3;
570 InstSize
[OPCODE_POLYGON_STIPPLE
] = 2;
571 InstSize
[OPCODE_POLYGON_OFFSET
] = 3;
572 InstSize
[OPCODE_POP_ATTRIB
] = 1;
573 InstSize
[OPCODE_POP_MATRIX
] = 1;
574 InstSize
[OPCODE_POP_NAME
] = 1;
575 InstSize
[OPCODE_PRIORITIZE_TEXTURE
] = 3;
576 InstSize
[OPCODE_PUSH_ATTRIB
] = 2;
577 InstSize
[OPCODE_PUSH_MATRIX
] = 1;
578 InstSize
[OPCODE_PUSH_NAME
] = 2;
579 InstSize
[OPCODE_RASTER_POS
] = 5;
580 InstSize
[OPCODE_RECTF
] = 5;
581 InstSize
[OPCODE_READ_BUFFER
] = 2;
582 InstSize
[OPCODE_SCALE
] = 4;
583 InstSize
[OPCODE_SCISSOR
] = 5;
584 InstSize
[OPCODE_STENCIL_FUNC
] = 4;
585 InstSize
[OPCODE_STENCIL_MASK
] = 2;
586 InstSize
[OPCODE_STENCIL_OP
] = 4;
587 InstSize
[OPCODE_SHADE_MODEL
] = 2;
588 InstSize
[OPCODE_TEXENV
] = 7;
589 InstSize
[OPCODE_TEXGEN
] = 7;
590 InstSize
[OPCODE_TEXPARAMETER
] = 7;
591 InstSize
[OPCODE_TEX_IMAGE1D
] = 9;
592 InstSize
[OPCODE_TEX_IMAGE2D
] = 10;
593 InstSize
[OPCODE_TEX_IMAGE3D
] = 11;
594 InstSize
[OPCODE_TEX_SUB_IMAGE1D
] = 8;
595 InstSize
[OPCODE_TEX_SUB_IMAGE2D
] = 10;
596 InstSize
[OPCODE_TEX_SUB_IMAGE3D
] = 12;
597 InstSize
[OPCODE_TRANSLATE
] = 4;
598 InstSize
[OPCODE_VIEWPORT
] = 5;
599 InstSize
[OPCODE_WINDOW_POS
] = 5;
600 InstSize
[OPCODE_CONTINUE
] = 2;
601 InstSize
[OPCODE_ERROR
] = 3;
602 InstSize
[OPCODE_VERTEX_CASSETTE
] = 9;
603 InstSize
[OPCODE_END_OF_LIST
] = 1;
604 /* GL_ARB_multitexture */
605 InstSize
[OPCODE_ACTIVE_TEXTURE
] = 2;
606 InstSize
[OPCODE_CLIENT_ACTIVE_TEXTURE
] = 2;
613 * Display List compilation functions
618 static void save_Accum( GLcontext
*ctx
, GLenum op
, GLfloat value
)
621 FLUSH_VB(ctx
, "dlist");
622 n
= alloc_instruction( ctx
, OPCODE_ACCUM
, 2 );
627 if (ctx
->ExecuteFlag
) {
628 (*ctx
->Exec
.Accum
)( ctx
, op
, value
);
633 static void save_AlphaFunc( GLcontext
*ctx
, GLenum func
, GLclampf ref
)
636 FLUSH_VB(ctx
, "dlist");
637 n
= alloc_instruction( ctx
, OPCODE_ALPHA_FUNC
, 2 );
640 n
[2].f
= (GLfloat
) ref
;
642 if (ctx
->ExecuteFlag
) {
643 (*ctx
->Exec
.AlphaFunc
)( ctx
, func
, ref
);
647 static void save_BindTexture( GLcontext
*ctx
, GLenum target
, GLuint texture
)
650 FLUSH_VB(ctx
, "dlist");
651 n
= alloc_instruction( ctx
, OPCODE_BIND_TEXTURE
, 2 );
656 if (ctx
->ExecuteFlag
) {
657 (*ctx
->Exec
.BindTexture
)( ctx
, target
, texture
);
662 static void save_Bitmap( GLcontext
*ctx
,
663 GLsizei width
, GLsizei height
,
664 GLfloat xorig
, GLfloat yorig
,
665 GLfloat xmove
, GLfloat ymove
,
666 const GLubyte
*bitmap
,
667 const struct gl_pixelstore_attrib
*packing
)
670 FLUSH_VB(ctx
, "dlist");
671 n
= alloc_instruction( ctx
, OPCODE_BITMAP
, 7 );
673 struct gl_image
*image
= gl_unpack_bitmap( ctx
, width
, height
,
678 n
[1].i
= (GLint
) width
;
679 n
[2].i
= (GLint
) height
;
684 n
[7].data
= (void *) image
;
686 if (ctx
->ExecuteFlag
) {
687 (*ctx
->Exec
.Bitmap
)( ctx
, width
, height
,
688 xorig
, yorig
, xmove
, ymove
, bitmap
, packing
);
693 static void save_BlendEquation( GLcontext
*ctx
, GLenum mode
)
696 FLUSH_VB(ctx
, "dlist");
697 n
= alloc_instruction( ctx
, OPCODE_BLEND_EQUATION
, 1 );
701 if (ctx
->ExecuteFlag
) {
702 (*ctx
->Exec
.BlendEquation
)( ctx
, mode
);
707 static void save_BlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
710 FLUSH_VB(ctx
, "dlist");
711 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC
, 2 );
716 if (ctx
->ExecuteFlag
) {
717 (*ctx
->Exec
.BlendFunc
)( ctx
, sfactor
, dfactor
);
722 static void save_BlendFuncSeparate( GLcontext
*ctx
,
723 GLenum sfactorRGB
, GLenum dfactorRGB
,
724 GLenum sfactorA
, GLenum dfactorA
)
727 FLUSH_VB(ctx
, "dlist");
728 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC_SEPARATE
, 4 );
735 if (ctx
->ExecuteFlag
) {
736 (*ctx
->Exec
.BlendFuncSeparate
)( ctx
, sfactorRGB
, dfactorRGB
,
742 static void save_BlendColor( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
743 GLfloat blue
, GLfloat alpha
)
746 FLUSH_VB(ctx
, "dlist");
747 n
= alloc_instruction( ctx
, OPCODE_BLEND_COLOR
, 4 );
754 if (ctx
->ExecuteFlag
) {
755 (*ctx
->Exec
.BlendColor
)( ctx
, red
, green
, blue
, alpha
);
760 static void save_CallList( GLcontext
*ctx
, GLuint list
)
763 FLUSH_VB(ctx
, "dlist");
764 n
= alloc_instruction( ctx
, OPCODE_CALL_LIST
, 1 );
768 if (ctx
->ExecuteFlag
) {
769 (*ctx
->Exec
.CallList
)( ctx
, list
);
774 static void save_CallLists( GLcontext
*ctx
,
775 GLsizei n
, GLenum type
, const GLvoid
*lists
)
778 FLUSH_VB(ctx
, "dlist");
781 GLuint list
= translate_id( i
, type
, lists
);
782 Node
*n
= alloc_instruction( ctx
, OPCODE_CALL_LIST_OFFSET
, 1 );
787 if (ctx
->ExecuteFlag
) {
788 (*ctx
->Exec
.CallLists
)( ctx
, n
, type
, lists
);
793 static void save_Clear( GLcontext
*ctx
, GLbitfield mask
)
796 FLUSH_VB(ctx
, "dlist");
797 n
= alloc_instruction( ctx
, OPCODE_CLEAR
, 1 );
801 if (ctx
->ExecuteFlag
) {
802 (*ctx
->Exec
.Clear
)( ctx
, mask
);
807 static void save_ClearAccum( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
808 GLfloat blue
, GLfloat alpha
)
811 FLUSH_VB(ctx
, "dlist");
812 n
= alloc_instruction( ctx
, OPCODE_CLEAR_ACCUM
, 4 );
819 if (ctx
->ExecuteFlag
) {
820 (*ctx
->Exec
.ClearAccum
)( ctx
, red
, green
, blue
, alpha
);
825 static void save_ClearColor( GLcontext
*ctx
, GLclampf red
, GLclampf green
,
826 GLclampf blue
, GLclampf alpha
)
829 FLUSH_VB(ctx
, "dlist");
830 n
= alloc_instruction( ctx
, OPCODE_CLEAR_COLOR
, 4 );
837 if (ctx
->ExecuteFlag
) {
838 (*ctx
->Exec
.ClearColor
)( ctx
, red
, green
, blue
, alpha
);
843 static void save_ClearDepth( GLcontext
*ctx
, GLclampd depth
)
846 FLUSH_VB(ctx
, "dlist");
847 n
= alloc_instruction( ctx
, OPCODE_CLEAR_DEPTH
, 1 );
849 n
[1].f
= (GLfloat
) depth
;
851 if (ctx
->ExecuteFlag
) {
852 (*ctx
->Exec
.ClearDepth
)( ctx
, depth
);
857 static void save_ClearIndex( GLcontext
*ctx
, GLfloat c
)
860 FLUSH_VB(ctx
, "dlist");
861 n
= alloc_instruction( ctx
, OPCODE_CLEAR_INDEX
, 1 );
865 if (ctx
->ExecuteFlag
) {
866 (*ctx
->Exec
.ClearIndex
)( ctx
, c
);
871 static void save_ClearStencil( GLcontext
*ctx
, GLint s
)
874 FLUSH_VB(ctx
, "dlist");
875 n
= alloc_instruction( ctx
, OPCODE_CLEAR_STENCIL
, 1 );
879 if (ctx
->ExecuteFlag
) {
880 (*ctx
->Exec
.ClearStencil
)( ctx
, s
);
885 static void save_ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*equ
)
888 FLUSH_VB(ctx
, "dlist");
889 n
= alloc_instruction( ctx
, OPCODE_CLIP_PLANE
, 5 );
897 if (ctx
->ExecuteFlag
) {
898 (*ctx
->Exec
.ClipPlane
)( ctx
, plane
, equ
);
904 static void save_ColorMask( GLcontext
*ctx
, GLboolean red
, GLboolean green
,
905 GLboolean blue
, GLboolean alpha
)
908 FLUSH_VB(ctx
, "dlist");
909 n
= alloc_instruction( ctx
, OPCODE_COLOR_MASK
, 4 );
916 if (ctx
->ExecuteFlag
) {
917 (*ctx
->Exec
.ColorMask
)( ctx
, red
, green
, blue
, alpha
);
922 static void save_ColorMaterial( GLcontext
*ctx
, GLenum face
, GLenum mode
)
925 FLUSH_VB(ctx
, "dlist");
926 n
= alloc_instruction( ctx
, OPCODE_COLOR_MATERIAL
, 2 );
931 if (ctx
->ExecuteFlag
) {
932 (*ctx
->Exec
.ColorMaterial
)( ctx
, face
, mode
);
937 static void save_ColorTable( GLcontext
*ctx
, GLenum target
, GLenum internalFormat
,
938 struct gl_image
*table
)
941 FLUSH_VB(ctx
, "dlist");
942 n
= alloc_instruction( ctx
, OPCODE_COLOR_TABLE
, 3 );
945 n
[2].e
= internalFormat
;
946 n
[3].data
= (GLvoid
*) table
;
948 /* must retain this image */
952 if (ctx
->ExecuteFlag
) {
953 (*ctx
->Exec
.ColorTable
)( ctx
, target
, internalFormat
, table
);
958 static void save_ColorSubTable( GLcontext
*ctx
, GLenum target
,
959 GLsizei start
, struct gl_image
*data
)
962 FLUSH_VB(ctx
, "dlist");
963 n
= alloc_instruction( ctx
, OPCODE_COLOR_SUB_TABLE
, 3 );
967 n
[3].data
= (GLvoid
*) data
;
969 /* must retain this image */
973 if (ctx
->ExecuteFlag
) {
974 (*ctx
->Exec
.ColorSubTable
)( ctx
, target
, start
, data
);
980 static void save_CopyPixels( GLcontext
*ctx
, GLint x
, GLint y
,
981 GLsizei width
, GLsizei height
, GLenum type
)
984 FLUSH_VB(ctx
, "dlist");
985 n
= alloc_instruction( ctx
, OPCODE_COPY_PIXELS
, 5 );
989 n
[3].i
= (GLint
) width
;
990 n
[4].i
= (GLint
) height
;
993 if (ctx
->ExecuteFlag
) {
994 (*ctx
->Exec
.CopyPixels
)( ctx
, x
, y
, width
, height
, type
);
1000 static void save_CopyTexImage1D( GLcontext
*ctx
,
1001 GLenum target
, GLint level
,
1002 GLenum internalformat
,
1003 GLint x
, GLint y
, GLsizei width
,
1007 FLUSH_VB(ctx
, "dlist");
1008 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE1D
, 7 );
1012 n
[3].e
= internalformat
;
1018 if (ctx
->ExecuteFlag
) {
1019 (*ctx
->Exec
.CopyTexImage1D
)( ctx
, target
, level
, internalformat
,
1020 x
, y
, width
, border
);
1025 static void save_CopyTexImage2D( GLcontext
*ctx
,
1026 GLenum target
, GLint level
,
1027 GLenum internalformat
,
1028 GLint x
, GLint y
, GLsizei width
,
1029 GLsizei height
, GLint border
)
1032 FLUSH_VB(ctx
, "dlist");
1033 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE2D
, 8 );
1037 n
[3].e
= internalformat
;
1044 if (ctx
->ExecuteFlag
) {
1045 (*ctx
->Exec
.CopyTexImage2D
)( ctx
, target
, level
, internalformat
,
1046 x
, y
, width
, height
, border
);
1052 static void save_CopyTexSubImage1D( GLcontext
*ctx
,
1053 GLenum target
, GLint level
,
1054 GLint xoffset
, GLint x
, GLint y
,
1058 FLUSH_VB(ctx
, "dlist");
1059 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE1D
, 6 );
1068 if (ctx
->ExecuteFlag
) {
1069 (*ctx
->Exec
.CopyTexSubImage1D
)( ctx
, target
, level
, xoffset
, x
, y
, width
);
1074 static void save_CopyTexSubImage2D( GLcontext
*ctx
,
1075 GLenum target
, GLint level
,
1076 GLint xoffset
, GLint yoffset
,
1078 GLsizei width
, GLint height
)
1081 FLUSH_VB(ctx
, "dlist");
1082 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE2D
, 8 );
1093 if (ctx
->ExecuteFlag
) {
1094 (*ctx
->Exec
.CopyTexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
1095 x
, y
, width
, height
);
1100 static void save_CopyTexSubImage3DEXT( GLcontext
*ctx
,
1101 GLenum target
, GLint level
,
1102 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1104 GLsizei width
, GLint height
)
1107 FLUSH_VB(ctx
, "dlist");
1108 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE3D
, 9 );
1120 if (ctx
->ExecuteFlag
) {
1121 (*ctx
->Exec
.CopyTexSubImage3DEXT
)( ctx
, target
, level
, xoffset
, yoffset
, zoffset
,
1122 x
, y
, width
, height
);
1127 static void save_CullFace( GLcontext
*ctx
, GLenum mode
)
1130 FLUSH_VB(ctx
, "dlist");
1131 n
= alloc_instruction( ctx
, OPCODE_CULL_FACE
, 1 );
1135 if (ctx
->ExecuteFlag
) {
1136 (*ctx
->Exec
.CullFace
)( ctx
, mode
);
1141 static void save_DepthFunc( GLcontext
*ctx
, GLenum func
)
1144 FLUSH_VB(ctx
, "dlist");
1145 n
= alloc_instruction( ctx
, OPCODE_DEPTH_FUNC
, 1 );
1149 if (ctx
->ExecuteFlag
) {
1150 (*ctx
->Exec
.DepthFunc
)( ctx
, func
);
1155 static void save_DepthMask( GLcontext
*ctx
, GLboolean mask
)
1158 FLUSH_VB(ctx
, "dlist");
1159 n
= alloc_instruction( ctx
, OPCODE_DEPTH_MASK
, 1 );
1163 if (ctx
->ExecuteFlag
) {
1164 (*ctx
->Exec
.DepthMask
)( ctx
, mask
);
1169 static void save_DepthRange( GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
)
1172 FLUSH_VB(ctx
, "dlist");
1173 n
= alloc_instruction( ctx
, OPCODE_DEPTH_RANGE
, 2 );
1175 n
[1].f
= (GLfloat
) nearval
;
1176 n
[2].f
= (GLfloat
) farval
;
1178 if (ctx
->ExecuteFlag
) {
1179 (*ctx
->Exec
.DepthRange
)( ctx
, nearval
, farval
);
1184 static void save_Disable( GLcontext
*ctx
, GLenum cap
)
1187 FLUSH_VB(ctx
, "dlist");
1188 n
= alloc_instruction( ctx
, OPCODE_DISABLE
, 1 );
1192 if (ctx
->ExecuteFlag
) {
1193 (*ctx
->Exec
.Disable
)( ctx
, cap
);
1198 static void save_DrawBuffer( GLcontext
*ctx
, GLenum mode
)
1201 FLUSH_VB(ctx
, "dlist");
1202 n
= alloc_instruction( ctx
, OPCODE_DRAW_BUFFER
, 1 );
1206 if (ctx
->ExecuteFlag
) {
1207 (*ctx
->Exec
.DrawBuffer
)( ctx
, mode
);
1212 static void save_DrawPixels( GLcontext
*ctx
, struct gl_image
*image
)
1215 FLUSH_VB(ctx
, "dlist");
1216 n
= alloc_instruction( ctx
, OPCODE_DRAW_PIXELS
, 1 );
1218 n
[1].data
= (GLvoid
*) image
;
1221 image
->RefCount
= 1;
1223 if (ctx
->ExecuteFlag
) {
1224 (*ctx
->Exec
.DrawPixels
)( ctx
, image
);
1230 static void save_Enable( GLcontext
*ctx
, GLenum cap
)
1233 FLUSH_VB(ctx
, "dlist");
1234 n
= alloc_instruction( ctx
, OPCODE_ENABLE
, 1 );
1238 if (ctx
->ExecuteFlag
) {
1239 (*ctx
->Exec
.Enable
)( ctx
, cap
);
1245 static void save_EvalMesh1( GLcontext
*ctx
,
1246 GLenum mode
, GLint i1
, GLint i2
)
1249 FLUSH_VB(ctx
, "dlist");
1250 n
= alloc_instruction( ctx
, OPCODE_EVALMESH1
, 3 );
1256 if (ctx
->ExecuteFlag
) {
1257 (*ctx
->Exec
.EvalMesh1
)( ctx
, mode
, i1
, i2
);
1262 static void save_EvalMesh2( GLcontext
*ctx
,
1263 GLenum mode
, GLint i1
, GLint i2
, GLint j1
, GLint j2
)
1266 FLUSH_VB(ctx
, "dlist");
1267 n
= alloc_instruction( ctx
, OPCODE_EVALMESH2
, 5 );
1275 if (ctx
->ExecuteFlag
) {
1276 (*ctx
->Exec
.EvalMesh2
)( ctx
, mode
, i1
, i2
, j1
, j2
);
1283 static void save_Fogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
)
1286 FLUSH_VB(ctx
, "dlist");
1287 n
= alloc_instruction( ctx
, OPCODE_FOG
, 5 );
1295 if (ctx
->ExecuteFlag
) {
1296 (*ctx
->Exec
.Fogfv
)( ctx
, pname
, params
);
1301 static void save_FrontFace( GLcontext
*ctx
, GLenum mode
)
1304 FLUSH_VB(ctx
, "dlist");
1305 n
= alloc_instruction( ctx
, OPCODE_FRONT_FACE
, 1 );
1309 if (ctx
->ExecuteFlag
) {
1310 (*ctx
->Exec
.FrontFace
)( ctx
, mode
);
1315 static void save_Frustum( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1316 GLdouble bottom
, GLdouble top
,
1317 GLdouble nearval
, GLdouble farval
)
1320 FLUSH_VB(ctx
, "dlist");
1321 n
= alloc_instruction( ctx
, OPCODE_FRUSTUM
, 6 );
1330 if (ctx
->ExecuteFlag
) {
1331 (*ctx
->Exec
.Frustum
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1336 static GLboolean
save_Hint( GLcontext
*ctx
, GLenum target
, GLenum mode
)
1339 FLUSH_VB(ctx
, "dlist");
1340 n
= alloc_instruction( ctx
, OPCODE_HINT
, 2 );
1345 if (ctx
->ExecuteFlag
) {
1346 return (*ctx
->Exec
.Hint
)( ctx
, target
, mode
);
1348 return GL_TRUE
; /* not queried */
1353 static void save_IndexMask( GLcontext
*ctx
, GLuint mask
)
1356 FLUSH_VB(ctx
, "dlist");
1357 n
= alloc_instruction( ctx
, OPCODE_INDEX_MASK
, 1 );
1361 if (ctx
->ExecuteFlag
) {
1362 (*ctx
->Exec
.IndexMask
)( ctx
, mask
);
1367 static void save_InitNames( GLcontext
*ctx
)
1369 FLUSH_VB(ctx
, "dlist");
1370 (void) alloc_instruction( ctx
, OPCODE_INIT_NAMES
, 0 );
1371 if (ctx
->ExecuteFlag
) {
1372 (*ctx
->Exec
.InitNames
)( ctx
);
1377 static void save_Lightfv( GLcontext
*ctx
, GLenum light
, GLenum pname
,
1378 const GLfloat
*params
, GLint numparams
)
1381 FLUSH_VB(ctx
, "dlist");
1382 n
= alloc_instruction( ctx
, OPCODE_LIGHT
, 6 );
1387 for (i
=0;i
<numparams
;i
++) {
1388 n
[3+i
].f
= params
[i
];
1391 if (ctx
->ExecuteFlag
) {
1392 (*ctx
->Exec
.Lightfv
)( ctx
, light
, pname
, params
, numparams
);
1397 static void save_LightModelfv( GLcontext
*ctx
,
1398 GLenum pname
, const GLfloat
*params
)
1401 FLUSH_VB(ctx
, "dlist");
1402 n
= alloc_instruction( ctx
, OPCODE_LIGHT_MODEL
, 5 );
1410 if (ctx
->ExecuteFlag
) {
1411 (*ctx
->Exec
.LightModelfv
)( ctx
, pname
, params
);
1416 static void save_LineStipple( GLcontext
*ctx
, GLint factor
, GLushort pattern
)
1419 FLUSH_VB(ctx
, "dlist");
1420 n
= alloc_instruction( ctx
, OPCODE_LINE_STIPPLE
, 2 );
1425 if (ctx
->ExecuteFlag
) {
1426 (*ctx
->Exec
.LineStipple
)( ctx
, factor
, pattern
);
1431 static void save_LineWidth( GLcontext
*ctx
, GLfloat width
)
1434 FLUSH_VB(ctx
, "dlist");
1435 n
= alloc_instruction( ctx
, OPCODE_LINE_WIDTH
, 1 );
1439 if (ctx
->ExecuteFlag
) {
1440 (*ctx
->Exec
.LineWidth
)( ctx
, width
);
1445 static void save_ListBase( GLcontext
*ctx
, GLuint base
)
1448 FLUSH_VB(ctx
, "dlist");
1449 n
= alloc_instruction( ctx
, OPCODE_LIST_BASE
, 1 );
1453 if (ctx
->ExecuteFlag
) {
1454 (*ctx
->Exec
.ListBase
)( ctx
, base
);
1459 static void save_LoadIdentity( GLcontext
*ctx
)
1461 FLUSH_VB(ctx
, "dlist");
1462 (void) alloc_instruction( ctx
, OPCODE_LOAD_IDENTITY
, 0 );
1463 if (ctx
->ExecuteFlag
) {
1464 (*ctx
->Exec
.LoadIdentity
)( ctx
);
1469 static void save_LoadMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1472 FLUSH_VB(ctx
, "dlist");
1473 n
= alloc_instruction( ctx
, OPCODE_LOAD_MATRIX
, 16 );
1476 for (i
=0;i
<16;i
++) {
1480 if (ctx
->ExecuteFlag
) {
1481 (*ctx
->Exec
.LoadMatrixf
)( ctx
, m
);
1486 static void save_LoadName( GLcontext
*ctx
, GLuint name
)
1489 FLUSH_VB(ctx
, "dlist");
1490 n
= alloc_instruction( ctx
, OPCODE_LOAD_NAME
, 1 );
1494 if (ctx
->ExecuteFlag
) {
1495 (*ctx
->Exec
.LoadName
)( ctx
, name
);
1500 static void save_LogicOp( GLcontext
*ctx
, GLenum opcode
)
1503 FLUSH_VB(ctx
, "dlist");
1504 n
= alloc_instruction( ctx
, OPCODE_LOGIC_OP
, 1 );
1508 if (ctx
->ExecuteFlag
) {
1509 (*ctx
->Exec
.LogicOp
)( ctx
, opcode
);
1514 static void save_Map1f( GLcontext
*ctx
,
1515 GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
1516 GLint order
, const GLfloat
*points
, GLboolean retain
)
1519 FLUSH_VB(ctx
, "dlist");
1520 n
= alloc_instruction( ctx
, OPCODE_MAP1
, 6 );
1527 n
[6].data
= (void *) points
;
1529 if (ctx
->ExecuteFlag
) {
1530 (*ctx
->Exec
.Map1f
)( ctx
, target
, u1
, u2
, stride
, order
, points
, GL_TRUE
);
1536 static void save_Map2f( GLcontext
*ctx
, GLenum target
,
1537 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
1538 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
1539 const GLfloat
*points
, GLboolean retain
)
1542 FLUSH_VB(ctx
, "dlist");
1543 n
= alloc_instruction( ctx
, OPCODE_MAP2
, 10 );
1554 n
[10].data
= (void *) points
;
1556 if (ctx
->ExecuteFlag
) {
1557 (*ctx
->Exec
.Map2f
)( ctx
, target
,
1558 u1
, u2
, ustride
, uorder
,
1559 v1
, v2
, vstride
, vorder
, points
, GL_TRUE
);
1565 static void save_MapGrid1f( GLcontext
*ctx
, GLint un
, GLfloat u1
, GLfloat u2
)
1568 FLUSH_VB(ctx
, "dlist");
1569 n
= alloc_instruction( ctx
, OPCODE_MAPGRID1
, 3 );
1575 if (ctx
->ExecuteFlag
) {
1576 (*ctx
->Exec
.MapGrid1f
)( ctx
, un
, u1
, u2
);
1581 static void save_MapGrid2f( GLcontext
*ctx
,
1582 GLint un
, GLfloat u1
, GLfloat u2
,
1583 GLint vn
, GLfloat v1
, GLfloat v2
)
1586 FLUSH_VB(ctx
, "dlist");
1587 n
= alloc_instruction( ctx
, OPCODE_MAPGRID2
, 6 );
1596 if (ctx
->ExecuteFlag
) {
1597 (*ctx
->Exec
.MapGrid2f
)( ctx
, un
, u1
, u2
, vn
, v1
, v2
);
1602 static void save_MatrixMode( GLcontext
*ctx
, GLenum mode
)
1605 FLUSH_VB(ctx
, "dlist");
1606 n
= alloc_instruction( ctx
, OPCODE_MATRIX_MODE
, 1 );
1610 if (ctx
->ExecuteFlag
) {
1611 (*ctx
->Exec
.MatrixMode
)( ctx
, mode
);
1616 static void save_MultMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1619 FLUSH_VB(ctx
, "dlist");
1620 n
= alloc_instruction( ctx
, OPCODE_MULT_MATRIX
, 16 );
1623 for (i
=0;i
<16;i
++) {
1627 if (ctx
->ExecuteFlag
) {
1628 (*ctx
->Exec
.MultMatrixf
)( ctx
, m
);
1633 static void save_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
1635 /* It's an error to call this function while building a display list */
1636 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
1643 static void save_Ortho( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1644 GLdouble bottom
, GLdouble top
,
1645 GLdouble nearval
, GLdouble farval
)
1648 FLUSH_VB(ctx
, "dlist");
1649 n
= alloc_instruction( ctx
, OPCODE_ORTHO
, 6 );
1658 if (ctx
->ExecuteFlag
) {
1659 (*ctx
->Exec
.Ortho
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1664 static void save_PixelMapfv( GLcontext
*ctx
,
1665 GLenum map
, GLint mapsize
, const GLfloat
*values
)
1668 FLUSH_VB(ctx
, "dlist");
1669 n
= alloc_instruction( ctx
, OPCODE_PIXEL_MAP
, 3 );
1673 n
[3].data
= (void *) MALLOC( mapsize
* sizeof(GLfloat
) );
1674 MEMCPY( n
[3].data
, (void *) values
, mapsize
* sizeof(GLfloat
) );
1676 if (ctx
->ExecuteFlag
) {
1677 (*ctx
->Exec
.PixelMapfv
)( ctx
, map
, mapsize
, values
);
1682 static void save_PixelTransferf( GLcontext
*ctx
, GLenum pname
, GLfloat param
)
1685 FLUSH_VB(ctx
, "dlist");
1686 n
= alloc_instruction( ctx
, OPCODE_PIXEL_TRANSFER
, 2 );
1691 if (ctx
->ExecuteFlag
) {
1692 (*ctx
->Exec
.PixelTransferf
)( ctx
, pname
, param
);
1697 static void save_PixelZoom( GLcontext
*ctx
, GLfloat xfactor
, GLfloat yfactor
)
1700 FLUSH_VB(ctx
, "dlist");
1701 n
= alloc_instruction( ctx
, OPCODE_PIXEL_ZOOM
, 2 );
1706 if (ctx
->ExecuteFlag
) {
1707 (*ctx
->Exec
.PixelZoom
)( ctx
, xfactor
, yfactor
);
1712 static void save_PointParameterfvEXT( GLcontext
*ctx
, GLenum pname
,
1713 const GLfloat
*params
)
1716 FLUSH_VB(ctx
, "dlist");
1717 n
= alloc_instruction( ctx
, OPCODE_POINT_PARAMETERS
, 4 );
1724 if (ctx
->ExecuteFlag
) {
1725 (*ctx
->Exec
.PointParameterfvEXT
)( ctx
, pname
, params
);
1730 static void save_PointSize( GLcontext
*ctx
, GLfloat size
)
1733 FLUSH_VB(ctx
, "dlist");
1734 n
= alloc_instruction( ctx
, OPCODE_POINT_SIZE
, 1 );
1738 if (ctx
->ExecuteFlag
) {
1739 (*ctx
->Exec
.PointSize
)( ctx
, size
);
1744 static void save_PolygonMode( GLcontext
*ctx
, GLenum face
, GLenum mode
)
1747 FLUSH_VB(ctx
, "dlist");
1748 n
= alloc_instruction( ctx
, OPCODE_POLYGON_MODE
, 2 );
1753 if (ctx
->ExecuteFlag
) {
1754 (*ctx
->Exec
.PolygonMode
)( ctx
, face
, mode
);
1760 * Polygon stipple must have been upacked already!
1762 static void save_PolygonStipple( GLcontext
*ctx
, const GLuint
*pattern
)
1765 FLUSH_VB(ctx
, "dlist");
1766 n
= alloc_instruction( ctx
, OPCODE_POLYGON_STIPPLE
, 1 );
1769 n
[1].data
= MALLOC( 32 * 4 );
1770 data
= n
[1].data
; /* This needed for Acorn compiler */
1771 MEMCPY( data
, pattern
, 32 * 4 );
1773 if (ctx
->ExecuteFlag
) {
1774 (*ctx
->Exec
.PolygonStipple
)( ctx
, pattern
);
1779 static void save_PolygonOffset( GLcontext
*ctx
, GLfloat factor
, GLfloat units
)
1782 FLUSH_VB(ctx
, "dlist");
1783 n
= alloc_instruction( ctx
, OPCODE_POLYGON_OFFSET
, 2 );
1788 if (ctx
->ExecuteFlag
) {
1789 (*ctx
->Exec
.PolygonOffset
)( ctx
, factor
, units
);
1794 static void save_PopAttrib( GLcontext
*ctx
)
1796 FLUSH_VB(ctx
, "dlist");
1797 (void) alloc_instruction( ctx
, OPCODE_POP_ATTRIB
, 0 );
1798 if (ctx
->ExecuteFlag
) {
1799 (*ctx
->Exec
.PopAttrib
)( ctx
);
1804 static void save_PopMatrix( GLcontext
*ctx
)
1806 FLUSH_VB(ctx
, "dlist");
1807 (void) alloc_instruction( ctx
, OPCODE_POP_MATRIX
, 0 );
1808 if (ctx
->ExecuteFlag
) {
1809 (*ctx
->Exec
.PopMatrix
)( ctx
);
1814 static void save_PopName( GLcontext
*ctx
)
1816 FLUSH_VB(ctx
, "dlist");
1817 (void) alloc_instruction( ctx
, OPCODE_POP_NAME
, 0 );
1818 if (ctx
->ExecuteFlag
) {
1819 (*ctx
->Exec
.PopName
)( ctx
);
1824 static void save_PrioritizeTextures( GLcontext
*ctx
,
1825 GLsizei num
, const GLuint
*textures
,
1826 const GLclampf
*priorities
)
1829 FLUSH_VB(ctx
, "dlist");
1831 for (i
=0;i
<num
;i
++) {
1833 n
= alloc_instruction( ctx
, OPCODE_PRIORITIZE_TEXTURE
, 2 );
1835 n
[1].ui
= textures
[i
];
1836 n
[2].f
= priorities
[i
];
1839 if (ctx
->ExecuteFlag
) {
1840 (*ctx
->Exec
.PrioritizeTextures
)( ctx
, num
, textures
, priorities
);
1845 static void save_PushAttrib( GLcontext
*ctx
, GLbitfield mask
)
1848 FLUSH_VB(ctx
, "dlist");
1849 n
= alloc_instruction( ctx
, OPCODE_PUSH_ATTRIB
, 1 );
1853 if (ctx
->ExecuteFlag
) {
1854 (*ctx
->Exec
.PushAttrib
)( ctx
, mask
);
1859 static void save_PushMatrix( GLcontext
*ctx
)
1861 FLUSH_VB(ctx
, "dlist");
1862 (void) alloc_instruction( ctx
, OPCODE_PUSH_MATRIX
, 0 );
1863 if (ctx
->ExecuteFlag
) {
1864 (*ctx
->Exec
.PushMatrix
)( ctx
);
1869 static void save_PushName( GLcontext
*ctx
, GLuint name
)
1872 FLUSH_VB(ctx
, "dlist");
1873 n
= alloc_instruction( ctx
, OPCODE_PUSH_NAME
, 1 );
1877 if (ctx
->ExecuteFlag
) {
1878 (*ctx
->Exec
.PushName
)( ctx
, name
);
1883 static void save_RasterPos4f( GLcontext
*ctx
,
1884 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
1887 FLUSH_VB(ctx
, "dlist");
1888 n
= alloc_instruction( ctx
, OPCODE_RASTER_POS
, 4 );
1895 if (ctx
->ExecuteFlag
) {
1896 (*ctx
->Exec
.RasterPos4f
)( ctx
, x
, y
, z
, w
);
1901 static void save_PassThrough( GLcontext
*ctx
, GLfloat token
)
1904 FLUSH_VB(ctx
, "dlist");
1905 n
= alloc_instruction( ctx
, OPCODE_PASSTHROUGH
, 1 );
1909 if (ctx
->ExecuteFlag
) {
1910 (*ctx
->Exec
.PassThrough
)( ctx
, token
);
1915 static void save_ReadBuffer( GLcontext
*ctx
, GLenum mode
)
1918 FLUSH_VB(ctx
, "dlist");
1919 n
= alloc_instruction( ctx
, OPCODE_READ_BUFFER
, 1 );
1923 if (ctx
->ExecuteFlag
) {
1924 (*ctx
->Exec
.ReadBuffer
)( ctx
, mode
);
1929 static void save_Rectf( GLcontext
*ctx
,
1930 GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
1933 FLUSH_VB(ctx
, "dlist");
1934 n
= alloc_instruction( ctx
, OPCODE_RECTF
, 4 );
1941 if (ctx
->ExecuteFlag
) {
1942 (*ctx
->Exec
.Rectf
)( ctx
, x1
, y1
, x2
, y2
);
1947 static void save_Rotatef( GLcontext
*ctx
, GLfloat angle
,
1948 GLfloat x
, GLfloat y
, GLfloat z
)
1951 gl_rotation_matrix( angle
, x
, y
, z
, m
);
1952 save_MultMatrixf( ctx
, m
); /* save and maybe execute */
1956 static void save_Scalef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
1959 FLUSH_VB(ctx
, "dlist");
1960 n
= alloc_instruction( ctx
, OPCODE_SCALE
, 3 );
1966 if (ctx
->ExecuteFlag
) {
1967 (*ctx
->Exec
.Scalef
)( ctx
, x
, y
, z
);
1972 static void save_Scissor( GLcontext
*ctx
,
1973 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1976 FLUSH_VB(ctx
, "dlist");
1977 n
= alloc_instruction( ctx
, OPCODE_SCISSOR
, 4 );
1984 if (ctx
->ExecuteFlag
) {
1985 (*ctx
->Exec
.Scissor
)( ctx
, x
, y
, width
, height
);
1990 static void save_ShadeModel( GLcontext
*ctx
, GLenum mode
)
1993 FLUSH_VB(ctx
, "dlist");
1994 n
= alloc_instruction( ctx
, OPCODE_SHADE_MODEL
, 1 );
1998 if (ctx
->ExecuteFlag
) {
1999 (*ctx
->Exec
.ShadeModel
)( ctx
, mode
);
2004 static void save_StencilFunc( GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
)
2007 FLUSH_VB(ctx
, "dlist");
2008 n
= alloc_instruction( ctx
, OPCODE_STENCIL_FUNC
, 3 );
2014 if (ctx
->ExecuteFlag
) {
2015 (*ctx
->Exec
.StencilFunc
)( ctx
, func
, ref
, mask
);
2020 static void save_StencilMask( GLcontext
*ctx
, GLuint mask
)
2023 FLUSH_VB(ctx
, "dlist");
2024 n
= alloc_instruction( ctx
, OPCODE_STENCIL_MASK
, 1 );
2028 if (ctx
->ExecuteFlag
) {
2029 (*ctx
->Exec
.StencilMask
)( ctx
, mask
);
2034 static void save_StencilOp( GLcontext
*ctx
,
2035 GLenum fail
, GLenum zfail
, GLenum zpass
)
2038 FLUSH_VB(ctx
, "dlist");
2039 n
= alloc_instruction( ctx
, OPCODE_STENCIL_OP
, 3 );
2045 if (ctx
->ExecuteFlag
) {
2046 (*ctx
->Exec
.StencilOp
)( ctx
, fail
, zfail
, zpass
);
2053 static void save_TexEnvfv( GLcontext
*ctx
,
2054 GLenum target
, GLenum pname
, const GLfloat
*params
)
2057 FLUSH_VB(ctx
, "dlist");
2058 n
= alloc_instruction( ctx
, OPCODE_TEXENV
, 6 );
2067 if (ctx
->ExecuteFlag
) {
2068 (*ctx
->Exec
.TexEnvfv
)( ctx
, target
, pname
, params
);
2073 static void save_TexGenfv( GLcontext
*ctx
,
2074 GLenum coord
, GLenum pname
, const GLfloat
*params
)
2077 FLUSH_VB(ctx
, "dlist");
2078 n
= alloc_instruction( ctx
, OPCODE_TEXGEN
, 6 );
2087 if (ctx
->ExecuteFlag
) {
2088 (*ctx
->Exec
.TexGenfv
)( ctx
, coord
, pname
, params
);
2093 static void save_TexParameterfv( GLcontext
*ctx
, GLenum target
,
2094 GLenum pname
, const GLfloat
*params
)
2097 FLUSH_VB(ctx
, "dlist");
2098 n
= alloc_instruction( ctx
, OPCODE_TEXPARAMETER
, 6 );
2107 if (ctx
->ExecuteFlag
) {
2108 (*ctx
->Exec
.TexParameterfv
)( ctx
, target
, pname
, params
);
2113 static void save_TexImage1D( GLcontext
*ctx
, GLenum target
,
2114 GLint level
, GLint components
,
2115 GLsizei width
, GLint border
,
2116 GLenum format
, GLenum type
,
2117 struct gl_image
*teximage
)
2120 FLUSH_VB(ctx
, "dlist");
2121 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE1D
, 8 );
2125 n
[3].i
= components
;
2126 n
[4].i
= (GLint
) width
;
2130 n
[8].data
= teximage
;
2132 /* this prevents gl_TexImage2D() from freeing the image */
2133 teximage
->RefCount
= 1;
2136 if (ctx
->ExecuteFlag
) {
2137 (*ctx
->Exec
.TexImage1D
)( ctx
, target
, level
, components
, width
,
2138 border
, format
, type
, teximage
);
2143 static void save_TexImage2D( GLcontext
*ctx
, GLenum target
,
2144 GLint level
, GLint components
,
2145 GLsizei width
, GLsizei height
, GLint border
,
2146 GLenum format
, GLenum type
,
2147 struct gl_image
*teximage
)
2150 FLUSH_VB(ctx
, "dlist");
2151 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE2D
, 9 );
2155 n
[3].i
= components
;
2156 n
[4].i
= (GLint
) width
;
2157 n
[5].i
= (GLint
) height
;
2161 n
[9].data
= teximage
;
2163 /* this prevents gl_TexImage2D() from freeing the image */
2164 teximage
->RefCount
= 1;
2167 if (ctx
->ExecuteFlag
) {
2168 (*ctx
->Exec
.TexImage2D
)( ctx
, target
, level
, components
, width
,
2169 height
, border
, format
, type
, teximage
);
2174 static void save_TexImage3DEXT( GLcontext
*ctx
, GLenum target
,
2175 GLint level
, GLint components
,
2176 GLsizei width
, GLsizei height
, GLsizei depth
,
2178 GLenum format
, GLenum type
,
2179 struct gl_image
*teximage
)
2182 FLUSH_VB(ctx
, "dlist");
2183 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE3D
, 10 );
2187 n
[3].i
= components
;
2188 n
[4].i
= (GLint
) width
;
2189 n
[5].i
= (GLint
) height
;
2190 n
[6].i
= (GLint
) depth
;
2194 n
[10].data
= teximage
;
2196 /* this prevents gl_TexImage3D() from freeing the image */
2197 teximage
->RefCount
= 1;
2200 if (ctx
->ExecuteFlag
) {
2201 (*ctx
->Exec
.TexImage3DEXT
)( ctx
, target
, level
, components
, width
,
2202 height
, depth
, border
, format
, type
, teximage
);
2207 static void save_TexSubImage1D( GLcontext
*ctx
,
2208 GLenum target
, GLint level
, GLint xoffset
,
2209 GLsizei width
, GLenum format
, GLenum type
,
2210 struct gl_image
*image
)
2213 FLUSH_VB(ctx
, "dlist");
2214 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE1D
, 7 );
2219 n
[4].i
= (GLint
) width
;
2224 image
->RefCount
= 1;
2226 if (ctx
->ExecuteFlag
) {
2227 (*ctx
->Exec
.TexSubImage1D
)( ctx
, target
, level
, xoffset
, width
,
2228 format
, type
, image
);
2233 static void save_TexSubImage2D( GLcontext
*ctx
,
2234 GLenum target
, GLint level
,
2235 GLint xoffset
, GLint yoffset
,
2236 GLsizei width
, GLsizei height
,
2237 GLenum format
, GLenum type
,
2238 struct gl_image
*image
)
2241 FLUSH_VB(ctx
, "dlist");
2242 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE2D
, 9 );
2248 n
[5].i
= (GLint
) width
;
2249 n
[6].i
= (GLint
) height
;
2254 image
->RefCount
= 1;
2256 if (ctx
->ExecuteFlag
) {
2257 (*ctx
->Exec
.TexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
2258 width
, height
, format
, type
, image
);
2263 static void save_TexSubImage3DEXT( GLcontext
*ctx
,
2264 GLenum target
, GLint level
,
2265 GLint xoffset
, GLint yoffset
,GLint zoffset
,
2266 GLsizei width
, GLsizei height
, GLsizei depth
,
2267 GLenum format
, GLenum type
,
2268 struct gl_image
*image
)
2271 FLUSH_VB(ctx
, "dlist");
2272 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE3D
, 11 );
2279 n
[6].i
= (GLint
) width
;
2280 n
[7].i
= (GLint
) height
;
2281 n
[8].i
= (GLint
) depth
;
2286 image
->RefCount
= 1;
2288 if (ctx
->ExecuteFlag
) {
2289 (*ctx
->Exec
.TexSubImage3DEXT
)( ctx
, target
, level
, xoffset
, yoffset
, zoffset
,
2290 width
, height
, depth
, format
, type
, image
);
2295 static void save_Translatef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
2298 FLUSH_VB(ctx
, "dlist");
2299 n
= alloc_instruction( ctx
, OPCODE_TRANSLATE
, 3 );
2305 if (ctx
->ExecuteFlag
) {
2306 (*ctx
->Exec
.Translatef
)( ctx
, x
, y
, z
);
2312 static void save_Viewport( GLcontext
*ctx
,
2313 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
2316 FLUSH_VB(ctx
, "dlist");
2317 n
= alloc_instruction( ctx
, OPCODE_VIEWPORT
, 4 );
2321 n
[3].i
= (GLint
) width
;
2322 n
[4].i
= (GLint
) height
;
2324 if (ctx
->ExecuteFlag
) {
2325 (*ctx
->Exec
.Viewport
)( ctx
, x
, y
, width
, height
);
2330 static void save_WindowPos4fMESA( GLcontext
*ctx
,
2331 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
2334 FLUSH_VB(ctx
, "dlist");
2335 n
= alloc_instruction( ctx
, OPCODE_WINDOW_POS
, 4 );
2342 if (ctx
->ExecuteFlag
) {
2343 (*ctx
->Exec
.WindowPos4fMESA
)( ctx
, x
, y
, z
, w
);
2352 /* GL_ARB_multitexture */
2353 static void save_ActiveTexture( GLcontext
*ctx
, GLenum target
)
2356 FLUSH_VB(ctx
, "dlist");
2357 n
= alloc_instruction( ctx
, OPCODE_ACTIVE_TEXTURE
, 1 );
2361 if (ctx
->ExecuteFlag
) {
2362 (*ctx
->Exec
.ActiveTexture
)( ctx
, target
);
2367 /* GL_ARB_multitexture */
2368 static void save_ClientActiveTexture( GLcontext
*ctx
, GLenum target
)
2371 FLUSH_VB(ctx
, "dlist");
2372 n
= alloc_instruction( ctx
, OPCODE_CLIENT_ACTIVE_TEXTURE
, 1 );
2376 if (ctx
->ExecuteFlag
) {
2377 (*ctx
->Exec
.ClientActiveTexture
)( ctx
, target
);
2383 void gl_compile_cassette( GLcontext
*ctx
)
2385 Node
*n
= alloc_instruction( ctx
, OPCODE_VERTEX_CASSETTE
, 8 );
2386 struct immediate
*im
= ctx
->input
;
2392 /* Do some easy optimizations of the cassette.
2395 if (0 && im
->v
.Obj
.size
< 4 && im
->Count
> 15) {
2396 im
->Bounds
= (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat
));
2397 (gl_calc_bound_tab
[im
->v
.Obj
.size
])( im
->Bounds
, &im
->v
.Obj
);
2401 n
[1].data
= (void *)im
;
2402 n
[2].ui
= im
->Start
;
2403 n
[3].ui
= im
->Count
;
2404 n
[4].ui
= im
->BeginState
;
2405 n
[5].ui
= im
->OrFlag
;
2406 n
[6].ui
= im
->AndFlag
;
2407 n
[7].ui
= im
->LastData
;
2408 n
[8].ui
= im
->LastPrimitive
;
2410 if (im
->Count
> VB_MAX
- 4) {
2412 struct immediate
*new_im
= gl_immediate_alloc(ctx
);
2413 if (!new_im
) return;
2414 SET_IMMEDIATE( ctx
, new_im
);
2415 gl_reset_input( ctx
);
2419 im
->Start
= im
->Count
; /* don't clear anything in reset_input */
2422 im
->Primitive
[im
->Start
] = ctx
->Current
.Primitive
;
2423 im
->LastPrimitive
= im
->Start
;
2424 im
->BeginState
= VERT_BEGIN_0
;
2429 fprintf(stderr
, "in compile_cassette, BeginState is %x\n",
2434 /* KW: Compile commands
2436 * Will appear in the list before the vertex buffer containing the
2437 * command that provoked the error. I don't see this as a problem.
2439 void gl_save_error( GLcontext
*ctx
, GLenum error
, const char *s
)
2442 n
= alloc_instruction( ctx
, OPCODE_ERROR
, 2 );
2445 n
[2].data
= (void *) s
;
2447 /* execute already done */
2450 /**********************************************************************/
2451 /* Display list execution */
2452 /**********************************************************************/
2456 * Execute a display list. Note that the ListBase offset must have already
2457 * been added before calling this function. I.e. the list argument is
2458 * the absolute list number, not relative to ListBase.
2459 * Input: list - display list number
2461 static void execute_list( GLcontext
*ctx
, GLuint list
)
2467 if (!gl_IsList(ctx
,list
))
2470 /* mesa_print_display_list( list ); */
2474 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
2478 opcode
= n
[0].opcode
;
2482 gl_error( ctx
, n
[1].e
, (const char *) n
[2].data
);
2484 case OPCODE_VERTEX_CASSETTE
: {
2485 struct immediate
*IM
;
2488 gl_update_state(ctx
);
2489 if (ctx
->CompileCVAFlag
) {
2490 ctx
->CompileCVAFlag
= 0;
2491 ctx
->CVA
.elt
.pipeline_valid
= 0;
2493 if (!ctx
->CVA
.elt
.pipeline_valid
)
2494 gl_build_immediate_pipeline( ctx
);
2497 IM
= (struct immediate
*) n
[1].data
;
2498 IM
->Start
= n
[2].ui
;
2499 IM
->Count
= n
[3].ui
;
2500 IM
->BeginState
= n
[4].ui
;
2501 IM
->OrFlag
= n
[5].ui
;
2502 IM
->AndFlag
= n
[6].ui
;
2503 IM
->LastData
= n
[7].ui
;
2504 IM
->LastPrimitive
= n
[8].ui
;
2506 if ((MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
) &&
2507 (MESA_VERBOSE
& VERBOSE_IMMEDIATE
))
2508 gl_print_cassette( (struct immediate
*) n
[1].data
, 0, ~0 );
2511 fprintf(stderr
, "Run cassette %d, rows %d..%d, beginstate %x\n",
2513 IM
->Start
, IM
->Count
, IM
->BeginState
);
2515 gl_fixup_cassette( ctx
, (struct immediate
*) n
[1].data
);
2516 gl_execute_cassette( ctx
, (struct immediate
*) n
[1].data
);
2520 gl_Accum( ctx
, n
[1].e
, n
[2].f
);
2522 case OPCODE_ALPHA_FUNC
:
2523 gl_AlphaFunc( ctx
, n
[1].e
, n
[2].f
);
2525 case OPCODE_BIND_TEXTURE
:
2526 gl_BindTexture( ctx
, n
[1].e
, n
[2].ui
);
2530 static struct gl_pixelstore_attrib defaultPacking
= {
2535 0, /* ImageHeight */
2537 GL_FALSE
, /* SwapBytes */
2538 GL_FALSE
/* LsbFirst */
2540 const struct gl_image
*image
= (struct gl_image
*) n
[7].data
;
2541 const GLubyte
*bitmap
= image
? image
->Data
: NULL
;
2542 gl_Bitmap( ctx
, (GLsizei
) n
[1].i
, (GLsizei
) n
[2].i
,
2543 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
,
2544 bitmap
, &defaultPacking
);
2547 case OPCODE_BLEND_COLOR
:
2548 gl_BlendColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2550 case OPCODE_BLEND_EQUATION
:
2551 gl_BlendEquation( ctx
, n
[1].e
);
2553 case OPCODE_BLEND_FUNC
:
2554 gl_BlendFunc( ctx
, n
[1].e
, n
[2].e
);
2556 case OPCODE_BLEND_FUNC_SEPARATE
:
2557 gl_BlendFuncSeparate( ctx
, n
[1].e
, n
[2].e
, n
[3].e
, n
[4].e
);
2559 case OPCODE_CALL_LIST
:
2560 /* Generated by glCallList(), don't add ListBase */
2561 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2562 execute_list( ctx
, n
[1].ui
);
2565 case OPCODE_CALL_LIST_OFFSET
:
2566 /* Generated by glCallLists() so we must add ListBase */
2567 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2568 execute_list( ctx
, ctx
->List
.ListBase
+ n
[1].ui
);
2572 gl_Clear( ctx
, n
[1].bf
);
2574 case OPCODE_CLEAR_COLOR
:
2575 gl_ClearColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2577 case OPCODE_CLEAR_ACCUM
:
2578 gl_ClearAccum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2580 case OPCODE_CLEAR_DEPTH
:
2581 gl_ClearDepth( ctx
, (GLclampd
) n
[1].f
);
2583 case OPCODE_CLEAR_INDEX
:
2584 gl_ClearIndex( ctx
, n
[1].ui
);
2586 case OPCODE_CLEAR_STENCIL
:
2587 gl_ClearStencil( ctx
, n
[1].i
);
2589 case OPCODE_CLIP_PLANE
:
2596 gl_ClipPlane( ctx
, n
[1].e
, equ
);
2599 case OPCODE_COLOR_MASK
:
2600 gl_ColorMask( ctx
, n
[1].b
, n
[2].b
, n
[3].b
, n
[4].b
);
2602 case OPCODE_COLOR_MATERIAL
:
2603 gl_ColorMaterial( ctx
, n
[1].e
, n
[2].e
);
2605 case OPCODE_COLOR_TABLE
:
2606 gl_ColorTable( ctx
, n
[1].e
, n
[2].e
, (struct gl_image
*) n
[3].data
);
2608 case OPCODE_COLOR_SUB_TABLE
:
2609 gl_ColorSubTable( ctx
, n
[1].e
, n
[2].i
,
2610 (struct gl_image
*) n
[3].data
);
2612 case OPCODE_COPY_PIXELS
:
2613 gl_CopyPixels( ctx
, n
[1].i
, n
[2].i
,
2614 (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
, n
[5].e
);
2616 case OPCODE_COPY_TEX_IMAGE1D
:
2617 gl_CopyTexImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2618 n
[5].i
, n
[6].i
, n
[7].i
);
2620 case OPCODE_COPY_TEX_IMAGE2D
:
2621 gl_CopyTexImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2622 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2624 case OPCODE_COPY_TEX_SUB_IMAGE1D
:
2625 gl_CopyTexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2628 case OPCODE_COPY_TEX_SUB_IMAGE2D
:
2629 gl_CopyTexSubImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2630 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2632 case OPCODE_COPY_TEX_SUB_IMAGE3D
:
2633 gl_CopyTexSubImage3DEXT( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2634 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
, n
[9].i
);
2636 case OPCODE_CULL_FACE
:
2637 gl_CullFace( ctx
, n
[1].e
);
2639 case OPCODE_DEPTH_FUNC
:
2640 gl_DepthFunc( ctx
, n
[1].e
);
2642 case OPCODE_DEPTH_MASK
:
2643 gl_DepthMask( ctx
, n
[1].b
);
2645 case OPCODE_DEPTH_RANGE
:
2646 gl_DepthRange( ctx
, (GLclampd
) n
[1].f
, (GLclampd
) n
[2].f
);
2648 case OPCODE_DISABLE
:
2649 gl_Disable( ctx
, n
[1].e
);
2651 case OPCODE_DRAW_BUFFER
:
2652 gl_DrawBuffer( ctx
, n
[1].e
);
2654 case OPCODE_DRAW_PIXELS
:
2655 gl_DrawPixels( ctx
, (struct gl_image
*) n
[1].data
);
2658 gl_Enable( ctx
, n
[1].e
);
2660 case OPCODE_EVALMESH1
:
2661 gl_EvalMesh1( ctx
, n
[1].e
, n
[2].i
, n
[3].i
);
2663 case OPCODE_EVALMESH2
:
2664 gl_EvalMesh2( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
);
2673 gl_Fogfv( ctx
, n
[1].e
, p
);
2676 case OPCODE_FRONT_FACE
:
2677 gl_FrontFace( ctx
, n
[1].e
);
2679 case OPCODE_FRUSTUM
:
2680 gl_Frustum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2683 gl_Hint( ctx
, n
[1].e
, n
[2].e
);
2685 case OPCODE_INDEX_MASK
:
2686 gl_IndexMask( ctx
, n
[1].ui
);
2688 case OPCODE_INIT_NAMES
:
2689 gl_InitNames( ctx
);
2698 gl_Lightfv( ctx
, n
[1].e
, n
[2].e
, p
, 4 );
2701 case OPCODE_LIGHT_MODEL
:
2708 gl_LightModelfv( ctx
, n
[1].e
, p
);
2711 case OPCODE_LINE_STIPPLE
:
2712 gl_LineStipple( ctx
, n
[1].i
, n
[2].us
);
2714 case OPCODE_LINE_WIDTH
:
2715 gl_LineWidth( ctx
, n
[1].f
);
2717 case OPCODE_LIST_BASE
:
2718 gl_ListBase( ctx
, n
[1].ui
);
2720 case OPCODE_LOAD_IDENTITY
:
2721 gl_LoadIdentity( ctx
);
2723 case OPCODE_LOAD_MATRIX
:
2724 if (sizeof(Node
)==sizeof(GLfloat
)) {
2725 gl_LoadMatrixf( ctx
, &n
[1].f
);
2730 for (i
=0;i
<16;i
++) {
2733 gl_LoadMatrixf( ctx
, m
);
2736 case OPCODE_LOAD_NAME
:
2737 gl_LoadName( ctx
, n
[1].ui
);
2739 case OPCODE_LOGIC_OP
:
2740 gl_LogicOp( ctx
, n
[1].e
);
2743 gl_Map1f( ctx
, n
[1].e
, n
[2].f
, n
[3].f
,
2744 n
[4].i
, n
[5].i
, (GLfloat
*) n
[6].data
, GL_TRUE
);
2747 gl_Map2f( ctx
, n
[1].e
,
2748 n
[2].f
, n
[3].f
, /* u1, u2 */
2749 n
[6].i
, n
[8].i
, /* ustride, uorder */
2750 n
[4].f
, n
[5].f
, /* v1, v2 */
2751 n
[7].i
, n
[9].i
, /* vstride, vorder */
2752 (GLfloat
*) n
[10].data
,
2755 case OPCODE_MAPGRID1
:
2756 gl_MapGrid1f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
);
2758 case OPCODE_MAPGRID2
:
2759 gl_MapGrid2f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
, n
[4].i
, n
[5].f
, n
[6].f
);
2761 case OPCODE_MATRIX_MODE
:
2762 gl_MatrixMode( ctx
, n
[1].e
);
2764 case OPCODE_MULT_MATRIX
:
2765 if (sizeof(Node
)==sizeof(GLfloat
)) {
2766 gl_MultMatrixf( ctx
, &n
[1].f
);
2771 for (i
=0;i
<16;i
++) {
2774 gl_MultMatrixf( ctx
, m
);
2778 gl_Ortho( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2780 case OPCODE_PASSTHROUGH
:
2781 gl_PassThrough( ctx
, n
[1].f
);
2783 case OPCODE_PIXEL_MAP
:
2784 gl_PixelMapfv( ctx
, n
[1].e
, n
[2].i
, (GLfloat
*) n
[3].data
);
2786 case OPCODE_PIXEL_TRANSFER
:
2787 gl_PixelTransferf( ctx
, n
[1].e
, n
[2].f
);
2789 case OPCODE_PIXEL_ZOOM
:
2790 gl_PixelZoom( ctx
, n
[1].f
, n
[2].f
);
2792 case OPCODE_POINT_SIZE
:
2793 gl_PointSize( ctx
, n
[1].f
);
2795 case OPCODE_POINT_PARAMETERS
:
2801 gl_PointParameterfvEXT( ctx
, n
[1].e
, params
);
2804 case OPCODE_POLYGON_MODE
:
2805 gl_PolygonMode( ctx
, n
[1].e
, n
[2].e
);
2807 case OPCODE_POLYGON_STIPPLE
:
2808 gl_PolygonStipple( ctx
, (GLuint
*) n
[1].data
);
2810 case OPCODE_POLYGON_OFFSET
:
2811 gl_PolygonOffset( ctx
, n
[1].f
, n
[2].f
);
2813 case OPCODE_POP_ATTRIB
:
2814 gl_PopAttrib( ctx
);
2816 case OPCODE_POP_MATRIX
:
2817 gl_PopMatrix( ctx
);
2819 case OPCODE_POP_NAME
:
2822 case OPCODE_PRIORITIZE_TEXTURE
:
2823 gl_PrioritizeTextures( ctx
, 1, &n
[1].ui
, &n
[2].f
);
2825 case OPCODE_PUSH_ATTRIB
:
2826 gl_PushAttrib( ctx
, n
[1].bf
);
2828 case OPCODE_PUSH_MATRIX
:
2829 gl_PushMatrix( ctx
);
2831 case OPCODE_PUSH_NAME
:
2832 gl_PushName( ctx
, n
[1].ui
);
2834 case OPCODE_RASTER_POS
:
2835 gl_RasterPos4f( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2837 case OPCODE_READ_BUFFER
:
2838 gl_ReadBuffer( ctx
, n
[1].e
);
2841 gl_Rectf( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2844 gl_Scalef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
2846 case OPCODE_SCISSOR
:
2847 gl_Scissor( ctx
, n
[1].i
, n
[2].i
, n
[3].i
, n
[4].i
);
2849 case OPCODE_SHADE_MODEL
:
2850 gl_ShadeModel( ctx
, n
[1].e
);
2852 case OPCODE_STENCIL_FUNC
:
2853 gl_StencilFunc( ctx
, n
[1].e
, n
[2].i
, n
[3].ui
);
2855 case OPCODE_STENCIL_MASK
:
2856 gl_StencilMask( ctx
, n
[1].ui
);
2858 case OPCODE_STENCIL_OP
:
2859 gl_StencilOp( ctx
, n
[1].e
, n
[2].e
, n
[3].e
);
2868 gl_TexEnvfv( ctx
, n
[1].e
, n
[2].e
, params
);
2878 gl_TexGenfv( ctx
, n
[1].e
, n
[2].e
, params
);
2881 case OPCODE_TEXPARAMETER
:
2888 gl_TexParameterfv( ctx
, n
[1].e
, n
[2].e
, params
);
2891 case OPCODE_TEX_IMAGE1D
:
2893 n
[1].e
, /* target */
2895 n
[3].i
, /* components */
2897 n
[5].e
, /* border */
2898 n
[6].e
, /* format */
2900 (struct gl_image
*) n
[8].data
);
2902 case OPCODE_TEX_IMAGE2D
:
2904 n
[1].e
, /* target */
2906 n
[3].i
, /* components */
2908 n
[5].i
, /* height */
2909 n
[6].e
, /* border */
2910 n
[7].e
, /* format */
2912 (struct gl_image
*) n
[9].data
);
2914 case OPCODE_TEX_IMAGE3D
:
2915 gl_TexImage3DEXT( ctx
,
2916 n
[1].e
, /* target */
2918 n
[3].i
, /* components */
2920 n
[5].i
, /* height */
2922 n
[7].e
, /* border */
2923 n
[8].e
, /* format */
2925 (struct gl_image
*) n
[10].data
);
2927 case OPCODE_TEX_SUB_IMAGE1D
:
2928 gl_TexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].e
,
2929 n
[6].e
, (struct gl_image
*) n
[7].data
);
2931 case OPCODE_TEX_SUB_IMAGE2D
:
2932 gl_TexSubImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].e
,
2933 n
[6].i
, n
[7].e
, n
[8].e
,
2934 (struct gl_image
*) n
[9].data
);
2936 case OPCODE_TEX_SUB_IMAGE3D
:
2937 gl_TexSubImage3DEXT( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
,
2938 n
[6].i
, n
[7].i
, n
[8].i
, n
[9].e
, n
[10].e
,
2939 (struct gl_image
*) n
[11].data
);
2941 case OPCODE_TRANSLATE
:
2942 gl_Translatef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
2944 case OPCODE_VIEWPORT
:
2946 n
[1].i
, n
[2].i
, (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
);
2948 case OPCODE_WINDOW_POS
:
2949 gl_WindowPos4fMESA( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2951 case OPCODE_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
2952 gl_ActiveTexture( ctx
, n
[1].e
);
2954 case OPCODE_CLIENT_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
2955 gl_ClientActiveTexture( ctx
, n
[1].e
);
2957 case OPCODE_CONTINUE
:
2958 n
= (Node
*) n
[1].next
;
2960 case OPCODE_END_OF_LIST
:
2966 sprintf(msg
, "Error in execute_list: opcode=%d", (int) opcode
);
2967 gl_problem( ctx
, msg
);
2972 /* increment n to point to next compiled command */
2973 if (opcode
!=OPCODE_CONTINUE
) {
2974 n
+= InstSize
[opcode
];
2985 /**********************************************************************/
2987 /**********************************************************************/
2993 * Test if a display list number is valid.
2995 GLboolean
gl_IsList( GLcontext
*ctx
, GLuint list
)
2997 if (list
> 0 && HashLookup(ctx
->Shared
->DisplayList
, list
)) {
3008 * Delete a sequence of consecutive display lists.
3010 void gl_DeleteLists( GLcontext
*ctx
, GLuint list
, GLsizei range
)
3014 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glDeleteLists");
3016 gl_error( ctx
, GL_INVALID_VALUE
, "glDeleteLists" );
3019 for (i
=list
;i
<list
+range
;i
++) {
3020 gl_destroy_list( ctx
, i
);
3027 * Return a display list number, n, such that lists n through n+range-1
3030 GLuint
gl_GenLists( GLcontext
*ctx
, GLsizei range
)
3034 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx
, "glGenLists", 0);
3036 gl_error( ctx
, GL_INVALID_VALUE
, "glGenLists" );
3043 base
= HashFindFreeKeyBlock(ctx
->Shared
->DisplayList
, range
);
3045 /* reserve the list IDs by with empty/dummy lists */
3047 for (i
=0; i
<range
; i
++) {
3048 HashInsert(ctx
->Shared
->DisplayList
, base
+i
, make_empty_list());
3057 * Begin a new display list.
3059 void gl_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
3061 struct immediate
*IM
;
3062 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glNewList");
3064 if (MESA_VERBOSE
&VERBOSE_API
)
3065 fprintf(stderr
, "glNewList %u %s\n", list
, gl_lookup_enum_by_nr(mode
));
3068 gl_error( ctx
, GL_INVALID_VALUE
, "glNewList" );
3072 if (mode
!=GL_COMPILE
&& mode
!=GL_COMPILE_AND_EXECUTE
) {
3073 gl_error( ctx
, GL_INVALID_ENUM
, "glNewList" );
3077 if (ctx
->CurrentListPtr
) {
3078 /* already compiling a display list */
3079 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
3083 /* Allocate new display list */
3084 ctx
->CurrentListNum
= list
;
3085 ctx
->CurrentBlock
= (Node
*) MALLOC( sizeof(Node
) * BLOCK_SIZE
);
3086 ctx
->CurrentListPtr
= ctx
->CurrentBlock
;
3087 ctx
->CurrentPos
= 0;
3089 IM
= gl_immediate_alloc( ctx
);
3090 SET_IMMEDIATE( ctx
, IM
);
3091 gl_reset_input( ctx
);
3093 ctx
->CompileFlag
= GL_TRUE
;
3094 ctx
->CompileCVAFlag
= GL_FALSE
;
3095 ctx
->ExecuteFlag
= (mode
== GL_COMPILE_AND_EXECUTE
);
3096 ctx
->API
= ctx
->Save
; /* Switch the API function pointers */
3102 * End definition of current display list.
3104 void gl_EndList( GLcontext
*ctx
)
3106 if (MESA_VERBOSE
&VERBOSE_API
)
3107 fprintf(stderr
, "glEndList\n");
3109 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
, "glEndList" );
3111 /* Check that a list is under construction */
3112 if (!ctx
->CurrentListPtr
) {
3113 gl_error( ctx
, GL_INVALID_OPERATION
, "glEndList" );
3117 (void) alloc_instruction( ctx
, OPCODE_END_OF_LIST
, 0 );
3119 /* Destroy old list, if any */
3120 gl_destroy_list(ctx
, ctx
->CurrentListNum
);
3121 /* Install the list */
3122 HashInsert(ctx
->Shared
->DisplayList
, ctx
->CurrentListNum
, ctx
->CurrentListPtr
);
3125 if (MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
)
3126 mesa_print_display_list(ctx
->CurrentListNum
);
3128 ctx
->CurrentListNum
= 0;
3129 ctx
->CurrentListPtr
= NULL
;
3130 ctx
->ExecuteFlag
= GL_TRUE
;
3131 ctx
->CompileFlag
= GL_FALSE
;
3132 /* ctx->CompileCVAFlag = ...; */
3134 /* KW: Put back the old input pointer.
3136 if (--ctx
->input
->ref_count
== 0)
3137 gl_immediate_free( ctx
->input
);
3139 SET_IMMEDIATE( ctx
, ctx
->VB
->IM
);
3140 gl_reset_input( ctx
);
3142 /* Haven't tracked down why this is needed.
3146 ctx
->API
= ctx
->Exec
; /* Switch the API function pointers */
3151 void gl_CallList( GLcontext
*ctx
, GLuint list
)
3153 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
3154 /* execute the display list, and restore the CompileFlag. */
3155 GLboolean save_compile_flag
;
3157 if (MESA_VERBOSE
&VERBOSE_API
) {
3158 fprintf(stderr
, "glCallList %u\n", list
);
3159 mesa_print_display_list( list
);
3162 save_compile_flag
= ctx
->CompileFlag
;
3163 ctx
->CompileFlag
= GL_FALSE
;
3165 FLUSH_VB( ctx
, "call list" );
3166 execute_list( ctx
, list
);
3167 ctx
->CompileFlag
= save_compile_flag
;
3169 /* also restore API function pointers to point to "save" versions */
3170 if (save_compile_flag
)
3171 ctx
->API
= ctx
->Save
;
3177 * Execute glCallLists: call multiple display lists.
3179 void gl_CallLists( GLcontext
*ctx
,
3180 GLsizei n
, GLenum type
, const GLvoid
*lists
)
3184 GLboolean save_compile_flag
;
3186 /* Save the CompileFlag status, turn it off, execute display list,
3187 * and restore the CompileFlag.
3189 save_compile_flag
= ctx
->CompileFlag
;
3190 ctx
->CompileFlag
= GL_FALSE
;
3192 FLUSH_VB( ctx
, "call lists" );
3195 list
= translate_id( i
, type
, lists
);
3196 execute_list( ctx
, ctx
->List
.ListBase
+ list
);
3199 ctx
->CompileFlag
= save_compile_flag
;
3201 /* also restore API function pointers to point to "save" versions */
3202 if (save_compile_flag
)
3203 ctx
->API
= ctx
->Save
;
3206 /* RESET_IMMEDIATE( ctx ); */
3212 * Set the offset added to list numbers in glCallLists.
3214 void gl_ListBase( GLcontext
*ctx
, GLuint base
)
3216 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glListBase");
3217 ctx
->List
.ListBase
= base
;
3226 * Assign all the pointers in 'table' to point to Mesa's display list
3227 * building functions.
3229 void gl_init_dlist_pointers( struct gl_api_table
*table
)
3231 table
->Accum
= save_Accum
;
3232 table
->AlphaFunc
= save_AlphaFunc
;
3233 table
->AreTexturesResident
= gl_AreTexturesResident
;
3234 table
->BindTexture
= save_BindTexture
;
3235 table
->Bitmap
= save_Bitmap
;
3236 table
->BlendColor
= save_BlendColor
;
3237 table
->BlendEquation
= save_BlendEquation
;
3238 table
->BlendFunc
= save_BlendFunc
;
3239 table
->BlendFuncSeparate
= save_BlendFuncSeparate
;
3240 table
->CallList
= save_CallList
;
3241 table
->CallLists
= save_CallLists
;
3242 table
->Clear
= save_Clear
;
3243 table
->ClearAccum
= save_ClearAccum
;
3244 table
->ClearColor
= save_ClearColor
;
3245 table
->ClearDepth
= save_ClearDepth
;
3246 table
->ClearIndex
= save_ClearIndex
;
3247 table
->ClearStencil
= save_ClearStencil
;
3248 table
->ClipPlane
= save_ClipPlane
;
3249 table
->ColorMask
= save_ColorMask
;
3250 table
->ColorMaterial
= save_ColorMaterial
;
3251 table
->ColorTable
= save_ColorTable
;
3252 table
->ColorSubTable
= save_ColorSubTable
;
3253 table
->CopyPixels
= save_CopyPixels
;
3254 table
->CopyTexImage1D
= save_CopyTexImage1D
;
3255 table
->CopyTexImage2D
= save_CopyTexImage2D
;
3256 table
->CopyTexSubImage1D
= save_CopyTexSubImage1D
;
3257 table
->CopyTexSubImage2D
= save_CopyTexSubImage2D
;
3258 table
->CopyTexSubImage3DEXT
= save_CopyTexSubImage3DEXT
;
3259 table
->CullFace
= save_CullFace
;
3260 table
->DeleteLists
= gl_DeleteLists
; /* NOT SAVED */
3261 table
->DeleteTextures
= gl_DeleteTextures
; /* NOT SAVED */
3262 table
->DepthFunc
= save_DepthFunc
;
3263 table
->DepthMask
= save_DepthMask
;
3264 table
->DepthRange
= save_DepthRange
;
3265 table
->Disable
= save_Disable
;
3266 table
->DisableClientState
= gl_DisableClientState
; /* NOT SAVED */
3267 table
->DrawBuffer
= save_DrawBuffer
;
3268 table
->DrawPixels
= save_DrawPixels
;
3269 table
->Enable
= save_Enable
;
3270 table
->Error
= gl_save_error
;
3271 table
->EnableClientState
= gl_EnableClientState
; /* NOT SAVED */
3272 table
->EndList
= gl_EndList
; /* NOT SAVED */
3273 table
->EvalMesh1
= save_EvalMesh1
;
3274 table
->EvalMesh2
= save_EvalMesh2
;
3275 table
->FeedbackBuffer
= gl_FeedbackBuffer
; /* NOT SAVED */
3276 table
->Finish
= gl_Finish
; /* NOT SAVED */
3277 table
->Flush
= gl_Flush
; /* NOT SAVED */
3278 table
->Fogfv
= save_Fogfv
;
3279 table
->FrontFace
= save_FrontFace
;
3280 table
->Frustum
= save_Frustum
;
3281 table
->GenLists
= gl_GenLists
; /* NOT SAVED */
3282 table
->GenTextures
= gl_GenTextures
; /* NOT SAVED */
3284 /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
3285 table
->GetBooleanv
= gl_GetBooleanv
;
3286 table
->GetClipPlane
= gl_GetClipPlane
;
3287 table
->GetColorTable
= gl_GetColorTable
;
3288 table
->GetColorTableParameteriv
= gl_GetColorTableParameteriv
;
3289 table
->GetDoublev
= gl_GetDoublev
;
3290 table
->GetError
= gl_GetError
;
3291 table
->GetFloatv
= gl_GetFloatv
;
3292 table
->GetIntegerv
= gl_GetIntegerv
;
3293 table
->GetString
= gl_GetString
;
3294 table
->GetLightfv
= gl_GetLightfv
;
3295 table
->GetLightiv
= gl_GetLightiv
;
3296 table
->GetMapdv
= gl_GetMapdv
;
3297 table
->GetMapfv
= gl_GetMapfv
;
3298 table
->GetMapiv
= gl_GetMapiv
;
3299 table
->GetMaterialfv
= gl_GetMaterialfv
;
3300 table
->GetMaterialiv
= gl_GetMaterialiv
;
3301 table
->GetPixelMapfv
= gl_GetPixelMapfv
;
3302 table
->GetPixelMapuiv
= gl_GetPixelMapuiv
;
3303 table
->GetPixelMapusv
= gl_GetPixelMapusv
;
3304 table
->GetPointerv
= gl_GetPointerv
;
3305 table
->GetPolygonStipple
= gl_GetPolygonStipple
;
3306 table
->GetTexEnvfv
= gl_GetTexEnvfv
;
3307 table
->GetTexEnviv
= gl_GetTexEnviv
;
3308 table
->GetTexGendv
= gl_GetTexGendv
;
3309 table
->GetTexGenfv
= gl_GetTexGenfv
;
3310 table
->GetTexGeniv
= gl_GetTexGeniv
;
3311 table
->GetTexImage
= gl_GetTexImage
;
3312 table
->GetTexLevelParameterfv
= gl_GetTexLevelParameterfv
;
3313 table
->GetTexLevelParameteriv
= gl_GetTexLevelParameteriv
;
3314 table
->GetTexParameterfv
= gl_GetTexParameterfv
;
3315 table
->GetTexParameteriv
= gl_GetTexParameteriv
;
3317 table
->Hint
= save_Hint
;
3318 table
->IndexMask
= save_IndexMask
;
3319 table
->InitNames
= save_InitNames
;
3320 table
->IsEnabled
= gl_IsEnabled
; /* NOT SAVED */
3321 table
->IsTexture
= gl_IsTexture
; /* NOT SAVED */
3322 table
->IsList
= gl_IsList
; /* NOT SAVED */
3323 table
->LightModelfv
= save_LightModelfv
;
3324 table
->Lightfv
= save_Lightfv
;
3325 table
->LineStipple
= save_LineStipple
;
3326 table
->LineWidth
= save_LineWidth
;
3327 table
->ListBase
= save_ListBase
;
3328 table
->LoadIdentity
= save_LoadIdentity
;
3329 table
->LoadMatrixf
= save_LoadMatrixf
;
3330 table
->LoadName
= save_LoadName
;
3331 table
->LogicOp
= save_LogicOp
;
3332 table
->Map1f
= save_Map1f
;
3333 table
->Map2f
= save_Map2f
;
3334 table
->MapGrid1f
= save_MapGrid1f
;
3335 table
->MapGrid2f
= save_MapGrid2f
;
3336 table
->MatrixMode
= save_MatrixMode
;
3337 table
->MultMatrixf
= save_MultMatrixf
;
3338 table
->NewList
= save_NewList
;
3339 table
->Ortho
= save_Ortho
;
3340 table
->PointParameterfvEXT
= save_PointParameterfvEXT
;
3341 table
->PassThrough
= save_PassThrough
;
3342 table
->PixelMapfv
= save_PixelMapfv
;
3343 table
->PixelStorei
= gl_PixelStorei
; /* NOT SAVED */
3344 table
->PixelTransferf
= save_PixelTransferf
;
3345 table
->PixelZoom
= save_PixelZoom
;
3346 table
->PointSize
= save_PointSize
;
3347 table
->PolygonMode
= save_PolygonMode
;
3348 table
->PolygonOffset
= save_PolygonOffset
;
3349 table
->PolygonStipple
= save_PolygonStipple
;
3350 table
->PopAttrib
= save_PopAttrib
;
3351 table
->PopClientAttrib
= gl_PopClientAttrib
; /* NOT SAVED */
3352 table
->PopMatrix
= save_PopMatrix
;
3353 table
->PopName
= save_PopName
;
3354 table
->PrioritizeTextures
= save_PrioritizeTextures
;
3355 table
->PushAttrib
= save_PushAttrib
;
3356 table
->PushClientAttrib
= gl_PushClientAttrib
; /* NOT SAVED */
3357 table
->PushMatrix
= save_PushMatrix
;
3358 table
->PushName
= save_PushName
;
3359 table
->RasterPos4f
= save_RasterPos4f
;
3360 table
->ReadBuffer
= save_ReadBuffer
;
3361 table
->ReadPixels
= gl_ReadPixels
; /* NOT SAVED */
3362 table
->Rectf
= save_Rectf
;
3363 table
->RenderMode
= gl_RenderMode
; /* NOT SAVED */
3364 table
->Rotatef
= save_Rotatef
;
3365 table
->Scalef
= save_Scalef
;
3366 table
->Scissor
= save_Scissor
;
3367 table
->SelectBuffer
= gl_SelectBuffer
; /* NOT SAVED */
3368 table
->ShadeModel
= save_ShadeModel
;
3369 table
->StencilFunc
= save_StencilFunc
;
3370 table
->StencilMask
= save_StencilMask
;
3371 table
->StencilOp
= save_StencilOp
;
3372 table
->TexEnvfv
= save_TexEnvfv
;
3373 table
->TexGenfv
= save_TexGenfv
;
3374 table
->TexImage1D
= save_TexImage1D
;
3375 table
->TexImage2D
= save_TexImage2D
;
3376 table
->TexImage3DEXT
= save_TexImage3DEXT
;
3377 table
->TexSubImage1D
= save_TexSubImage1D
;
3378 table
->TexSubImage2D
= save_TexSubImage2D
;
3379 table
->TexSubImage3DEXT
= save_TexSubImage3DEXT
;
3380 table
->TexParameterfv
= save_TexParameterfv
;
3381 table
->Translatef
= save_Translatef
;
3382 table
->Viewport
= save_Viewport
;
3384 /* GL_MESA_window_pos extension */
3385 table
->WindowPos4fMESA
= save_WindowPos4fMESA
;
3387 /* GL_MESA_resize_buffers extension */
3388 table
->ResizeBuffersMESA
= gl_ResizeBuffersMESA
;
3390 /* GL_ARB_multitexture */
3391 table
->ActiveTexture
= save_ActiveTexture
;
3392 table
->ClientActiveTexture
= save_ClientActiveTexture
;
3400 static const char *enum_string( GLenum k
)
3402 return gl_lookup_enum_by_nr( k
);
3407 * Print the commands in a display list. For debugging only.
3408 * TODO: many commands aren't handled yet.
3410 static void print_list( GLcontext
*ctx
, FILE *f
, GLuint list
)
3416 if (!glIsList(list
)) {
3417 fprintf(f
,"%u is not a display list ID\n",list
);
3421 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
3423 fprintf( f
, "START-LIST %u, address %p\n", list
, (void*)n
);
3425 done
= n
? GL_FALSE
: GL_TRUE
;
3427 opcode
= n
[0].opcode
;
3431 fprintf(f
,"accum %s %g\n", enum_string(n
[1].e
), n
[2].f
);
3434 fprintf(f
,"Bitmap %d %d %g %g %g %g %p\n", n
[1].i
, n
[2].i
,
3435 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
, (void *) n
[7].data
);
3437 case OPCODE_CALL_LIST
:
3438 fprintf(f
,"CallList %d\n", (int) n
[1].ui
);
3440 case OPCODE_CALL_LIST_OFFSET
:
3441 fprintf(f
,"CallList %d + offset %u = %u\n", (int) n
[1].ui
,
3442 ctx
->List
.ListBase
, ctx
->List
.ListBase
+ n
[1].ui
);
3444 case OPCODE_DISABLE
:
3445 fprintf(f
,"Disable %s\n", enum_string(n
[1].e
));
3448 fprintf(f
,"Enable %s\n", enum_string(n
[1].e
));
3450 case OPCODE_FRUSTUM
:
3451 fprintf(f
,"Frustum %g %g %g %g %g %g\n",
3452 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3454 case OPCODE_LINE_STIPPLE
:
3455 fprintf(f
,"LineStipple %d %x\n", n
[1].i
, (int) n
[2].us
);
3457 case OPCODE_LOAD_IDENTITY
:
3458 fprintf(f
,"LoadIdentity\n");
3460 case OPCODE_LOAD_MATRIX
:
3461 fprintf(f
,"LoadMatrix\n");
3462 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3463 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3464 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3465 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3467 case OPCODE_MULT_MATRIX
:
3468 fprintf(f
,"MultMatrix (or Rotate)\n");
3469 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3470 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3471 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3472 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3475 fprintf(f
,"Ortho %g %g %g %g %g %g\n",
3476 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3478 case OPCODE_POP_ATTRIB
:
3479 fprintf(f
,"PopAttrib\n");
3481 case OPCODE_POP_MATRIX
:
3482 fprintf(f
,"PopMatrix\n");
3484 case OPCODE_POP_NAME
:
3485 fprintf(f
,"PopName\n");
3487 case OPCODE_PUSH_ATTRIB
:
3488 fprintf(f
,"PushAttrib %x\n", n
[1].bf
);
3490 case OPCODE_PUSH_MATRIX
:
3491 fprintf(f
,"PushMatrix\n");
3493 case OPCODE_PUSH_NAME
:
3494 fprintf(f
,"PushName %d\n", (int) n
[1].ui
);
3496 case OPCODE_RASTER_POS
:
3497 fprintf(f
,"RasterPos %g %g %g %g\n", n
[1].f
, n
[2].f
,n
[3].f
,n
[4].f
);
3500 fprintf( f
, "Rectf %g %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
3503 fprintf(f
,"Scale %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3505 case OPCODE_TRANSLATE
:
3506 fprintf(f
,"Translate %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3508 case OPCODE_BIND_TEXTURE
:
3509 fprintf(f
,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n
[1].ui
),
3512 case OPCODE_SHADE_MODEL
:
3513 fprintf(f
,"ShadeModel %s\n", gl_lookup_enum_by_nr(n
[1].ui
));
3517 * meta opcodes/commands
3520 fprintf(f
,"Error: %s %s\n", enum_string(n
[1].e
), (const char *)n
[2].data
);
3522 case OPCODE_VERTEX_CASSETTE
:
3523 fprintf(f
,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
3524 ((struct immediate
*) n
[1].data
)->id
,
3527 /* gl_print_cassette( (struct immediate *) n[1].data, */
3530 case OPCODE_CONTINUE
:
3531 fprintf(f
,"DISPLAY-LIST-CONTINUE\n");
3532 n
= (Node
*) n
[1].next
;
3534 case OPCODE_END_OF_LIST
:
3535 fprintf(f
,"END-LIST %u\n", list
);
3539 if (opcode
< 0 || opcode
> OPCODE_END_OF_LIST
) {
3540 fprintf(f
,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
3545 fprintf(f
,"command %d, %u operands\n",opcode
,InstSize
[opcode
]);
3549 /* increment n to point to next compiled command */
3550 if (opcode
!=OPCODE_CONTINUE
) {
3551 n
+= InstSize
[opcode
];
3564 * Clients may call this function to help debug display list problems.
3565 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
3566 * changed, or break in the future without notice.
3568 void mesa_print_display_list( GLuint list
)
3571 print_list( CC
, stderr
, list
);