1 /* $Id: dlist.c,v 1.4 1999/09/11 11:31:34 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.
51 #include "extensions.h"
86 #include "GL/xf86glx.h"
93 Functions which aren't compiled but executed immediately:
108 Functions which cause errors if called while compiling a display list:
115 * Display list instructions are stored as sequences of "nodes". Nodes
116 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
117 * are linked together with a pointer.
121 /* How many nodes to allocate at a time:
122 * - reduced now that we hold vertices etc. elsewhere.
124 #define BLOCK_SIZE 64
128 * Display list opcodes.
130 * The fact that these identifiers are assigned consecutive
131 * integer values starting at 0 is very important, see InstSize array usage)
133 * KW: Commented out opcodes now handled by vertex-cassettes.
141 OPCODE_BLEND_EQUATION
,
143 OPCODE_BLEND_FUNC_SEPARATE
,
145 OPCODE_CALL_LIST_OFFSET
,
151 OPCODE_CLEAR_STENCIL
,
154 OPCODE_COLOR_MATERIAL
,
156 OPCODE_COLOR_SUB_TABLE
,
158 OPCODE_COPY_TEX_IMAGE1D
,
159 OPCODE_COPY_TEX_IMAGE2D
,
160 OPCODE_COPY_TEX_IMAGE3D
,
161 OPCODE_COPY_TEX_SUB_IMAGE1D
,
162 OPCODE_COPY_TEX_SUB_IMAGE2D
,
163 OPCODE_COPY_TEX_SUB_IMAGE3D
,
189 OPCODE_LOAD_IDENTITY
,
202 OPCODE_PIXEL_TRANSFER
,
205 OPCODE_POINT_PARAMETERS
,
207 OPCODE_POLYGON_STIPPLE
,
208 OPCODE_POLYGON_OFFSET
,
212 OPCODE_PRIORITIZE_TEXTURE
,
221 OPCODE_SELECT_TEXTURE_SGIS
,
222 OPCODE_SELECT_TEXTURE_COORD_SET
,
233 OPCODE_TEX_SUB_IMAGE1D
,
234 OPCODE_TEX_SUB_IMAGE2D
,
235 OPCODE_TEX_SUB_IMAGE3D
,
239 /* GL_ARB_multitexture */
240 OPCODE_ACTIVE_TEXTURE
,
241 OPCODE_CLIENT_ACTIVE_TEXTURE
,
242 /* The following three are meta instructions */
243 OPCODE_ERROR
, /* raise compiled-in error */
244 OPCODE_VERTEX_CASSETTE
, /* render prebuilt vertex buffer */
251 * Each instruction in the display list is stored as a sequence of
252 * contiguous nodes in memory.
253 * Each node is the union of a variety of datatypes.
267 void *next
; /* If prev node's opcode==OPCODE_CONTINUE */
272 /* Number of nodes of storage needed for each instruction: */
273 static GLuint InstSize
[ OPCODE_END_OF_LIST
+1 ];
275 void mesa_print_display_list( GLuint list
);
278 /**********************************************************************/
279 /***** Private *****/
280 /**********************************************************************/
284 * Allocate space for a display list instruction.
285 * Input: opcode - type of instruction
286 * argcount - number of arguments following the instruction
287 * Return: pointer to first node in the instruction
289 static Node
*alloc_instruction( GLcontext
*ctx
, OpCode opcode
, GLint argcount
)
292 GLuint count
= InstSize
[opcode
];
294 assert( (GLint
) count
== argcount
+1 );
296 if (ctx
->CurrentPos
+ count
+ 2 > BLOCK_SIZE
) {
297 /* This block is full. Allocate a new block and chain to it */
298 n
= ctx
->CurrentBlock
+ ctx
->CurrentPos
;
299 n
[0].opcode
= OPCODE_CONTINUE
;
300 newblock
= (Node
*) malloc( sizeof(Node
) * BLOCK_SIZE
);
302 gl_error( ctx
, GL_OUT_OF_MEMORY
, "Building display list" );
305 n
[1].next
= (Node
*) newblock
;
306 ctx
->CurrentBlock
= newblock
;
310 n
= ctx
->CurrentBlock
+ ctx
->CurrentPos
;
311 ctx
->CurrentPos
+= count
;
313 n
[0].opcode
= opcode
;
321 * Make an empty display list. This is used by glGenLists() to
322 * reserver display list IDs.
324 static Node
*make_empty_list( void )
326 Node
*n
= (Node
*) malloc( sizeof(Node
) );
327 n
[0].opcode
= OPCODE_END_OF_LIST
;
334 * Destroy all nodes in a display list.
335 * Input: list - display list number
337 void gl_destroy_list( GLcontext
*ctx
, GLuint list
)
345 block
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
348 done
= block
? GL_FALSE
: GL_TRUE
;
350 switch (n
[0].opcode
) {
351 /* special cases first */
352 case OPCODE_VERTEX_CASSETTE
:
353 if ( ! -- ((struct immediate
*) n
[1].data
)->ref_count
)
354 gl_immediate_free( (struct immediate
*) n
[1].data
);
355 n
+= InstSize
[n
[0].opcode
];
358 gl_free_control_points( ctx
, n
[1].e
, (GLfloat
*) n
[6].data
);
359 n
+= InstSize
[n
[0].opcode
];
362 gl_free_control_points( ctx
, n
[1].e
, (GLfloat
*) n
[10].data
);
363 n
+= InstSize
[n
[0].opcode
];
365 case OPCODE_DRAW_PIXELS
:
366 gl_free_image( (struct gl_image
*) n
[1].data
);
367 n
+= InstSize
[n
[0].opcode
];
370 gl_free_image( (struct gl_image
*) n
[7].data
);
371 n
+= InstSize
[n
[0].opcode
];
373 case OPCODE_COLOR_TABLE
:
374 gl_free_image( (struct gl_image
*) n
[3].data
);
375 n
+= InstSize
[n
[0].opcode
];
377 case OPCODE_COLOR_SUB_TABLE
:
378 gl_free_image( (struct gl_image
*) n
[3].data
);
379 n
+= InstSize
[n
[0].opcode
];
381 case OPCODE_POLYGON_STIPPLE
:
383 n
+= InstSize
[n
[0].opcode
];
385 case OPCODE_TEX_IMAGE1D
:
386 gl_free_image( (struct gl_image
*) n
[8].data
);
387 n
+= InstSize
[n
[0].opcode
];
389 case OPCODE_TEX_IMAGE2D
:
390 gl_free_image( (struct gl_image
*) n
[9].data
);
391 n
+= InstSize
[n
[0].opcode
];
393 case OPCODE_TEX_SUB_IMAGE1D
:
395 struct gl_image
*image
;
396 image
= (struct gl_image
*) n
[7].data
;
397 gl_free_image( image
);
400 case OPCODE_TEX_SUB_IMAGE2D
:
402 struct gl_image
*image
;
403 image
= (struct gl_image
*) n
[9].data
;
404 gl_free_image( image
);
407 case OPCODE_CONTINUE
:
408 n
= (Node
*) n
[1].next
;
412 case OPCODE_END_OF_LIST
:
417 /* Most frequent case */
418 n
+= InstSize
[n
[0].opcode
];
423 HashRemove(ctx
->Shared
->DisplayList
, list
);
429 * Translate the nth element of list from type to GLuint.
431 static GLuint
translate_id( GLsizei n
, GLenum type
, const GLvoid
*list
)
443 bptr
= (GLbyte
*) list
;
444 return (GLuint
) *(bptr
+n
);
445 case GL_UNSIGNED_BYTE
:
446 ubptr
= (GLubyte
*) list
;
447 return (GLuint
) *(ubptr
+n
);
449 sptr
= (GLshort
*) list
;
450 return (GLuint
) *(sptr
+n
);
451 case GL_UNSIGNED_SHORT
:
452 usptr
= (GLushort
*) list
;
453 return (GLuint
) *(usptr
+n
);
455 iptr
= (GLint
*) list
;
456 return (GLuint
) *(iptr
+n
);
457 case GL_UNSIGNED_INT
:
458 uiptr
= (GLuint
*) list
;
459 return (GLuint
) *(uiptr
+n
);
461 fptr
= (GLfloat
*) list
;
462 return (GLuint
) *(fptr
+n
);
464 ubptr
= ((GLubyte
*) list
) + 2*n
;
465 return (GLuint
) *ubptr
* 256 + (GLuint
) *(ubptr
+1);
467 ubptr
= ((GLubyte
*) list
) + 3*n
;
468 return (GLuint
) *ubptr
* 65536
469 + (GLuint
) *(ubptr
+1) * 256
470 + (GLuint
) *(ubptr
+2);
472 ubptr
= ((GLubyte
*) list
) + 4*n
;
473 return (GLuint
) *ubptr
* 16777216
474 + (GLuint
) *(ubptr
+1) * 65536
475 + (GLuint
) *(ubptr
+2) * 256
476 + (GLuint
) *(ubptr
+3);
485 /**********************************************************************/
487 /**********************************************************************/
489 void gl_init_lists( void )
491 static int init_flag
= 0;
494 InstSize
[OPCODE_ACCUM
] = 3;
495 InstSize
[OPCODE_ALPHA_FUNC
] = 3;
496 InstSize
[OPCODE_BIND_TEXTURE
] = 3;
497 InstSize
[OPCODE_BITMAP
] = 8;
498 InstSize
[OPCODE_BLEND_COLOR
] = 5;
499 InstSize
[OPCODE_BLEND_EQUATION
] = 2;
500 InstSize
[OPCODE_BLEND_FUNC
] = 3;
501 InstSize
[OPCODE_BLEND_FUNC_SEPARATE
] = 5;
502 InstSize
[OPCODE_CALL_LIST
] = 2;
503 InstSize
[OPCODE_CALL_LIST_OFFSET
] = 2;
504 InstSize
[OPCODE_CLEAR
] = 2;
505 InstSize
[OPCODE_CLEAR_ACCUM
] = 5;
506 InstSize
[OPCODE_CLEAR_COLOR
] = 5;
507 InstSize
[OPCODE_CLEAR_DEPTH
] = 2;
508 InstSize
[OPCODE_CLEAR_INDEX
] = 2;
509 InstSize
[OPCODE_CLEAR_STENCIL
] = 2;
510 InstSize
[OPCODE_CLIP_PLANE
] = 6;
511 InstSize
[OPCODE_COLOR_MASK
] = 5;
512 InstSize
[OPCODE_COLOR_MATERIAL
] = 3;
513 InstSize
[OPCODE_COLOR_TABLE
] = 4;
514 InstSize
[OPCODE_COLOR_SUB_TABLE
] = 4;
515 InstSize
[OPCODE_COPY_PIXELS
] = 6;
516 InstSize
[OPCODE_COPY_TEX_IMAGE1D
] = 8;
517 InstSize
[OPCODE_COPY_TEX_IMAGE2D
] = 9;
518 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE1D
] = 7;
519 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE2D
] = 9;
520 InstSize
[OPCODE_COPY_TEX_SUB_IMAGE3D
] = 10;
521 InstSize
[OPCODE_CULL_FACE
] = 2;
522 InstSize
[OPCODE_DEPTH_FUNC
] = 2;
523 InstSize
[OPCODE_DEPTH_MASK
] = 2;
524 InstSize
[OPCODE_DEPTH_RANGE
] = 3;
525 InstSize
[OPCODE_DISABLE
] = 2;
526 InstSize
[OPCODE_DRAW_BUFFER
] = 2;
527 InstSize
[OPCODE_DRAW_PIXELS
] = 2;
528 InstSize
[OPCODE_ENABLE
] = 2;
529 InstSize
[OPCODE_EVALCOORD1
] = 2;
530 InstSize
[OPCODE_EVALCOORD2
] = 3;
531 InstSize
[OPCODE_EVALMESH1
] = 4;
532 InstSize
[OPCODE_EVALMESH2
] = 6;
533 InstSize
[OPCODE_EVALPOINT1
] = 2;
534 InstSize
[OPCODE_EVALPOINT2
] = 3;
535 InstSize
[OPCODE_FOG
] = 6;
536 InstSize
[OPCODE_FRONT_FACE
] = 2;
537 InstSize
[OPCODE_FRUSTUM
] = 7;
538 InstSize
[OPCODE_HINT
] = 3;
539 InstSize
[OPCODE_INDEX_MASK
] = 2;
540 InstSize
[OPCODE_INIT_NAMES
] = 1;
541 InstSize
[OPCODE_LIGHT
] = 7;
542 InstSize
[OPCODE_LIGHT_MODEL
] = 6;
543 InstSize
[OPCODE_LINE_STIPPLE
] = 3;
544 InstSize
[OPCODE_LINE_WIDTH
] = 2;
545 InstSize
[OPCODE_LIST_BASE
] = 2;
546 InstSize
[OPCODE_LOAD_IDENTITY
] = 1;
547 InstSize
[OPCODE_LOAD_MATRIX
] = 17;
548 InstSize
[OPCODE_LOAD_NAME
] = 2;
549 InstSize
[OPCODE_LOGIC_OP
] = 2;
550 InstSize
[OPCODE_MAP1
] = 7;
551 InstSize
[OPCODE_MAP2
] = 11;
552 InstSize
[OPCODE_MAPGRID1
] = 4;
553 InstSize
[OPCODE_MAPGRID2
] = 7;
554 InstSize
[OPCODE_MATRIX_MODE
] = 2;
555 InstSize
[OPCODE_MULT_MATRIX
] = 17;
556 InstSize
[OPCODE_ORTHO
] = 7;
557 InstSize
[OPCODE_PASSTHROUGH
] = 2;
558 InstSize
[OPCODE_PIXEL_MAP
] = 4;
559 InstSize
[OPCODE_PIXEL_TRANSFER
] = 3;
560 InstSize
[OPCODE_PIXEL_ZOOM
] = 3;
561 InstSize
[OPCODE_POINT_SIZE
] = 2;
562 InstSize
[OPCODE_POINT_PARAMETERS
] = 5;
563 InstSize
[OPCODE_POLYGON_MODE
] = 3;
564 InstSize
[OPCODE_POLYGON_STIPPLE
] = 2;
565 InstSize
[OPCODE_POLYGON_OFFSET
] = 3;
566 InstSize
[OPCODE_POP_ATTRIB
] = 1;
567 InstSize
[OPCODE_POP_MATRIX
] = 1;
568 InstSize
[OPCODE_POP_NAME
] = 1;
569 InstSize
[OPCODE_PRIORITIZE_TEXTURE
] = 3;
570 InstSize
[OPCODE_PUSH_ATTRIB
] = 2;
571 InstSize
[OPCODE_PUSH_MATRIX
] = 1;
572 InstSize
[OPCODE_PUSH_NAME
] = 2;
573 InstSize
[OPCODE_RASTER_POS
] = 5;
574 InstSize
[OPCODE_RECTF
] = 5;
575 InstSize
[OPCODE_READ_BUFFER
] = 2;
576 InstSize
[OPCODE_SCALE
] = 4;
577 InstSize
[OPCODE_SCISSOR
] = 5;
578 InstSize
[OPCODE_STENCIL_FUNC
] = 4;
579 InstSize
[OPCODE_STENCIL_MASK
] = 2;
580 InstSize
[OPCODE_STENCIL_OP
] = 4;
581 InstSize
[OPCODE_SHADE_MODEL
] = 2;
582 InstSize
[OPCODE_TEXENV
] = 7;
583 InstSize
[OPCODE_TEXGEN
] = 7;
584 InstSize
[OPCODE_TEXPARAMETER
] = 7;
585 InstSize
[OPCODE_TEX_IMAGE1D
] = 9;
586 InstSize
[OPCODE_TEX_IMAGE2D
] = 10;
587 InstSize
[OPCODE_TEX_IMAGE3D
] = 11;
588 InstSize
[OPCODE_TEX_SUB_IMAGE1D
] = 8;
589 InstSize
[OPCODE_TEX_SUB_IMAGE2D
] = 10;
590 InstSize
[OPCODE_TEX_SUB_IMAGE3D
] = 12;
591 InstSize
[OPCODE_TRANSLATE
] = 4;
592 InstSize
[OPCODE_VIEWPORT
] = 5;
593 InstSize
[OPCODE_WINDOW_POS
] = 5;
594 InstSize
[OPCODE_CONTINUE
] = 2;
595 InstSize
[OPCODE_ERROR
] = 3;
596 InstSize
[OPCODE_VERTEX_CASSETTE
] = 2;
597 InstSize
[OPCODE_END_OF_LIST
] = 1;
598 /* GL_ARB_multitexture */
599 InstSize
[OPCODE_ACTIVE_TEXTURE
] = 2;
600 InstSize
[OPCODE_CLIENT_ACTIVE_TEXTURE
] = 2;
607 * Display List compilation functions
612 static void save_Accum( GLcontext
*ctx
, GLenum op
, GLfloat value
)
615 FLUSH_VB(ctx
, "dlist");
616 n
= alloc_instruction( ctx
, OPCODE_ACCUM
, 2 );
621 if (ctx
->ExecuteFlag
) {
622 (*ctx
->Exec
.Accum
)( ctx
, op
, value
);
627 static void save_AlphaFunc( GLcontext
*ctx
, GLenum func
, GLclampf ref
)
630 FLUSH_VB(ctx
, "dlist");
631 n
= alloc_instruction( ctx
, OPCODE_ALPHA_FUNC
, 2 );
634 n
[2].f
= (GLfloat
) ref
;
636 if (ctx
->ExecuteFlag
) {
637 (*ctx
->Exec
.AlphaFunc
)( ctx
, func
, ref
);
641 static void save_BindTexture( GLcontext
*ctx
, GLenum target
, GLuint texture
)
644 FLUSH_VB(ctx
, "dlist");
645 n
= alloc_instruction( ctx
, OPCODE_BIND_TEXTURE
, 2 );
650 if (ctx
->ExecuteFlag
) {
651 (*ctx
->Exec
.BindTexture
)( ctx
, target
, texture
);
656 static void save_Bitmap( GLcontext
*ctx
,
657 GLsizei width
, GLsizei height
,
658 GLfloat xorig
, GLfloat yorig
,
659 GLfloat xmove
, GLfloat ymove
,
660 const GLubyte
*bitmap
,
661 const struct gl_pixelstore_attrib
*packing
)
664 FLUSH_VB(ctx
, "dlist");
665 n
= alloc_instruction( ctx
, OPCODE_BITMAP
, 7 );
667 struct gl_image
*image
= gl_unpack_bitmap( ctx
, width
, height
,
672 n
[1].i
= (GLint
) width
;
673 n
[2].i
= (GLint
) height
;
678 n
[7].data
= (void *) image
;
680 if (ctx
->ExecuteFlag
) {
681 (*ctx
->Exec
.Bitmap
)( ctx
, width
, height
,
682 xorig
, yorig
, xmove
, ymove
, bitmap
, packing
);
687 static void save_BlendEquation( GLcontext
*ctx
, GLenum mode
)
690 FLUSH_VB(ctx
, "dlist");
691 n
= alloc_instruction( ctx
, OPCODE_BLEND_EQUATION
, 1 );
695 if (ctx
->ExecuteFlag
) {
696 (*ctx
->Exec
.BlendEquation
)( ctx
, mode
);
701 static void save_BlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
704 FLUSH_VB(ctx
, "dlist");
705 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC
, 2 );
710 if (ctx
->ExecuteFlag
) {
711 (*ctx
->Exec
.BlendFunc
)( ctx
, sfactor
, dfactor
);
716 static void save_BlendFuncSeparate( GLcontext
*ctx
,
717 GLenum sfactorRGB
, GLenum dfactorRGB
,
718 GLenum sfactorA
, GLenum dfactorA
)
721 FLUSH_VB(ctx
, "dlist");
722 n
= alloc_instruction( ctx
, OPCODE_BLEND_FUNC_SEPARATE
, 4 );
729 if (ctx
->ExecuteFlag
) {
730 (*ctx
->Exec
.BlendFuncSeparate
)( ctx
, sfactorRGB
, dfactorRGB
,
736 static void save_BlendColor( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
737 GLfloat blue
, GLfloat alpha
)
740 FLUSH_VB(ctx
, "dlist");
741 n
= alloc_instruction( ctx
, OPCODE_BLEND_COLOR
, 4 );
748 if (ctx
->ExecuteFlag
) {
749 (*ctx
->Exec
.BlendColor
)( ctx
, red
, green
, blue
, alpha
);
754 static void save_CallList( GLcontext
*ctx
, GLuint list
)
757 FLUSH_VB(ctx
, "dlist");
758 n
= alloc_instruction( ctx
, OPCODE_CALL_LIST
, 1 );
762 if (ctx
->ExecuteFlag
) {
763 (*ctx
->Exec
.CallList
)( ctx
, list
);
768 static void save_CallLists( GLcontext
*ctx
,
769 GLsizei n
, GLenum type
, const GLvoid
*lists
)
772 FLUSH_VB(ctx
, "dlist");
775 GLuint list
= translate_id( i
, type
, lists
);
776 Node
*n
= alloc_instruction( ctx
, OPCODE_CALL_LIST_OFFSET
, 1 );
781 if (ctx
->ExecuteFlag
) {
782 (*ctx
->Exec
.CallLists
)( ctx
, n
, type
, lists
);
787 static void save_Clear( GLcontext
*ctx
, GLbitfield mask
)
790 FLUSH_VB(ctx
, "dlist");
791 n
= alloc_instruction( ctx
, OPCODE_CLEAR
, 1 );
795 if (ctx
->ExecuteFlag
) {
796 (*ctx
->Exec
.Clear
)( ctx
, mask
);
801 static void save_ClearAccum( GLcontext
*ctx
, GLfloat red
, GLfloat green
,
802 GLfloat blue
, GLfloat alpha
)
805 FLUSH_VB(ctx
, "dlist");
806 n
= alloc_instruction( ctx
, OPCODE_CLEAR_ACCUM
, 4 );
813 if (ctx
->ExecuteFlag
) {
814 (*ctx
->Exec
.ClearAccum
)( ctx
, red
, green
, blue
, alpha
);
819 static void save_ClearColor( GLcontext
*ctx
, GLclampf red
, GLclampf green
,
820 GLclampf blue
, GLclampf alpha
)
823 FLUSH_VB(ctx
, "dlist");
824 n
= alloc_instruction( ctx
, OPCODE_CLEAR_COLOR
, 4 );
831 if (ctx
->ExecuteFlag
) {
832 (*ctx
->Exec
.ClearColor
)( ctx
, red
, green
, blue
, alpha
);
837 static void save_ClearDepth( GLcontext
*ctx
, GLclampd depth
)
840 FLUSH_VB(ctx
, "dlist");
841 n
= alloc_instruction( ctx
, OPCODE_CLEAR_DEPTH
, 1 );
843 n
[1].f
= (GLfloat
) depth
;
845 if (ctx
->ExecuteFlag
) {
846 (*ctx
->Exec
.ClearDepth
)( ctx
, depth
);
851 static void save_ClearIndex( GLcontext
*ctx
, GLfloat c
)
854 FLUSH_VB(ctx
, "dlist");
855 n
= alloc_instruction( ctx
, OPCODE_CLEAR_INDEX
, 1 );
859 if (ctx
->ExecuteFlag
) {
860 (*ctx
->Exec
.ClearIndex
)( ctx
, c
);
865 static void save_ClearStencil( GLcontext
*ctx
, GLint s
)
868 FLUSH_VB(ctx
, "dlist");
869 n
= alloc_instruction( ctx
, OPCODE_CLEAR_STENCIL
, 1 );
873 if (ctx
->ExecuteFlag
) {
874 (*ctx
->Exec
.ClearStencil
)( ctx
, s
);
879 static void save_ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*equ
)
882 FLUSH_VB(ctx
, "dlist");
883 n
= alloc_instruction( ctx
, OPCODE_CLIP_PLANE
, 5 );
891 if (ctx
->ExecuteFlag
) {
892 (*ctx
->Exec
.ClipPlane
)( ctx
, plane
, equ
);
898 static void save_ColorMask( GLcontext
*ctx
, GLboolean red
, GLboolean green
,
899 GLboolean blue
, GLboolean alpha
)
902 FLUSH_VB(ctx
, "dlist");
903 n
= alloc_instruction( ctx
, OPCODE_COLOR_MASK
, 4 );
910 if (ctx
->ExecuteFlag
) {
911 (*ctx
->Exec
.ColorMask
)( ctx
, red
, green
, blue
, alpha
);
916 static void save_ColorMaterial( GLcontext
*ctx
, GLenum face
, GLenum mode
)
919 FLUSH_VB(ctx
, "dlist");
920 n
= alloc_instruction( ctx
, OPCODE_COLOR_MATERIAL
, 2 );
925 if (ctx
->ExecuteFlag
) {
926 (*ctx
->Exec
.ColorMaterial
)( ctx
, face
, mode
);
931 static void save_ColorTable( GLcontext
*ctx
, GLenum target
, GLenum internalFormat
,
932 struct gl_image
*table
)
935 FLUSH_VB(ctx
, "dlist");
936 n
= alloc_instruction( ctx
, OPCODE_COLOR_TABLE
, 3 );
939 n
[2].e
= internalFormat
;
940 n
[3].data
= (GLvoid
*) table
;
942 /* must retain this image */
946 if (ctx
->ExecuteFlag
) {
947 (*ctx
->Exec
.ColorTable
)( ctx
, target
, internalFormat
, table
);
952 static void save_ColorSubTable( GLcontext
*ctx
, GLenum target
,
953 GLsizei start
, struct gl_image
*data
)
956 FLUSH_VB(ctx
, "dlist");
957 n
= alloc_instruction( ctx
, OPCODE_COLOR_SUB_TABLE
, 3 );
961 n
[3].data
= (GLvoid
*) data
;
963 /* must retain this image */
967 if (ctx
->ExecuteFlag
) {
968 (*ctx
->Exec
.ColorSubTable
)( ctx
, target
, start
, data
);
974 static void save_CopyPixels( GLcontext
*ctx
, GLint x
, GLint y
,
975 GLsizei width
, GLsizei height
, GLenum type
)
978 FLUSH_VB(ctx
, "dlist");
979 n
= alloc_instruction( ctx
, OPCODE_COPY_PIXELS
, 5 );
983 n
[3].i
= (GLint
) width
;
984 n
[4].i
= (GLint
) height
;
987 if (ctx
->ExecuteFlag
) {
988 (*ctx
->Exec
.CopyPixels
)( ctx
, x
, y
, width
, height
, type
);
994 static void save_CopyTexImage1D( GLcontext
*ctx
,
995 GLenum target
, GLint level
,
996 GLenum internalformat
,
997 GLint x
, GLint y
, GLsizei width
,
1001 FLUSH_VB(ctx
, "dlist");
1002 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE1D
, 7 );
1006 n
[3].e
= internalformat
;
1012 if (ctx
->ExecuteFlag
) {
1013 (*ctx
->Exec
.CopyTexImage1D
)( ctx
, target
, level
, internalformat
,
1014 x
, y
, width
, border
);
1019 static void save_CopyTexImage2D( GLcontext
*ctx
,
1020 GLenum target
, GLint level
,
1021 GLenum internalformat
,
1022 GLint x
, GLint y
, GLsizei width
,
1023 GLsizei height
, GLint border
)
1026 FLUSH_VB(ctx
, "dlist");
1027 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_IMAGE2D
, 8 );
1031 n
[3].e
= internalformat
;
1038 if (ctx
->ExecuteFlag
) {
1039 (*ctx
->Exec
.CopyTexImage2D
)( ctx
, target
, level
, internalformat
,
1040 x
, y
, width
, height
, border
);
1046 static void save_CopyTexSubImage1D( GLcontext
*ctx
,
1047 GLenum target
, GLint level
,
1048 GLint xoffset
, GLint x
, GLint y
,
1052 FLUSH_VB(ctx
, "dlist");
1053 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE1D
, 6 );
1062 if (ctx
->ExecuteFlag
) {
1063 (*ctx
->Exec
.CopyTexSubImage1D
)( ctx
, target
, level
, xoffset
, x
, y
, width
);
1068 static void save_CopyTexSubImage2D( GLcontext
*ctx
,
1069 GLenum target
, GLint level
,
1070 GLint xoffset
, GLint yoffset
,
1072 GLsizei width
, GLint height
)
1075 FLUSH_VB(ctx
, "dlist");
1076 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE2D
, 8 );
1087 if (ctx
->ExecuteFlag
) {
1088 (*ctx
->Exec
.CopyTexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
1089 x
, y
, width
, height
);
1094 static void save_CopyTexSubImage3DEXT( GLcontext
*ctx
,
1095 GLenum target
, GLint level
,
1096 GLint xoffset
, GLint yoffset
, GLint zoffset
,
1098 GLsizei width
, GLint height
)
1101 FLUSH_VB(ctx
, "dlist");
1102 n
= alloc_instruction( ctx
, OPCODE_COPY_TEX_SUB_IMAGE3D
, 9 );
1114 if (ctx
->ExecuteFlag
) {
1115 (*ctx
->Exec
.CopyTexSubImage3DEXT
)( ctx
, target
, level
, xoffset
, yoffset
, zoffset
,
1116 x
, y
, width
, height
);
1121 static void save_CullFace( GLcontext
*ctx
, GLenum mode
)
1124 FLUSH_VB(ctx
, "dlist");
1125 n
= alloc_instruction( ctx
, OPCODE_CULL_FACE
, 1 );
1129 if (ctx
->ExecuteFlag
) {
1130 (*ctx
->Exec
.CullFace
)( ctx
, mode
);
1135 static void save_DepthFunc( GLcontext
*ctx
, GLenum func
)
1138 FLUSH_VB(ctx
, "dlist");
1139 n
= alloc_instruction( ctx
, OPCODE_DEPTH_FUNC
, 1 );
1143 if (ctx
->ExecuteFlag
) {
1144 (*ctx
->Exec
.DepthFunc
)( ctx
, func
);
1149 static void save_DepthMask( GLcontext
*ctx
, GLboolean mask
)
1152 FLUSH_VB(ctx
, "dlist");
1153 n
= alloc_instruction( ctx
, OPCODE_DEPTH_MASK
, 1 );
1157 if (ctx
->ExecuteFlag
) {
1158 (*ctx
->Exec
.DepthMask
)( ctx
, mask
);
1163 static void save_DepthRange( GLcontext
*ctx
, GLclampd nearval
, GLclampd farval
)
1166 FLUSH_VB(ctx
, "dlist");
1167 n
= alloc_instruction( ctx
, OPCODE_DEPTH_RANGE
, 2 );
1169 n
[1].f
= (GLfloat
) nearval
;
1170 n
[2].f
= (GLfloat
) farval
;
1172 if (ctx
->ExecuteFlag
) {
1173 (*ctx
->Exec
.DepthRange
)( ctx
, nearval
, farval
);
1178 static void save_Disable( GLcontext
*ctx
, GLenum cap
)
1181 FLUSH_VB(ctx
, "dlist");
1182 n
= alloc_instruction( ctx
, OPCODE_DISABLE
, 1 );
1186 if (ctx
->ExecuteFlag
) {
1187 (*ctx
->Exec
.Disable
)( ctx
, cap
);
1192 static void save_DrawBuffer( GLcontext
*ctx
, GLenum mode
)
1195 FLUSH_VB(ctx
, "dlist");
1196 n
= alloc_instruction( ctx
, OPCODE_DRAW_BUFFER
, 1 );
1200 if (ctx
->ExecuteFlag
) {
1201 (*ctx
->Exec
.DrawBuffer
)( ctx
, mode
);
1206 static void save_DrawPixels( GLcontext
*ctx
, struct gl_image
*image
)
1209 FLUSH_VB(ctx
, "dlist");
1210 n
= alloc_instruction( ctx
, OPCODE_DRAW_PIXELS
, 1 );
1212 n
[1].data
= (GLvoid
*) image
;
1215 image
->RefCount
= 1;
1217 if (ctx
->ExecuteFlag
) {
1218 (*ctx
->Exec
.DrawPixels
)( ctx
, image
);
1224 static void save_Enable( GLcontext
*ctx
, GLenum cap
)
1227 FLUSH_VB(ctx
, "dlist");
1228 n
= alloc_instruction( ctx
, OPCODE_ENABLE
, 1 );
1232 if (ctx
->ExecuteFlag
) {
1233 (*ctx
->Exec
.Enable
)( ctx
, cap
);
1239 static void save_EvalMesh1( GLcontext
*ctx
,
1240 GLenum mode
, GLint i1
, GLint i2
)
1243 FLUSH_VB(ctx
, "dlist");
1244 n
= alloc_instruction( ctx
, OPCODE_EVALMESH1
, 3 );
1250 if (ctx
->ExecuteFlag
) {
1251 (*ctx
->Exec
.EvalMesh1
)( ctx
, mode
, i1
, i2
);
1256 static void save_EvalMesh2( GLcontext
*ctx
,
1257 GLenum mode
, GLint i1
, GLint i2
, GLint j1
, GLint j2
)
1260 FLUSH_VB(ctx
, "dlist");
1261 n
= alloc_instruction( ctx
, OPCODE_EVALMESH2
, 5 );
1269 if (ctx
->ExecuteFlag
) {
1270 (*ctx
->Exec
.EvalMesh2
)( ctx
, mode
, i1
, i2
, j1
, j2
);
1277 static void save_Fogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*params
)
1280 FLUSH_VB(ctx
, "dlist");
1281 n
= alloc_instruction( ctx
, OPCODE_FOG
, 5 );
1289 if (ctx
->ExecuteFlag
) {
1290 (*ctx
->Exec
.Fogfv
)( ctx
, pname
, params
);
1295 static void save_FrontFace( GLcontext
*ctx
, GLenum mode
)
1298 FLUSH_VB(ctx
, "dlist");
1299 n
= alloc_instruction( ctx
, OPCODE_FRONT_FACE
, 1 );
1303 if (ctx
->ExecuteFlag
) {
1304 (*ctx
->Exec
.FrontFace
)( ctx
, mode
);
1309 static void save_Frustum( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1310 GLdouble bottom
, GLdouble top
,
1311 GLdouble nearval
, GLdouble farval
)
1314 FLUSH_VB(ctx
, "dlist");
1315 n
= alloc_instruction( ctx
, OPCODE_FRUSTUM
, 6 );
1324 if (ctx
->ExecuteFlag
) {
1325 (*ctx
->Exec
.Frustum
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1330 static GLboolean
save_Hint( GLcontext
*ctx
, GLenum target
, GLenum mode
)
1333 FLUSH_VB(ctx
, "dlist");
1334 n
= alloc_instruction( ctx
, OPCODE_HINT
, 2 );
1339 if (ctx
->ExecuteFlag
) {
1340 return (*ctx
->Exec
.Hint
)( ctx
, target
, mode
);
1342 return GL_TRUE
; /* not queried */
1347 static void save_IndexMask( GLcontext
*ctx
, GLuint mask
)
1350 FLUSH_VB(ctx
, "dlist");
1351 n
= alloc_instruction( ctx
, OPCODE_INDEX_MASK
, 1 );
1355 if (ctx
->ExecuteFlag
) {
1356 (*ctx
->Exec
.IndexMask
)( ctx
, mask
);
1361 static void save_InitNames( GLcontext
*ctx
)
1363 FLUSH_VB(ctx
, "dlist");
1364 (void) alloc_instruction( ctx
, OPCODE_INIT_NAMES
, 0 );
1365 if (ctx
->ExecuteFlag
) {
1366 (*ctx
->Exec
.InitNames
)( ctx
);
1371 static void save_Lightfv( GLcontext
*ctx
, GLenum light
, GLenum pname
,
1372 const GLfloat
*params
, GLint numparams
)
1375 FLUSH_VB(ctx
, "dlist");
1376 n
= alloc_instruction( ctx
, OPCODE_LIGHT
, 6 );
1381 for (i
=0;i
<numparams
;i
++) {
1382 n
[3+i
].f
= params
[i
];
1385 if (ctx
->ExecuteFlag
) {
1386 (*ctx
->Exec
.Lightfv
)( ctx
, light
, pname
, params
, numparams
);
1391 static void save_LightModelfv( GLcontext
*ctx
,
1392 GLenum pname
, const GLfloat
*params
)
1395 FLUSH_VB(ctx
, "dlist");
1396 n
= alloc_instruction( ctx
, OPCODE_LIGHT_MODEL
, 5 );
1404 if (ctx
->ExecuteFlag
) {
1405 (*ctx
->Exec
.LightModelfv
)( ctx
, pname
, params
);
1410 static void save_LineStipple( GLcontext
*ctx
, GLint factor
, GLushort pattern
)
1413 FLUSH_VB(ctx
, "dlist");
1414 n
= alloc_instruction( ctx
, OPCODE_LINE_STIPPLE
, 2 );
1419 if (ctx
->ExecuteFlag
) {
1420 (*ctx
->Exec
.LineStipple
)( ctx
, factor
, pattern
);
1425 static void save_LineWidth( GLcontext
*ctx
, GLfloat width
)
1428 FLUSH_VB(ctx
, "dlist");
1429 n
= alloc_instruction( ctx
, OPCODE_LINE_WIDTH
, 1 );
1433 if (ctx
->ExecuteFlag
) {
1434 (*ctx
->Exec
.LineWidth
)( ctx
, width
);
1439 static void save_ListBase( GLcontext
*ctx
, GLuint base
)
1442 FLUSH_VB(ctx
, "dlist");
1443 n
= alloc_instruction( ctx
, OPCODE_LIST_BASE
, 1 );
1447 if (ctx
->ExecuteFlag
) {
1448 (*ctx
->Exec
.ListBase
)( ctx
, base
);
1453 static void save_LoadIdentity( GLcontext
*ctx
)
1455 FLUSH_VB(ctx
, "dlist");
1456 (void) alloc_instruction( ctx
, OPCODE_LOAD_IDENTITY
, 0 );
1457 if (ctx
->ExecuteFlag
) {
1458 (*ctx
->Exec
.LoadIdentity
)( ctx
);
1463 static void save_LoadMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1466 FLUSH_VB(ctx
, "dlist");
1467 n
= alloc_instruction( ctx
, OPCODE_LOAD_MATRIX
, 16 );
1470 for (i
=0;i
<16;i
++) {
1474 if (ctx
->ExecuteFlag
) {
1475 (*ctx
->Exec
.LoadMatrixf
)( ctx
, m
);
1480 static void save_LoadName( GLcontext
*ctx
, GLuint name
)
1483 FLUSH_VB(ctx
, "dlist");
1484 n
= alloc_instruction( ctx
, OPCODE_LOAD_NAME
, 1 );
1488 if (ctx
->ExecuteFlag
) {
1489 (*ctx
->Exec
.LoadName
)( ctx
, name
);
1494 static void save_LogicOp( GLcontext
*ctx
, GLenum opcode
)
1497 FLUSH_VB(ctx
, "dlist");
1498 n
= alloc_instruction( ctx
, OPCODE_LOGIC_OP
, 1 );
1502 if (ctx
->ExecuteFlag
) {
1503 (*ctx
->Exec
.LogicOp
)( ctx
, opcode
);
1508 static void save_Map1f( GLcontext
*ctx
,
1509 GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
1510 GLint order
, const GLfloat
*points
, GLboolean retain
)
1513 FLUSH_VB(ctx
, "dlist");
1514 n
= alloc_instruction( ctx
, OPCODE_MAP1
, 6 );
1521 n
[6].data
= (void *) points
;
1523 if (ctx
->ExecuteFlag
) {
1524 (*ctx
->Exec
.Map1f
)( ctx
, target
, u1
, u2
, stride
, order
, points
, GL_TRUE
);
1530 static void save_Map2f( GLcontext
*ctx
, GLenum target
,
1531 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
1532 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
1533 const GLfloat
*points
, GLboolean retain
)
1536 FLUSH_VB(ctx
, "dlist");
1537 n
= alloc_instruction( ctx
, OPCODE_MAP2
, 10 );
1548 n
[10].data
= (void *) points
;
1550 if (ctx
->ExecuteFlag
) {
1551 (*ctx
->Exec
.Map2f
)( ctx
, target
,
1552 u1
, u2
, ustride
, uorder
,
1553 v1
, v2
, vstride
, vorder
, points
, GL_TRUE
);
1559 static void save_MapGrid1f( GLcontext
*ctx
, GLint un
, GLfloat u1
, GLfloat u2
)
1562 FLUSH_VB(ctx
, "dlist");
1563 n
= alloc_instruction( ctx
, OPCODE_MAPGRID1
, 3 );
1569 if (ctx
->ExecuteFlag
) {
1570 (*ctx
->Exec
.MapGrid1f
)( ctx
, un
, u1
, u2
);
1575 static void save_MapGrid2f( GLcontext
*ctx
,
1576 GLint un
, GLfloat u1
, GLfloat u2
,
1577 GLint vn
, GLfloat v1
, GLfloat v2
)
1580 FLUSH_VB(ctx
, "dlist");
1581 n
= alloc_instruction( ctx
, OPCODE_MAPGRID2
, 6 );
1590 if (ctx
->ExecuteFlag
) {
1591 (*ctx
->Exec
.MapGrid2f
)( ctx
, un
, u1
, u2
, vn
, v1
, v2
);
1596 static void save_MatrixMode( GLcontext
*ctx
, GLenum mode
)
1599 FLUSH_VB(ctx
, "dlist");
1600 n
= alloc_instruction( ctx
, OPCODE_MATRIX_MODE
, 1 );
1604 if (ctx
->ExecuteFlag
) {
1605 (*ctx
->Exec
.MatrixMode
)( ctx
, mode
);
1610 static void save_MultMatrixf( GLcontext
*ctx
, const GLfloat
*m
)
1613 FLUSH_VB(ctx
, "dlist");
1614 n
= alloc_instruction( ctx
, OPCODE_MULT_MATRIX
, 16 );
1617 for (i
=0;i
<16;i
++) {
1621 if (ctx
->ExecuteFlag
) {
1622 (*ctx
->Exec
.MultMatrixf
)( ctx
, m
);
1627 static void save_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
1629 /* It's an error to call this function while building a display list */
1630 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
1637 static void save_Ortho( GLcontext
*ctx
, GLdouble left
, GLdouble right
,
1638 GLdouble bottom
, GLdouble top
,
1639 GLdouble nearval
, GLdouble farval
)
1642 FLUSH_VB(ctx
, "dlist");
1643 n
= alloc_instruction( ctx
, OPCODE_ORTHO
, 6 );
1652 if (ctx
->ExecuteFlag
) {
1653 (*ctx
->Exec
.Ortho
)( ctx
, left
, right
, bottom
, top
, nearval
, farval
);
1658 static void save_PixelMapfv( GLcontext
*ctx
,
1659 GLenum map
, GLint mapsize
, const GLfloat
*values
)
1662 FLUSH_VB(ctx
, "dlist");
1663 n
= alloc_instruction( ctx
, OPCODE_PIXEL_MAP
, 3 );
1667 n
[3].data
= (void *) malloc( mapsize
* sizeof(GLfloat
) );
1668 MEMCPY( n
[3].data
, (void *) values
, mapsize
* sizeof(GLfloat
) );
1670 if (ctx
->ExecuteFlag
) {
1671 (*ctx
->Exec
.PixelMapfv
)( ctx
, map
, mapsize
, values
);
1676 static void save_PixelTransferf( GLcontext
*ctx
, GLenum pname
, GLfloat param
)
1679 FLUSH_VB(ctx
, "dlist");
1680 n
= alloc_instruction( ctx
, OPCODE_PIXEL_TRANSFER
, 2 );
1685 if (ctx
->ExecuteFlag
) {
1686 (*ctx
->Exec
.PixelTransferf
)( ctx
, pname
, param
);
1691 static void save_PixelZoom( GLcontext
*ctx
, GLfloat xfactor
, GLfloat yfactor
)
1694 FLUSH_VB(ctx
, "dlist");
1695 n
= alloc_instruction( ctx
, OPCODE_PIXEL_ZOOM
, 2 );
1700 if (ctx
->ExecuteFlag
) {
1701 (*ctx
->Exec
.PixelZoom
)( ctx
, xfactor
, yfactor
);
1706 static void save_PointParameterfvEXT( GLcontext
*ctx
, GLenum pname
,
1707 const GLfloat
*params
)
1710 FLUSH_VB(ctx
, "dlist");
1711 n
= alloc_instruction( ctx
, OPCODE_POINT_PARAMETERS
, 4 );
1718 if (ctx
->ExecuteFlag
) {
1719 (*ctx
->Exec
.PointParameterfvEXT
)( ctx
, pname
, params
);
1724 static void save_PointSize( GLcontext
*ctx
, GLfloat size
)
1727 FLUSH_VB(ctx
, "dlist");
1728 n
= alloc_instruction( ctx
, OPCODE_POINT_SIZE
, 1 );
1732 if (ctx
->ExecuteFlag
) {
1733 (*ctx
->Exec
.PointSize
)( ctx
, size
);
1738 static void save_PolygonMode( GLcontext
*ctx
, GLenum face
, GLenum mode
)
1741 FLUSH_VB(ctx
, "dlist");
1742 n
= alloc_instruction( ctx
, OPCODE_POLYGON_MODE
, 2 );
1747 if (ctx
->ExecuteFlag
) {
1748 (*ctx
->Exec
.PolygonMode
)( ctx
, face
, mode
);
1754 * Polygon stipple must have been upacked already!
1756 static void save_PolygonStipple( GLcontext
*ctx
, const GLuint
*pattern
)
1759 FLUSH_VB(ctx
, "dlist");
1760 n
= alloc_instruction( ctx
, OPCODE_POLYGON_STIPPLE
, 1 );
1763 n
[1].data
= malloc( 32 * 4 );
1764 data
= n
[1].data
; /* This needed for Acorn compiler */
1765 MEMCPY( data
, pattern
, 32 * 4 );
1767 if (ctx
->ExecuteFlag
) {
1768 (*ctx
->Exec
.PolygonStipple
)( ctx
, pattern
);
1773 static void save_PolygonOffset( GLcontext
*ctx
, GLfloat factor
, GLfloat units
)
1776 FLUSH_VB(ctx
, "dlist");
1777 n
= alloc_instruction( ctx
, OPCODE_POLYGON_OFFSET
, 2 );
1782 if (ctx
->ExecuteFlag
) {
1783 (*ctx
->Exec
.PolygonOffset
)( ctx
, factor
, units
);
1788 static void save_PopAttrib( GLcontext
*ctx
)
1790 FLUSH_VB(ctx
, "dlist");
1791 (void) alloc_instruction( ctx
, OPCODE_POP_ATTRIB
, 0 );
1792 if (ctx
->ExecuteFlag
) {
1793 (*ctx
->Exec
.PopAttrib
)( ctx
);
1798 static void save_PopMatrix( GLcontext
*ctx
)
1800 FLUSH_VB(ctx
, "dlist");
1801 (void) alloc_instruction( ctx
, OPCODE_POP_MATRIX
, 0 );
1802 if (ctx
->ExecuteFlag
) {
1803 (*ctx
->Exec
.PopMatrix
)( ctx
);
1808 static void save_PopName( GLcontext
*ctx
)
1810 FLUSH_VB(ctx
, "dlist");
1811 (void) alloc_instruction( ctx
, OPCODE_POP_NAME
, 0 );
1812 if (ctx
->ExecuteFlag
) {
1813 (*ctx
->Exec
.PopName
)( ctx
);
1818 static void save_PrioritizeTextures( GLcontext
*ctx
,
1819 GLsizei num
, const GLuint
*textures
,
1820 const GLclampf
*priorities
)
1823 FLUSH_VB(ctx
, "dlist");
1825 for (i
=0;i
<num
;i
++) {
1827 n
= alloc_instruction( ctx
, OPCODE_PRIORITIZE_TEXTURE
, 2 );
1829 n
[1].ui
= textures
[i
];
1830 n
[2].f
= priorities
[i
];
1833 if (ctx
->ExecuteFlag
) {
1834 (*ctx
->Exec
.PrioritizeTextures
)( ctx
, num
, textures
, priorities
);
1839 static void save_PushAttrib( GLcontext
*ctx
, GLbitfield mask
)
1842 FLUSH_VB(ctx
, "dlist");
1843 n
= alloc_instruction( ctx
, OPCODE_PUSH_ATTRIB
, 1 );
1847 if (ctx
->ExecuteFlag
) {
1848 (*ctx
->Exec
.PushAttrib
)( ctx
, mask
);
1853 static void save_PushMatrix( GLcontext
*ctx
)
1855 FLUSH_VB(ctx
, "dlist");
1856 (void) alloc_instruction( ctx
, OPCODE_PUSH_MATRIX
, 0 );
1857 if (ctx
->ExecuteFlag
) {
1858 (*ctx
->Exec
.PushMatrix
)( ctx
);
1863 static void save_PushName( GLcontext
*ctx
, GLuint name
)
1866 FLUSH_VB(ctx
, "dlist");
1867 n
= alloc_instruction( ctx
, OPCODE_PUSH_NAME
, 1 );
1871 if (ctx
->ExecuteFlag
) {
1872 (*ctx
->Exec
.PushName
)( ctx
, name
);
1877 static void save_RasterPos4f( GLcontext
*ctx
,
1878 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
1881 FLUSH_VB(ctx
, "dlist");
1882 n
= alloc_instruction( ctx
, OPCODE_RASTER_POS
, 4 );
1889 if (ctx
->ExecuteFlag
) {
1890 (*ctx
->Exec
.RasterPos4f
)( ctx
, x
, y
, z
, w
);
1895 static void save_PassThrough( GLcontext
*ctx
, GLfloat token
)
1898 FLUSH_VB(ctx
, "dlist");
1899 n
= alloc_instruction( ctx
, OPCODE_PASSTHROUGH
, 1 );
1903 if (ctx
->ExecuteFlag
) {
1904 (*ctx
->Exec
.PassThrough
)( ctx
, token
);
1909 static void save_ReadBuffer( GLcontext
*ctx
, GLenum mode
)
1912 FLUSH_VB(ctx
, "dlist");
1913 n
= alloc_instruction( ctx
, OPCODE_READ_BUFFER
, 1 );
1917 if (ctx
->ExecuteFlag
) {
1918 (*ctx
->Exec
.ReadBuffer
)( ctx
, mode
);
1923 static void save_Rectf( GLcontext
*ctx
,
1924 GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
1927 FLUSH_VB(ctx
, "dlist");
1928 n
= alloc_instruction( ctx
, OPCODE_RECTF
, 4 );
1935 if (ctx
->ExecuteFlag
) {
1936 (*ctx
->Exec
.Rectf
)( ctx
, x1
, y1
, x2
, y2
);
1941 static void save_Rotatef( GLcontext
*ctx
, GLfloat angle
,
1942 GLfloat x
, GLfloat y
, GLfloat z
)
1945 gl_rotation_matrix( angle
, x
, y
, z
, m
);
1946 save_MultMatrixf( ctx
, m
); /* save and maybe execute */
1950 static void save_Scalef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
1953 FLUSH_VB(ctx
, "dlist");
1954 n
= alloc_instruction( ctx
, OPCODE_SCALE
, 3 );
1960 if (ctx
->ExecuteFlag
) {
1961 (*ctx
->Exec
.Scalef
)( ctx
, x
, y
, z
);
1966 static void save_Scissor( GLcontext
*ctx
,
1967 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1970 FLUSH_VB(ctx
, "dlist");
1971 n
= alloc_instruction( ctx
, OPCODE_SCISSOR
, 4 );
1978 if (ctx
->ExecuteFlag
) {
1979 (*ctx
->Exec
.Scissor
)( ctx
, x
, y
, width
, height
);
1984 static void save_ShadeModel( GLcontext
*ctx
, GLenum mode
)
1987 FLUSH_VB(ctx
, "dlist");
1988 n
= alloc_instruction( ctx
, OPCODE_SHADE_MODEL
, 1 );
1992 if (ctx
->ExecuteFlag
) {
1993 (*ctx
->Exec
.ShadeModel
)( ctx
, mode
);
1998 static void save_StencilFunc( GLcontext
*ctx
, GLenum func
, GLint ref
, GLuint mask
)
2001 FLUSH_VB(ctx
, "dlist");
2002 n
= alloc_instruction( ctx
, OPCODE_STENCIL_FUNC
, 3 );
2008 if (ctx
->ExecuteFlag
) {
2009 (*ctx
->Exec
.StencilFunc
)( ctx
, func
, ref
, mask
);
2014 static void save_StencilMask( GLcontext
*ctx
, GLuint mask
)
2017 FLUSH_VB(ctx
, "dlist");
2018 n
= alloc_instruction( ctx
, OPCODE_STENCIL_MASK
, 1 );
2022 if (ctx
->ExecuteFlag
) {
2023 (*ctx
->Exec
.StencilMask
)( ctx
, mask
);
2028 static void save_StencilOp( GLcontext
*ctx
,
2029 GLenum fail
, GLenum zfail
, GLenum zpass
)
2032 FLUSH_VB(ctx
, "dlist");
2033 n
= alloc_instruction( ctx
, OPCODE_STENCIL_OP
, 3 );
2039 if (ctx
->ExecuteFlag
) {
2040 (*ctx
->Exec
.StencilOp
)( ctx
, fail
, zfail
, zpass
);
2047 static void save_TexEnvfv( GLcontext
*ctx
,
2048 GLenum target
, GLenum pname
, const GLfloat
*params
)
2051 FLUSH_VB(ctx
, "dlist");
2052 n
= alloc_instruction( ctx
, OPCODE_TEXENV
, 6 );
2061 if (ctx
->ExecuteFlag
) {
2062 (*ctx
->Exec
.TexEnvfv
)( ctx
, target
, pname
, params
);
2067 static void save_TexGenfv( GLcontext
*ctx
,
2068 GLenum coord
, GLenum pname
, const GLfloat
*params
)
2071 FLUSH_VB(ctx
, "dlist");
2072 n
= alloc_instruction( ctx
, OPCODE_TEXGEN
, 6 );
2081 if (ctx
->ExecuteFlag
) {
2082 (*ctx
->Exec
.TexGenfv
)( ctx
, coord
, pname
, params
);
2087 static void save_TexParameterfv( GLcontext
*ctx
, GLenum target
,
2088 GLenum pname
, const GLfloat
*params
)
2091 FLUSH_VB(ctx
, "dlist");
2092 n
= alloc_instruction( ctx
, OPCODE_TEXPARAMETER
, 6 );
2101 if (ctx
->ExecuteFlag
) {
2102 (*ctx
->Exec
.TexParameterfv
)( ctx
, target
, pname
, params
);
2107 static void save_TexImage1D( GLcontext
*ctx
, GLenum target
,
2108 GLint level
, GLint components
,
2109 GLsizei width
, GLint border
,
2110 GLenum format
, GLenum type
,
2111 struct gl_image
*teximage
)
2114 FLUSH_VB(ctx
, "dlist");
2115 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE1D
, 8 );
2119 n
[3].i
= components
;
2120 n
[4].i
= (GLint
) width
;
2124 n
[8].data
= teximage
;
2126 /* this prevents gl_TexImage2D() from freeing the image */
2127 teximage
->RefCount
= 1;
2130 if (ctx
->ExecuteFlag
) {
2131 (*ctx
->Exec
.TexImage1D
)( ctx
, target
, level
, components
, width
,
2132 border
, format
, type
, teximage
);
2137 static void save_TexImage2D( GLcontext
*ctx
, GLenum target
,
2138 GLint level
, GLint components
,
2139 GLsizei width
, GLsizei height
, GLint border
,
2140 GLenum format
, GLenum type
,
2141 struct gl_image
*teximage
)
2144 FLUSH_VB(ctx
, "dlist");
2145 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE2D
, 9 );
2149 n
[3].i
= components
;
2150 n
[4].i
= (GLint
) width
;
2151 n
[5].i
= (GLint
) height
;
2155 n
[9].data
= teximage
;
2157 /* this prevents gl_TexImage2D() from freeing the image */
2158 teximage
->RefCount
= 1;
2161 if (ctx
->ExecuteFlag
) {
2162 (*ctx
->Exec
.TexImage2D
)( ctx
, target
, level
, components
, width
,
2163 height
, border
, format
, type
, teximage
);
2168 static void save_TexImage3DEXT( GLcontext
*ctx
, GLenum target
,
2169 GLint level
, GLint components
,
2170 GLsizei width
, GLsizei height
, GLsizei depth
,
2172 GLenum format
, GLenum type
,
2173 struct gl_image
*teximage
)
2176 FLUSH_VB(ctx
, "dlist");
2177 n
= alloc_instruction( ctx
, OPCODE_TEX_IMAGE3D
, 10 );
2181 n
[3].i
= components
;
2182 n
[4].i
= (GLint
) width
;
2183 n
[5].i
= (GLint
) height
;
2184 n
[6].i
= (GLint
) depth
;
2188 n
[10].data
= teximage
;
2190 if (ctx
->ExecuteFlag
) {
2191 (*ctx
->Exec
.TexImage3DEXT
)( ctx
, target
, level
, components
, width
,
2192 height
, depth
, border
, format
, type
, teximage
);
2197 static void save_TexSubImage1D( GLcontext
*ctx
,
2198 GLenum target
, GLint level
, GLint xoffset
,
2199 GLsizei width
, GLenum format
, GLenum type
,
2200 struct gl_image
*image
)
2203 FLUSH_VB(ctx
, "dlist");
2204 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE1D
, 7 );
2209 n
[4].i
= (GLint
) width
;
2214 image
->RefCount
= 1;
2216 if (ctx
->ExecuteFlag
) {
2217 (*ctx
->Exec
.TexSubImage1D
)( ctx
, target
, level
, xoffset
, width
,
2218 format
, type
, image
);
2223 static void save_TexSubImage2D( GLcontext
*ctx
,
2224 GLenum target
, GLint level
,
2225 GLint xoffset
, GLint yoffset
,
2226 GLsizei width
, GLsizei height
,
2227 GLenum format
, GLenum type
,
2228 struct gl_image
*image
)
2231 FLUSH_VB(ctx
, "dlist");
2232 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE2D
, 9 );
2238 n
[5].i
= (GLint
) width
;
2239 n
[6].i
= (GLint
) height
;
2244 image
->RefCount
= 1;
2246 if (ctx
->ExecuteFlag
) {
2247 (*ctx
->Exec
.TexSubImage2D
)( ctx
, target
, level
, xoffset
, yoffset
,
2248 width
, height
, format
, type
, image
);
2253 static void save_TexSubImage3DEXT( GLcontext
*ctx
,
2254 GLenum target
, GLint level
,
2255 GLint xoffset
, GLint yoffset
,GLint zoffset
,
2256 GLsizei width
, GLsizei height
, GLsizei depth
,
2257 GLenum format
, GLenum type
,
2258 struct gl_image
*image
)
2261 FLUSH_VB(ctx
, "dlist");
2262 n
= alloc_instruction( ctx
, OPCODE_TEX_SUB_IMAGE3D
, 11 );
2269 n
[6].i
= (GLint
) width
;
2270 n
[7].i
= (GLint
) height
;
2271 n
[8].i
= (GLint
) depth
;
2276 image
->RefCount
= 1;
2278 if (ctx
->ExecuteFlag
) {
2279 (*ctx
->Exec
.TexSubImage3DEXT
)( ctx
, target
, level
, xoffset
, yoffset
, zoffset
,
2280 width
, height
, depth
, format
, type
, image
);
2285 static void save_Translatef( GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
)
2288 FLUSH_VB(ctx
, "dlist");
2289 n
= alloc_instruction( ctx
, OPCODE_TRANSLATE
, 3 );
2295 if (ctx
->ExecuteFlag
) {
2296 (*ctx
->Exec
.Translatef
)( ctx
, x
, y
, z
);
2302 static void save_Viewport( GLcontext
*ctx
,
2303 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
2306 FLUSH_VB(ctx
, "dlist");
2307 n
= alloc_instruction( ctx
, OPCODE_VIEWPORT
, 4 );
2311 n
[3].i
= (GLint
) width
;
2312 n
[4].i
= (GLint
) height
;
2314 if (ctx
->ExecuteFlag
) {
2315 (*ctx
->Exec
.Viewport
)( ctx
, x
, y
, width
, height
);
2320 static void save_WindowPos4fMESA( GLcontext
*ctx
,
2321 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
2324 FLUSH_VB(ctx
, "dlist");
2325 n
= alloc_instruction( ctx
, OPCODE_WINDOW_POS
, 4 );
2332 if (ctx
->ExecuteFlag
) {
2333 (*ctx
->Exec
.WindowPos4fMESA
)( ctx
, x
, y
, z
, w
);
2342 /* GL_ARB_multitexture */
2343 static void save_ActiveTexture( GLcontext
*ctx
, GLenum target
)
2346 FLUSH_VB(ctx
, "dlist");
2347 n
= alloc_instruction( ctx
, OPCODE_ACTIVE_TEXTURE
, 1 );
2351 if (ctx
->ExecuteFlag
) {
2352 (*ctx
->Exec
.ActiveTexture
)( ctx
, target
);
2357 /* GL_ARB_multitexture */
2358 static void save_ClientActiveTexture( GLcontext
*ctx
, GLenum target
)
2361 FLUSH_VB(ctx
, "dlist");
2362 n
= alloc_instruction( ctx
, OPCODE_CLIENT_ACTIVE_TEXTURE
, 1 );
2366 if (ctx
->ExecuteFlag
) {
2367 (*ctx
->Exec
.ClientActiveTexture
)( ctx
, target
);
2375 void gl_compile_cassette( GLcontext
*ctx
)
2377 Node
*n
= alloc_instruction( ctx
, OPCODE_VERTEX_CASSETTE
, 1 );
2378 struct immediate
*new_im
= gl_immediate_alloc(ctx
);
2379 struct immediate
*im
= ctx
->input
;
2381 if (!n
|| !new_im
) {
2383 if (new_im
) gl_immediate_free(new_im
);
2387 /* Do some easy optimizations of the cassette.
2389 if (im
->v
.Obj
.size
< 4 &&
2392 im
->Bounds
= (GLfloat (*)[3]) malloc(6 * sizeof(GLfloat
));
2393 (gl_calc_bound_tab
[im
->v
.Obj
.size
])( im
->Bounds
, &im
->v
.Obj
);
2397 n
[1].data
= (void *)im
;
2398 SET_IMMEDIATE( ctx
, new_im
);
2401 /* KW: Compile commands
2403 * Will appear in the list before the vertex buffer containing the
2404 * command that provoked the error. I don't see this as a problem.
2406 void gl_save_error( GLcontext
*ctx
, GLenum error
, const char *s
)
2409 n
= alloc_instruction( ctx
, OPCODE_ERROR
, 2 );
2412 n
[2].data
= (void *) s
;
2414 /* execute already done */
2417 /**********************************************************************/
2418 /* Display list execution */
2419 /**********************************************************************/
2423 * Execute a display list. Note that the ListBase offset must have already
2424 * been added before calling this function. I.e. the list argument is
2425 * the absolute list number, not relative to ListBase.
2426 * Input: list - display list number
2428 static void execute_list( GLcontext
*ctx
, GLuint list
)
2434 if (!gl_IsList(ctx
,list
))
2437 /* mesa_print_display_list( list ); */
2441 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
2445 opcode
= n
[0].opcode
;
2449 gl_error( ctx
, n
[1].e
, (const char *) n
[2].data
);
2451 case OPCODE_VERTEX_CASSETTE
:
2453 gl_update_state(ctx
);
2454 if (ctx
->CompileCVAFlag
) {
2455 ctx
->CompileCVAFlag
= 0;
2456 ctx
->CVA
.elt
.pipeline_valid
= 0;
2458 if (!ctx
->CVA
.elt
.pipeline_valid
)
2459 gl_build_immediate_pipeline( ctx
);
2460 gl_fixup_cassette( ctx
, (struct immediate
*) n
[1].data
);
2461 gl_execute_cassette( ctx
, (struct immediate
*) n
[1].data
);
2464 gl_Accum( ctx
, n
[1].e
, n
[2].f
);
2466 case OPCODE_ALPHA_FUNC
:
2467 gl_AlphaFunc( ctx
, n
[1].e
, n
[2].f
);
2469 case OPCODE_BIND_TEXTURE
:
2470 gl_BindTexture( ctx
, n
[1].e
, n
[2].ui
);
2474 static struct gl_pixelstore_attrib defaultPacking
= {
2479 0, /* ImageHeight */
2481 GL_FALSE
, /* SwapBytes */
2482 GL_FALSE
/* LsbFirst */
2484 const struct gl_image
*image
= (struct gl_image
*) n
[7].data
;
2485 const GLubyte
*bitmap
= image
? image
->Data
: NULL
;
2486 gl_Bitmap( ctx
, (GLsizei
) n
[1].i
, (GLsizei
) n
[2].i
,
2487 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
,
2488 bitmap
, &defaultPacking
);
2491 case OPCODE_BLEND_COLOR
:
2492 gl_BlendColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2494 case OPCODE_BLEND_EQUATION
:
2495 gl_BlendEquation( ctx
, n
[1].e
);
2497 case OPCODE_BLEND_FUNC
:
2498 gl_BlendFunc( ctx
, n
[1].e
, n
[2].e
);
2500 case OPCODE_BLEND_FUNC_SEPARATE
:
2501 gl_BlendFuncSeparate( ctx
, n
[1].e
, n
[2].e
, n
[3].e
, n
[4].e
);
2503 case OPCODE_CALL_LIST
:
2504 /* Generated by glCallList(), don't add ListBase */
2505 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2506 execute_list( ctx
, n
[1].ui
);
2509 case OPCODE_CALL_LIST_OFFSET
:
2510 /* Generated by glCallLists() so we must add ListBase */
2511 if (ctx
->CallDepth
<MAX_LIST_NESTING
) {
2512 execute_list( ctx
, ctx
->List
.ListBase
+ n
[1].ui
);
2516 gl_Clear( ctx
, n
[1].bf
);
2518 case OPCODE_CLEAR_COLOR
:
2519 gl_ClearColor( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2521 case OPCODE_CLEAR_ACCUM
:
2522 gl_ClearAccum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2524 case OPCODE_CLEAR_DEPTH
:
2525 gl_ClearDepth( ctx
, (GLclampd
) n
[1].f
);
2527 case OPCODE_CLEAR_INDEX
:
2528 gl_ClearIndex( ctx
, n
[1].ui
);
2530 case OPCODE_CLEAR_STENCIL
:
2531 gl_ClearStencil( ctx
, n
[1].i
);
2533 case OPCODE_CLIP_PLANE
:
2540 gl_ClipPlane( ctx
, n
[1].e
, equ
);
2543 case OPCODE_COLOR_MASK
:
2544 gl_ColorMask( ctx
, n
[1].b
, n
[2].b
, n
[3].b
, n
[4].b
);
2546 case OPCODE_COLOR_MATERIAL
:
2547 gl_ColorMaterial( ctx
, n
[1].e
, n
[2].e
);
2549 case OPCODE_COLOR_TABLE
:
2550 gl_ColorTable( ctx
, n
[1].e
, n
[2].e
, (struct gl_image
*) n
[3].data
);
2552 case OPCODE_COLOR_SUB_TABLE
:
2553 gl_ColorSubTable( ctx
, n
[1].e
, n
[2].i
,
2554 (struct gl_image
*) n
[3].data
);
2556 case OPCODE_COPY_PIXELS
:
2557 gl_CopyPixels( ctx
, n
[1].i
, n
[2].i
,
2558 (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
, n
[5].e
);
2560 case OPCODE_COPY_TEX_IMAGE1D
:
2561 gl_CopyTexImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2562 n
[5].i
, n
[6].i
, n
[7].i
);
2564 case OPCODE_COPY_TEX_IMAGE2D
:
2565 gl_CopyTexImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].e
, n
[4].i
,
2566 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2568 case OPCODE_COPY_TEX_SUB_IMAGE1D
:
2569 gl_CopyTexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2572 case OPCODE_COPY_TEX_SUB_IMAGE2D
:
2573 gl_CopyTexSubImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2574 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
);
2576 case OPCODE_COPY_TEX_SUB_IMAGE3D
:
2577 gl_CopyTexSubImage3DEXT( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
,
2578 n
[5].i
, n
[6].i
, n
[7].i
, n
[8].i
, n
[9].i
);
2580 case OPCODE_CULL_FACE
:
2581 gl_CullFace( ctx
, n
[1].e
);
2583 case OPCODE_DEPTH_FUNC
:
2584 gl_DepthFunc( ctx
, n
[1].e
);
2586 case OPCODE_DEPTH_MASK
:
2587 gl_DepthMask( ctx
, n
[1].b
);
2589 case OPCODE_DEPTH_RANGE
:
2590 gl_DepthRange( ctx
, (GLclampd
) n
[1].f
, (GLclampd
) n
[2].f
);
2592 case OPCODE_DISABLE
:
2593 gl_Disable( ctx
, n
[1].e
);
2595 case OPCODE_DRAW_BUFFER
:
2596 gl_DrawBuffer( ctx
, n
[1].e
);
2598 case OPCODE_DRAW_PIXELS
:
2599 gl_DrawPixels( ctx
, (struct gl_image
*) n
[1].data
);
2602 gl_Enable( ctx
, n
[1].e
);
2604 case OPCODE_EVALMESH1
:
2605 gl_EvalMesh1( ctx
, n
[1].e
, n
[2].i
, n
[3].i
);
2607 case OPCODE_EVALMESH2
:
2608 gl_EvalMesh2( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
);
2617 gl_Fogfv( ctx
, n
[1].e
, p
);
2620 case OPCODE_FRONT_FACE
:
2621 gl_FrontFace( ctx
, n
[1].e
);
2623 case OPCODE_FRUSTUM
:
2624 gl_Frustum( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2627 gl_Hint( ctx
, n
[1].e
, n
[2].e
);
2629 case OPCODE_INDEX_MASK
:
2630 gl_IndexMask( ctx
, n
[1].ui
);
2632 case OPCODE_INIT_NAMES
:
2633 gl_InitNames( ctx
);
2642 gl_Lightfv( ctx
, n
[1].e
, n
[2].e
, p
, 4 );
2645 case OPCODE_LIGHT_MODEL
:
2652 gl_LightModelfv( ctx
, n
[1].e
, p
);
2655 case OPCODE_LINE_STIPPLE
:
2656 gl_LineStipple( ctx
, n
[1].i
, n
[2].us
);
2658 case OPCODE_LINE_WIDTH
:
2659 gl_LineWidth( ctx
, n
[1].f
);
2661 case OPCODE_LIST_BASE
:
2662 gl_ListBase( ctx
, n
[1].ui
);
2664 case OPCODE_LOAD_IDENTITY
:
2665 gl_LoadIdentity( ctx
);
2667 case OPCODE_LOAD_MATRIX
:
2668 if (sizeof(Node
)==sizeof(GLfloat
)) {
2669 gl_LoadMatrixf( ctx
, &n
[1].f
);
2674 for (i
=0;i
<16;i
++) {
2677 gl_LoadMatrixf( ctx
, m
);
2680 case OPCODE_LOAD_NAME
:
2681 gl_LoadName( ctx
, n
[1].ui
);
2683 case OPCODE_LOGIC_OP
:
2684 gl_LogicOp( ctx
, n
[1].e
);
2687 gl_Map1f( ctx
, n
[1].e
, n
[2].f
, n
[3].f
,
2688 n
[4].i
, n
[5].i
, (GLfloat
*) n
[6].data
, GL_TRUE
);
2691 gl_Map2f( ctx
, n
[1].e
,
2692 n
[2].f
, n
[3].f
, /* u1, u2 */
2693 n
[6].i
, n
[8].i
, /* ustride, uorder */
2694 n
[4].f
, n
[5].f
, /* v1, v2 */
2695 n
[7].i
, n
[9].i
, /* vstride, vorder */
2696 (GLfloat
*) n
[10].data
,
2699 case OPCODE_MAPGRID1
:
2700 gl_MapGrid1f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
);
2702 case OPCODE_MAPGRID2
:
2703 gl_MapGrid2f( ctx
, n
[1].i
, n
[2].f
, n
[3].f
, n
[4].i
, n
[5].f
, n
[6].f
);
2705 case OPCODE_MATRIX_MODE
:
2706 gl_MatrixMode( ctx
, n
[1].e
);
2708 case OPCODE_MULT_MATRIX
:
2709 if (sizeof(Node
)==sizeof(GLfloat
)) {
2710 gl_MultMatrixf( ctx
, &n
[1].f
);
2715 for (i
=0;i
<16;i
++) {
2718 gl_MultMatrixf( ctx
, m
);
2722 gl_Ortho( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
2724 case OPCODE_PASSTHROUGH
:
2725 gl_PassThrough( ctx
, n
[1].f
);
2727 case OPCODE_PIXEL_MAP
:
2728 gl_PixelMapfv( ctx
, n
[1].e
, n
[2].i
, (GLfloat
*) n
[3].data
);
2730 case OPCODE_PIXEL_TRANSFER
:
2731 gl_PixelTransferf( ctx
, n
[1].e
, n
[2].f
);
2733 case OPCODE_PIXEL_ZOOM
:
2734 gl_PixelZoom( ctx
, n
[1].f
, n
[2].f
);
2736 case OPCODE_POINT_SIZE
:
2737 gl_PointSize( ctx
, n
[1].f
);
2739 case OPCODE_POINT_PARAMETERS
:
2745 gl_PointParameterfvEXT( ctx
, n
[1].e
, params
);
2748 case OPCODE_POLYGON_MODE
:
2749 gl_PolygonMode( ctx
, n
[1].e
, n
[2].e
);
2751 case OPCODE_POLYGON_STIPPLE
:
2752 gl_PolygonStipple( ctx
, (GLuint
*) n
[1].data
);
2754 case OPCODE_POLYGON_OFFSET
:
2755 gl_PolygonOffset( ctx
, n
[1].f
, n
[2].f
);
2757 case OPCODE_POP_ATTRIB
:
2758 gl_PopAttrib( ctx
);
2760 case OPCODE_POP_MATRIX
:
2761 gl_PopMatrix( ctx
);
2763 case OPCODE_POP_NAME
:
2766 case OPCODE_PRIORITIZE_TEXTURE
:
2767 gl_PrioritizeTextures( ctx
, 1, &n
[1].ui
, &n
[2].f
);
2769 case OPCODE_PUSH_ATTRIB
:
2770 gl_PushAttrib( ctx
, n
[1].bf
);
2772 case OPCODE_PUSH_MATRIX
:
2773 gl_PushMatrix( ctx
);
2775 case OPCODE_PUSH_NAME
:
2776 gl_PushName( ctx
, n
[1].ui
);
2778 case OPCODE_RASTER_POS
:
2779 gl_RasterPos4f( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2781 case OPCODE_READ_BUFFER
:
2782 gl_ReadBuffer( ctx
, n
[1].e
);
2785 gl_Rectf( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2788 gl_Scalef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
2790 case OPCODE_SCISSOR
:
2791 gl_Scissor( ctx
, n
[1].i
, n
[2].i
, n
[3].i
, n
[4].i
);
2793 case OPCODE_SHADE_MODEL
:
2794 gl_ShadeModel( ctx
, n
[1].e
);
2796 case OPCODE_STENCIL_FUNC
:
2797 gl_StencilFunc( ctx
, n
[1].e
, n
[2].i
, n
[3].ui
);
2799 case OPCODE_STENCIL_MASK
:
2800 gl_StencilMask( ctx
, n
[1].ui
);
2802 case OPCODE_STENCIL_OP
:
2803 gl_StencilOp( ctx
, n
[1].e
, n
[2].e
, n
[3].e
);
2812 gl_TexEnvfv( ctx
, n
[1].e
, n
[2].e
, params
);
2822 gl_TexGenfv( ctx
, n
[1].e
, n
[2].e
, params
);
2825 case OPCODE_TEXPARAMETER
:
2832 gl_TexParameterfv( ctx
, n
[1].e
, n
[2].e
, params
);
2835 case OPCODE_TEX_IMAGE1D
:
2837 n
[1].e
, /* target */
2839 n
[3].i
, /* components */
2841 n
[5].e
, /* border */
2842 n
[6].e
, /* format */
2844 (struct gl_image
*) n
[8].data
);
2846 case OPCODE_TEX_IMAGE2D
:
2848 n
[1].e
, /* target */
2850 n
[3].i
, /* components */
2852 n
[5].i
, /* height */
2853 n
[6].e
, /* border */
2854 n
[7].e
, /* format */
2856 (struct gl_image
*) n
[9].data
);
2858 case OPCODE_TEX_IMAGE3D
:
2859 gl_TexImage3DEXT( ctx
,
2860 n
[1].e
, /* target */
2862 n
[3].i
, /* components */
2864 n
[5].i
, /* height */
2866 n
[7].e
, /* border */
2867 n
[8].e
, /* format */
2869 (struct gl_image
*) n
[10].data
);
2871 case OPCODE_TEX_SUB_IMAGE1D
:
2872 gl_TexSubImage1D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].e
,
2873 n
[6].e
, (struct gl_image
*) n
[7].data
);
2875 case OPCODE_TEX_SUB_IMAGE2D
:
2876 gl_TexSubImage2D( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].e
,
2877 n
[6].i
, n
[7].e
, n
[8].e
,
2878 (struct gl_image
*) n
[9].data
);
2880 case OPCODE_TEX_SUB_IMAGE3D
:
2881 gl_TexSubImage3DEXT( ctx
, n
[1].e
, n
[2].i
, n
[3].i
, n
[4].i
, n
[5].i
,
2882 n
[6].i
, n
[7].i
, n
[8].i
, n
[9].e
, n
[10].e
,
2883 (struct gl_image
*) n
[11].data
);
2885 case OPCODE_TRANSLATE
:
2886 gl_Translatef( ctx
, n
[1].f
, n
[2].f
, n
[3].f
);
2888 case OPCODE_VIEWPORT
:
2890 n
[1].i
, n
[2].i
, (GLsizei
) n
[3].i
, (GLsizei
) n
[4].i
);
2892 case OPCODE_WINDOW_POS
:
2893 gl_WindowPos4fMESA( ctx
, n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
2895 case OPCODE_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
2896 gl_ActiveTexture( ctx
, n
[1].e
);
2898 case OPCODE_CLIENT_ACTIVE_TEXTURE
: /* GL_ARB_multitexture */
2899 gl_ClientActiveTexture( ctx
, n
[1].e
);
2901 case OPCODE_CONTINUE
:
2902 n
= (Node
*) n
[1].next
;
2904 case OPCODE_END_OF_LIST
:
2910 sprintf(msg
, "Error in execute_list: opcode=%d", (int) opcode
);
2911 gl_problem( ctx
, msg
);
2916 /* increment n to point to next compiled command */
2917 if (opcode
!=OPCODE_CONTINUE
) {
2918 n
+= InstSize
[opcode
];
2929 /**********************************************************************/
2931 /**********************************************************************/
2937 * Test if a display list number is valid.
2939 GLboolean
gl_IsList( GLcontext
*ctx
, GLuint list
)
2941 if (list
> 0 && HashLookup(ctx
->Shared
->DisplayList
, list
)) {
2952 * Delete a sequence of consecutive display lists.
2954 void gl_DeleteLists( GLcontext
*ctx
, GLuint list
, GLsizei range
)
2958 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glDeleteLists");
2960 gl_error( ctx
, GL_INVALID_VALUE
, "glDeleteLists" );
2963 for (i
=list
;i
<list
+range
;i
++) {
2964 gl_destroy_list( ctx
, i
);
2971 * Return a display list number, n, such that lists n through n+range-1
2974 GLuint
gl_GenLists( GLcontext
*ctx
, GLsizei range
)
2978 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx
, "glGenLists", 0);
2980 gl_error( ctx
, GL_INVALID_VALUE
, "glGenLists" );
2987 base
= HashFindFreeKeyBlock(ctx
->Shared
->DisplayList
, range
);
2989 /* reserve the list IDs by with empty/dummy lists */
2991 for (i
=0; i
<range
; i
++) {
2992 HashInsert(ctx
->Shared
->DisplayList
, base
+i
, make_empty_list());
3001 * Begin a new display list.
3003 void gl_NewList( GLcontext
*ctx
, GLuint list
, GLenum mode
)
3005 struct immediate
*IM
;
3006 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glNewList");
3008 if (MESA_VERBOSE
&VERBOSE_API
)
3009 fprintf(stderr
, "glNewList %u %s\n", list
, gl_lookup_enum_by_nr(mode
));
3012 gl_error( ctx
, GL_INVALID_VALUE
, "glNewList" );
3016 if (mode
!=GL_COMPILE
&& mode
!=GL_COMPILE_AND_EXECUTE
) {
3017 gl_error( ctx
, GL_INVALID_ENUM
, "glNewList" );
3021 if (ctx
->CurrentListPtr
) {
3022 /* already compiling a display list */
3023 gl_error( ctx
, GL_INVALID_OPERATION
, "glNewList" );
3027 /* Allocate new display list */
3028 ctx
->CurrentListNum
= list
;
3029 ctx
->CurrentBlock
= (Node
*) malloc( sizeof(Node
) * BLOCK_SIZE
);
3030 ctx
->CurrentListPtr
= ctx
->CurrentBlock
;
3031 ctx
->CurrentPos
= 0;
3033 IM
= gl_immediate_alloc( ctx
);
3034 SET_IMMEDIATE( ctx
, IM
);
3035 gl_reset_input( ctx
);
3037 ctx
->CompileFlag
= GL_TRUE
;
3038 ctx
->CompileCVAFlag
= GL_FALSE
;
3039 ctx
->ExecuteFlag
= (mode
== GL_COMPILE_AND_EXECUTE
);
3040 ctx
->API
= ctx
->Save
; /* Switch the API function pointers */
3046 * End definition of current display list.
3048 void gl_EndList( GLcontext
*ctx
)
3050 if (MESA_VERBOSE
&VERBOSE_API
)
3051 fprintf(stderr
, "glEndList\n");
3053 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
, "glEndList" );
3055 /* Check that a list is under construction */
3056 if (!ctx
->CurrentListPtr
) {
3057 gl_error( ctx
, GL_INVALID_OPERATION
, "glEndList" );
3061 (void) alloc_instruction( ctx
, OPCODE_END_OF_LIST
, 0 );
3063 /* Destroy old list, if any */
3064 gl_destroy_list(ctx
, ctx
->CurrentListNum
);
3065 /* Install the list */
3066 HashInsert(ctx
->Shared
->DisplayList
, ctx
->CurrentListNum
, ctx
->CurrentListPtr
);
3069 if (MESA_VERBOSE
& VERBOSE_DISPLAY_LIST
)
3070 mesa_print_display_list(ctx
->CurrentListNum
);
3072 ctx
->CurrentListNum
= 0;
3073 ctx
->CurrentListPtr
= NULL
;
3074 ctx
->ExecuteFlag
= GL_TRUE
;
3075 ctx
->CompileFlag
= GL_FALSE
;
3076 /* ctx->CompileCVAFlag = ...; */
3078 /* KW: Put back the old input pointer.
3081 SET_IMMEDIATE( ctx
, ctx
->VB
->IM
);
3082 gl_reset_input( ctx
);
3084 /* Haven't tracked down why this is needed.
3088 ctx
->API
= ctx
->Exec
; /* Switch the API function pointers */
3093 void gl_CallList( GLcontext
*ctx
, GLuint list
)
3095 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
3096 /* execute the display list, and restore the CompileFlag. */
3097 GLboolean save_compile_flag
;
3099 if (MESA_VERBOSE
&VERBOSE_API
)
3100 fprintf(stderr
, "glCallList %u\n", list
);
3103 save_compile_flag
= ctx
->CompileFlag
;
3104 ctx
->CompileFlag
= GL_FALSE
;
3106 FLUSH_VB( ctx
, "call list" );
3108 /* mesa_print_display_list( list ); */
3110 execute_list( ctx
, list
);
3111 ctx
->CompileFlag
= save_compile_flag
;
3113 /* also restore API function pointers to point to "save" versions */
3114 if (save_compile_flag
)
3115 ctx
->API
= ctx
->Save
;
3118 /* RESET_IMMEDIATE( ctx ); */
3124 * Execute glCallLists: call multiple display lists.
3126 void gl_CallLists( GLcontext
*ctx
,
3127 GLsizei n
, GLenum type
, const GLvoid
*lists
)
3131 GLboolean save_compile_flag
;
3133 /* Save the CompileFlag status, turn it off, execute display list,
3134 * and restore the CompileFlag.
3136 save_compile_flag
= ctx
->CompileFlag
;
3137 ctx
->CompileFlag
= GL_FALSE
;
3139 FLUSH_VB( ctx
, "call lists" );
3142 list
= translate_id( i
, type
, lists
);
3143 execute_list( ctx
, ctx
->List
.ListBase
+ list
);
3146 ctx
->CompileFlag
= save_compile_flag
;
3148 /* also restore API function pointers to point to "save" versions */
3149 if (save_compile_flag
)
3150 ctx
->API
= ctx
->Save
;
3153 /* RESET_IMMEDIATE( ctx ); */
3159 * Set the offset added to list numbers in glCallLists.
3161 void gl_ListBase( GLcontext
*ctx
, GLuint base
)
3163 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glListBase");
3164 ctx
->List
.ListBase
= base
;
3173 * Assign all the pointers in 'table' to point to Mesa's display list
3174 * building functions.
3176 void gl_init_dlist_pointers( struct gl_api_table
*table
)
3178 table
->Accum
= save_Accum
;
3179 table
->AlphaFunc
= save_AlphaFunc
;
3180 table
->AreTexturesResident
= gl_AreTexturesResident
;
3181 table
->BindTexture
= save_BindTexture
;
3182 table
->Bitmap
= save_Bitmap
;
3183 table
->BlendColor
= save_BlendColor
;
3184 table
->BlendEquation
= save_BlendEquation
;
3185 table
->BlendFunc
= save_BlendFunc
;
3186 table
->BlendFuncSeparate
= save_BlendFuncSeparate
;
3187 table
->CallList
= save_CallList
;
3188 table
->CallLists
= save_CallLists
;
3189 table
->Clear
= save_Clear
;
3190 table
->ClearAccum
= save_ClearAccum
;
3191 table
->ClearColor
= save_ClearColor
;
3192 table
->ClearDepth
= save_ClearDepth
;
3193 table
->ClearIndex
= save_ClearIndex
;
3194 table
->ClearStencil
= save_ClearStencil
;
3195 table
->ClipPlane
= save_ClipPlane
;
3196 table
->ColorMask
= save_ColorMask
;
3197 table
->ColorMaterial
= save_ColorMaterial
;
3198 table
->ColorTable
= save_ColorTable
;
3199 table
->ColorSubTable
= save_ColorSubTable
;
3200 table
->CopyPixels
= save_CopyPixels
;
3201 table
->CopyTexImage1D
= save_CopyTexImage1D
;
3202 table
->CopyTexImage2D
= save_CopyTexImage2D
;
3203 table
->CopyTexSubImage1D
= save_CopyTexSubImage1D
;
3204 table
->CopyTexSubImage2D
= save_CopyTexSubImage2D
;
3205 table
->CopyTexSubImage3DEXT
= save_CopyTexSubImage3DEXT
;
3206 table
->CullFace
= save_CullFace
;
3207 table
->DeleteLists
= gl_DeleteLists
; /* NOT SAVED */
3208 table
->DeleteTextures
= gl_DeleteTextures
; /* NOT SAVED */
3209 table
->DepthFunc
= save_DepthFunc
;
3210 table
->DepthMask
= save_DepthMask
;
3211 table
->DepthRange
= save_DepthRange
;
3212 table
->Disable
= save_Disable
;
3213 table
->DisableClientState
= gl_DisableClientState
; /* NOT SAVED */
3214 table
->DrawBuffer
= save_DrawBuffer
;
3215 table
->DrawPixels
= save_DrawPixels
;
3216 table
->Enable
= save_Enable
;
3217 table
->Error
= gl_save_error
;
3218 table
->EnableClientState
= gl_EnableClientState
; /* NOT SAVED */
3219 table
->EndList
= gl_EndList
; /* NOT SAVED */
3220 table
->EvalMesh1
= save_EvalMesh1
;
3221 table
->EvalMesh2
= save_EvalMesh2
;
3222 table
->FeedbackBuffer
= gl_FeedbackBuffer
; /* NOT SAVED */
3223 table
->Finish
= gl_Finish
; /* NOT SAVED */
3224 table
->Flush
= gl_Flush
; /* NOT SAVED */
3225 table
->Fogfv
= save_Fogfv
;
3226 table
->FrontFace
= save_FrontFace
;
3227 table
->Frustum
= save_Frustum
;
3228 table
->GenLists
= gl_GenLists
; /* NOT SAVED */
3229 table
->GenTextures
= gl_GenTextures
; /* NOT SAVED */
3231 /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
3232 table
->GetBooleanv
= gl_GetBooleanv
;
3233 table
->GetClipPlane
= gl_GetClipPlane
;
3234 table
->GetColorTable
= gl_GetColorTable
;
3235 table
->GetColorTableParameteriv
= gl_GetColorTableParameteriv
;
3236 table
->GetDoublev
= gl_GetDoublev
;
3237 table
->GetError
= gl_GetError
;
3238 table
->GetFloatv
= gl_GetFloatv
;
3239 table
->GetIntegerv
= gl_GetIntegerv
;
3240 table
->GetString
= gl_GetString
;
3241 table
->GetLightfv
= gl_GetLightfv
;
3242 table
->GetLightiv
= gl_GetLightiv
;
3243 table
->GetMapdv
= gl_GetMapdv
;
3244 table
->GetMapfv
= gl_GetMapfv
;
3245 table
->GetMapiv
= gl_GetMapiv
;
3246 table
->GetMaterialfv
= gl_GetMaterialfv
;
3247 table
->GetMaterialiv
= gl_GetMaterialiv
;
3248 table
->GetPixelMapfv
= gl_GetPixelMapfv
;
3249 table
->GetPixelMapuiv
= gl_GetPixelMapuiv
;
3250 table
->GetPixelMapusv
= gl_GetPixelMapusv
;
3251 table
->GetPointerv
= gl_GetPointerv
;
3252 table
->GetPolygonStipple
= gl_GetPolygonStipple
;
3253 table
->GetTexEnvfv
= gl_GetTexEnvfv
;
3254 table
->GetTexEnviv
= gl_GetTexEnviv
;
3255 table
->GetTexGendv
= gl_GetTexGendv
;
3256 table
->GetTexGenfv
= gl_GetTexGenfv
;
3257 table
->GetTexGeniv
= gl_GetTexGeniv
;
3258 table
->GetTexImage
= gl_GetTexImage
;
3259 table
->GetTexLevelParameterfv
= gl_GetTexLevelParameterfv
;
3260 table
->GetTexLevelParameteriv
= gl_GetTexLevelParameteriv
;
3261 table
->GetTexParameterfv
= gl_GetTexParameterfv
;
3262 table
->GetTexParameteriv
= gl_GetTexParameteriv
;
3264 table
->Hint
= save_Hint
;
3265 table
->IndexMask
= save_IndexMask
;
3266 table
->InitNames
= save_InitNames
;
3267 table
->IsEnabled
= gl_IsEnabled
; /* NOT SAVED */
3268 table
->IsTexture
= gl_IsTexture
; /* NOT SAVED */
3269 table
->IsList
= gl_IsList
; /* NOT SAVED */
3270 table
->LightModelfv
= save_LightModelfv
;
3271 table
->Lightfv
= save_Lightfv
;
3272 table
->LineStipple
= save_LineStipple
;
3273 table
->LineWidth
= save_LineWidth
;
3274 table
->ListBase
= save_ListBase
;
3275 table
->LoadIdentity
= save_LoadIdentity
;
3276 table
->LoadMatrixf
= save_LoadMatrixf
;
3277 table
->LoadName
= save_LoadName
;
3278 table
->LogicOp
= save_LogicOp
;
3279 table
->Map1f
= save_Map1f
;
3280 table
->Map2f
= save_Map2f
;
3281 table
->MapGrid1f
= save_MapGrid1f
;
3282 table
->MapGrid2f
= save_MapGrid2f
;
3283 table
->MatrixMode
= save_MatrixMode
;
3284 table
->MultMatrixf
= save_MultMatrixf
;
3285 table
->NewList
= save_NewList
;
3286 table
->Ortho
= save_Ortho
;
3287 table
->PointParameterfvEXT
= save_PointParameterfvEXT
;
3288 table
->PassThrough
= save_PassThrough
;
3289 table
->PixelMapfv
= save_PixelMapfv
;
3290 table
->PixelStorei
= gl_PixelStorei
; /* NOT SAVED */
3291 table
->PixelTransferf
= save_PixelTransferf
;
3292 table
->PixelZoom
= save_PixelZoom
;
3293 table
->PointSize
= save_PointSize
;
3294 table
->PolygonMode
= save_PolygonMode
;
3295 table
->PolygonOffset
= save_PolygonOffset
;
3296 table
->PolygonStipple
= save_PolygonStipple
;
3297 table
->PopAttrib
= save_PopAttrib
;
3298 table
->PopClientAttrib
= gl_PopClientAttrib
; /* NOT SAVED */
3299 table
->PopMatrix
= save_PopMatrix
;
3300 table
->PopName
= save_PopName
;
3301 table
->PrioritizeTextures
= save_PrioritizeTextures
;
3302 table
->PushAttrib
= save_PushAttrib
;
3303 table
->PushClientAttrib
= gl_PushClientAttrib
; /* NOT SAVED */
3304 table
->PushMatrix
= save_PushMatrix
;
3305 table
->PushName
= save_PushName
;
3306 table
->RasterPos4f
= save_RasterPos4f
;
3307 table
->ReadBuffer
= save_ReadBuffer
;
3308 table
->ReadPixels
= gl_ReadPixels
; /* NOT SAVED */
3309 table
->Rectf
= save_Rectf
;
3310 table
->RenderMode
= gl_RenderMode
; /* NOT SAVED */
3311 table
->Rotatef
= save_Rotatef
;
3312 table
->Scalef
= save_Scalef
;
3313 table
->Scissor
= save_Scissor
;
3314 table
->SelectBuffer
= gl_SelectBuffer
; /* NOT SAVED */
3315 table
->ShadeModel
= save_ShadeModel
;
3316 table
->StencilFunc
= save_StencilFunc
;
3317 table
->StencilMask
= save_StencilMask
;
3318 table
->StencilOp
= save_StencilOp
;
3319 table
->TexEnvfv
= save_TexEnvfv
;
3320 table
->TexGenfv
= save_TexGenfv
;
3321 table
->TexImage1D
= save_TexImage1D
;
3322 table
->TexImage2D
= save_TexImage2D
;
3323 table
->TexImage3DEXT
= save_TexImage3DEXT
;
3324 table
->TexSubImage1D
= save_TexSubImage1D
;
3325 table
->TexSubImage2D
= save_TexSubImage2D
;
3326 table
->TexSubImage3DEXT
= save_TexSubImage3DEXT
;
3327 table
->TexParameterfv
= save_TexParameterfv
;
3328 table
->Translatef
= save_Translatef
;
3329 table
->Viewport
= save_Viewport
;
3331 /* GL_MESA_window_pos extension */
3332 table
->WindowPos4fMESA
= save_WindowPos4fMESA
;
3334 /* GL_MESA_resize_buffers extension */
3335 table
->ResizeBuffersMESA
= gl_ResizeBuffersMESA
;
3337 /* GL_ARB_multitexture */
3338 table
->ActiveTexture
= save_ActiveTexture
;
3339 table
->ClientActiveTexture
= save_ClientActiveTexture
;
3341 /* GL_EXT_get_proc_address */
3342 table
->GetProcAddress
= gl_GetProcAddress
; /* NOT SAVED */
3350 static const char *enum_string( GLenum k
)
3352 return gl_lookup_enum_by_nr( k
);
3357 * Print the commands in a display list. For debugging only.
3358 * TODO: many commands aren't handled yet.
3360 static void print_list( GLcontext
*ctx
, FILE *f
, GLuint list
)
3366 if (!glIsList(list
)) {
3367 fprintf(f
,"%u is not a display list ID\n",list
);
3371 n
= (Node
*) HashLookup(ctx
->Shared
->DisplayList
, list
);
3373 fprintf( f
, "START-LIST %u, address %p\n", list
, (void*)n
);
3375 done
= n
? GL_FALSE
: GL_TRUE
;
3377 opcode
= n
[0].opcode
;
3381 fprintf(f
,"accum %s %g\n", enum_string(n
[1].e
), n
[2].f
);
3384 fprintf(f
,"Bitmap %d %d %g %g %g %g %p\n", n
[1].i
, n
[2].i
,
3385 n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
, (void *) n
[7].data
);
3387 case OPCODE_CALL_LIST
:
3388 fprintf(f
,"CallList %d\n", (int) n
[1].ui
);
3390 case OPCODE_CALL_LIST_OFFSET
:
3391 fprintf(f
,"CallList %d + offset %u = %u\n", (int) n
[1].ui
,
3392 ctx
->List
.ListBase
, ctx
->List
.ListBase
+ n
[1].ui
);
3394 case OPCODE_DISABLE
:
3395 fprintf(f
,"Disable %s\n", enum_string(n
[1].e
));
3398 fprintf(f
,"Enable %s\n", enum_string(n
[1].e
));
3400 case OPCODE_FRUSTUM
:
3401 fprintf(f
,"Frustum %g %g %g %g %g %g\n",
3402 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3404 case OPCODE_LINE_STIPPLE
:
3405 fprintf(f
,"LineStipple %d %x\n", n
[1].i
, (int) n
[2].us
);
3407 case OPCODE_LOAD_IDENTITY
:
3408 fprintf(f
,"LoadIdentity\n");
3410 case OPCODE_LOAD_MATRIX
:
3411 fprintf(f
,"LoadMatrix\n");
3412 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3413 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3414 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3415 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3417 case OPCODE_MULT_MATRIX
:
3418 fprintf(f
,"MultMatrix (or Rotate)\n");
3419 fprintf(f
," %8f %8f %8f %8f\n", n
[1].f
, n
[5].f
, n
[9].f
, n
[13].f
);
3420 fprintf(f
," %8f %8f %8f %8f\n", n
[2].f
, n
[6].f
, n
[10].f
, n
[14].f
);
3421 fprintf(f
," %8f %8f %8f %8f\n", n
[3].f
, n
[7].f
, n
[11].f
, n
[15].f
);
3422 fprintf(f
," %8f %8f %8f %8f\n", n
[4].f
, n
[8].f
, n
[12].f
, n
[16].f
);
3425 fprintf(f
,"Ortho %g %g %g %g %g %g\n",
3426 n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
, n
[5].f
, n
[6].f
);
3428 case OPCODE_POP_ATTRIB
:
3429 fprintf(f
,"PopAttrib\n");
3431 case OPCODE_POP_MATRIX
:
3432 fprintf(f
,"PopMatrix\n");
3434 case OPCODE_POP_NAME
:
3435 fprintf(f
,"PopName\n");
3437 case OPCODE_PUSH_ATTRIB
:
3438 fprintf(f
,"PushAttrib %x\n", n
[1].bf
);
3440 case OPCODE_PUSH_MATRIX
:
3441 fprintf(f
,"PushMatrix\n");
3443 case OPCODE_PUSH_NAME
:
3444 fprintf(f
,"PushName %d\n", (int) n
[1].ui
);
3446 case OPCODE_RASTER_POS
:
3447 fprintf(f
,"RasterPos %g %g %g %g\n", n
[1].f
, n
[2].f
,n
[3].f
,n
[4].f
);
3450 fprintf( f
, "Rectf %g %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
, n
[4].f
);
3453 fprintf(f
,"Scale %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3455 case OPCODE_TRANSLATE
:
3456 fprintf(f
,"Translate %g %g %g\n", n
[1].f
, n
[2].f
, n
[3].f
);
3460 * meta opcodes/commands
3463 fprintf(f
,"Error: %s %s\n", enum_string(n
[1].e
), (const char *)n
[2].data
);
3465 case OPCODE_VERTEX_CASSETTE
:
3466 fprintf(f
,"VERTEX-CASSETTE, id %u, %u elements\n",
3467 ((struct immediate
*) n
[1].data
)->id
,
3468 ((struct immediate
*) n
[1].data
)->Count
- VB_START
);
3470 case OPCODE_CONTINUE
:
3471 fprintf(f
,"DISPLAY-LIST-CONTINUE\n");
3472 n
= (Node
*) n
[1].next
;
3474 case OPCODE_END_OF_LIST
:
3475 fprintf(f
,"END-LIST %u\n", list
);
3479 if (opcode
< 0 || opcode
> OPCODE_END_OF_LIST
) {
3480 fprintf(f
,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
3485 fprintf(f
,"command %d, %u operands\n",opcode
,InstSize
[opcode
]);
3489 /* increment n to point to next compiled command */
3490 if (opcode
!=OPCODE_CONTINUE
) {
3491 n
+= InstSize
[opcode
];
3504 * Clients may call this function to help debug display list problems.
3505 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
3506 * changed, or break in the future without notice.
3508 void mesa_print_display_list( GLuint list
)
3511 print_list( CC
, stdout
, list
);