dlist.c revision 8df3d8ae6c48cbbe649e8cfeebd8a99f983784f7
1/* $Id: dlist.c,v 1.33 2000/03/03 17:45:21 brianp Exp $ */ 2 3/* 4 * Mesa 3-D graphics library 5 * Version: 3.3 6 * 7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. 8 * 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: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 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. 25 */ 26 27 28#ifdef PC_HEADER 29#include "all.h" 30#else 31#include "glheader.h" 32#include "accum.h" 33#include "attrib.h" 34#include "bitmap.h" 35#include "bbox.h" 36#include "blend.h" 37#include "buffers.h" 38#include "clip.h" 39#include "colortab.h" 40#include "context.h" 41#include "copypix.h" 42#include "cva.h" 43#include "depth.h" 44#include "enable.h" 45#include "enums.h" 46#include "eval.h" 47#include "extensions.h" 48#include "feedback.h" 49#include "get.h" 50#include "glapi.h" 51#include "hash.h" 52#include "image.h" 53#include "imaging.h" 54#include "light.h" 55#include "lines.h" 56#include "dlist.h" 57#include "macros.h" 58#include "matrix.h" 59#include "mem.h" 60#include "pipeline.h" 61#include "pixel.h" 62#include "points.h" 63#include "polygon.h" 64#include "readpix.h" 65#include "rect.h" 66#include "state.h" 67#include "texobj.h" 68#include "teximage.h" 69#include "texstate.h" 70#include "types.h" 71#include "varray.h" 72#include "vb.h" 73#include "vbfill.h" 74#include "vbxform.h" 75#include "xform.h" 76#endif 77 78 79 80/* 81Functions which aren't compiled but executed immediately: 82 glIsList 83 glGenLists 84 glDeleteLists 85 glEndList 86 glFeedbackBuffer 87 glSelectBuffer 88 glRenderMode 89 glReadPixels 90 glPixelStore 91 glFlush 92 glFinish 93 glIsEnabled 94 glGet* 95 96Functions which cause errors if called while compiling a display list: 97 glNewList 98*/ 99 100 101 102/* 103 * Display list instructions are stored as sequences of "nodes". Nodes 104 * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks 105 * are linked together with a pointer. 106 */ 107 108 109/* How many nodes to allocate at a time: 110 * - reduced now that we hold vertices etc. elsewhere. 111 */ 112#define BLOCK_SIZE 64 113 114 115/* 116 * Display list opcodes. 117 * 118 * The fact that these identifiers are assigned consecutive 119 * integer values starting at 0 is very important, see InstSize array usage) 120 * 121 * KW: Commented out opcodes now handled by vertex-cassettes. 122 */ 123typedef enum { 124 OPCODE_ACCUM, 125 OPCODE_ALPHA_FUNC, 126 OPCODE_BIND_TEXTURE, 127 OPCODE_BITMAP, 128 OPCODE_BLEND_COLOR, 129 OPCODE_BLEND_EQUATION, 130 OPCODE_BLEND_FUNC, 131 OPCODE_BLEND_FUNC_SEPARATE, 132 OPCODE_CALL_LIST, 133 OPCODE_CALL_LIST_OFFSET, 134 OPCODE_CLEAR, 135 OPCODE_CLEAR_ACCUM, 136 OPCODE_CLEAR_COLOR, 137 OPCODE_CLEAR_DEPTH, 138 OPCODE_CLEAR_INDEX, 139 OPCODE_CLEAR_STENCIL, 140 OPCODE_CLIP_PLANE, 141 OPCODE_COLOR_MASK, 142 OPCODE_COLOR_MATERIAL, 143 OPCODE_COLOR_TABLE, 144 OPCODE_COLOR_SUB_TABLE, 145 OPCODE_COPY_PIXELS, 146 OPCODE_COPY_TEX_IMAGE1D, 147 OPCODE_COPY_TEX_IMAGE2D, 148 OPCODE_COPY_TEX_SUB_IMAGE1D, 149 OPCODE_COPY_TEX_SUB_IMAGE2D, 150 OPCODE_COPY_TEX_SUB_IMAGE3D, 151 OPCODE_CULL_FACE, 152 OPCODE_DEPTH_FUNC, 153 OPCODE_DEPTH_MASK, 154 OPCODE_DEPTH_RANGE, 155 OPCODE_DISABLE, 156 OPCODE_DRAW_BUFFER, 157 OPCODE_DRAW_PIXELS, 158 OPCODE_ENABLE, 159 OPCODE_EVALCOORD1, 160 OPCODE_EVALCOORD2, 161 OPCODE_EVALMESH1, 162 OPCODE_EVALMESH2, 163 OPCODE_EVALPOINT1, 164 OPCODE_EVALPOINT2, 165 OPCODE_FOG, 166 OPCODE_FRONT_FACE, 167 OPCODE_FRUSTUM, 168 OPCODE_HINT, 169 OPCODE_HINT_PGI, 170 OPCODE_INDEX_MASK, 171 OPCODE_INIT_NAMES, 172 OPCODE_LIGHT, 173 OPCODE_LIGHT_MODEL, 174 OPCODE_LINE_STIPPLE, 175 OPCODE_LINE_WIDTH, 176 OPCODE_LIST_BASE, 177 OPCODE_LOAD_IDENTITY, 178 OPCODE_LOAD_MATRIX, 179 OPCODE_LOAD_NAME, 180 OPCODE_LOGIC_OP, 181 OPCODE_MAP1, 182 OPCODE_MAP2, 183 OPCODE_MAPGRID1, 184 OPCODE_MAPGRID2, 185 OPCODE_MATRIX_MODE, 186 OPCODE_MULT_MATRIX, 187 OPCODE_ORTHO, 188 OPCODE_PASSTHROUGH, 189 OPCODE_PIXEL_MAP, 190 OPCODE_PIXEL_TRANSFER, 191 OPCODE_PIXEL_ZOOM, 192 OPCODE_POINT_SIZE, 193 OPCODE_POINT_PARAMETERS, 194 OPCODE_POLYGON_MODE, 195 OPCODE_POLYGON_STIPPLE, 196 OPCODE_POLYGON_OFFSET, 197 OPCODE_POP_ATTRIB, 198 OPCODE_POP_MATRIX, 199 OPCODE_POP_NAME, 200 OPCODE_PRIORITIZE_TEXTURE, 201 OPCODE_PUSH_ATTRIB, 202 OPCODE_PUSH_MATRIX, 203 OPCODE_PUSH_NAME, 204 OPCODE_RASTER_POS, 205 OPCODE_RECTF, 206 OPCODE_READ_BUFFER, 207 OPCODE_SCALE, 208 OPCODE_SCISSOR, 209 OPCODE_SELECT_TEXTURE_SGIS, 210 OPCODE_SELECT_TEXTURE_COORD_SET, 211 OPCODE_SHADE_MODEL, 212 OPCODE_STENCIL_FUNC, 213 OPCODE_STENCIL_MASK, 214 OPCODE_STENCIL_OP, 215 OPCODE_TEXENV, 216 OPCODE_TEXGEN, 217 OPCODE_TEXPARAMETER, 218 OPCODE_TEX_IMAGE1D, 219 OPCODE_TEX_IMAGE2D, 220 OPCODE_TEX_IMAGE3D, 221 OPCODE_TEX_SUB_IMAGE1D, 222 OPCODE_TEX_SUB_IMAGE2D, 223 OPCODE_TEX_SUB_IMAGE3D, 224 OPCODE_TRANSLATE, 225 OPCODE_VIEWPORT, 226 OPCODE_WINDOW_POS, 227 /* GL_ARB_multitexture */ 228 OPCODE_ACTIVE_TEXTURE, 229 OPCODE_CLIENT_ACTIVE_TEXTURE, 230 /* The following three are meta instructions */ 231 OPCODE_ERROR, /* raise compiled-in error */ 232 OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */ 233 OPCODE_CONTINUE, 234 OPCODE_END_OF_LIST 235} OpCode; 236 237 238/* 239 * Each instruction in the display list is stored as a sequence of 240 * contiguous nodes in memory. 241 * Each node is the union of a variety of datatypes. 242 */ 243union node { 244 OpCode opcode; 245 GLboolean b; 246 GLbitfield bf; 247 GLubyte ub; 248 GLshort s; 249 GLushort us; 250 GLint i; 251 GLuint ui; 252 GLenum e; 253 GLfloat f; 254 GLvoid *data; 255 void *next; /* If prev node's opcode==OPCODE_CONTINUE */ 256}; 257 258 259 260/* Number of nodes of storage needed for each instruction: */ 261static GLuint InstSize[ OPCODE_END_OF_LIST+1 ]; 262 263void mesa_print_display_list( GLuint list ); 264 265 266/**********************************************************************/ 267/***** Private *****/ 268/**********************************************************************/ 269 270 271/* 272 * Allocate space for a display list instruction. 273 * Input: opcode - type of instruction 274 * argcount - number of arguments following the instruction 275 * Return: pointer to first node in the instruction 276 */ 277static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount ) 278{ 279 Node *n, *newblock; 280 GLuint count = InstSize[opcode]; 281 282 assert( (GLint) count == argcount+1 ); 283 284 if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) { 285 /* This block is full. Allocate a new block and chain to it */ 286 n = ctx->CurrentBlock + ctx->CurrentPos; 287 n[0].opcode = OPCODE_CONTINUE; 288 newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE ); 289 if (!newblock) { 290 gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" ); 291 return NULL; 292 } 293 n[1].next = (Node *) newblock; 294 ctx->CurrentBlock = newblock; 295 ctx->CurrentPos = 0; 296 } 297 298 n = ctx->CurrentBlock + ctx->CurrentPos; 299 ctx->CurrentPos += count; 300 301 n[0].opcode = opcode; 302 303 return n; 304} 305 306 307 308/* 309 * Make an empty display list. This is used by glGenLists() to 310 * reserver display list IDs. 311 */ 312static Node *make_empty_list( void ) 313{ 314 Node *n = (Node *) MALLOC( sizeof(Node) ); 315 n[0].opcode = OPCODE_END_OF_LIST; 316 return n; 317} 318 319 320 321/* 322 * Destroy all nodes in a display list. 323 * Input: list - display list number 324 */ 325void gl_destroy_list( GLcontext *ctx, GLuint list ) 326{ 327 Node *n, *block; 328 GLboolean done; 329 330 if (list==0) 331 return; 332 333 block = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list); 334 n = block; 335 336 done = block ? GL_FALSE : GL_TRUE; 337 while (!done) { 338 switch (n[0].opcode) { 339 /* special cases first */ 340 case OPCODE_VERTEX_CASSETTE: 341 if ( ! -- ((struct immediate *) n[1].data)->ref_count ) 342 gl_immediate_free( (struct immediate *) n[1].data ); 343 n += InstSize[n[0].opcode]; 344 break; 345 case OPCODE_MAP1: 346 FREE(n[6].data); 347 n += InstSize[n[0].opcode]; 348 break; 349 case OPCODE_MAP2: 350 FREE(n[10].data); 351 n += InstSize[n[0].opcode]; 352 break; 353 case OPCODE_DRAW_PIXELS: 354 FREE( n[5].data ); 355 n += InstSize[n[0].opcode]; 356 break; 357 case OPCODE_BITMAP: 358 FREE( n[7].data ); 359 n += InstSize[n[0].opcode]; 360 break; 361 case OPCODE_COLOR_TABLE: 362 FREE( n[6].data ); 363 n += InstSize[n[0].opcode]; 364 break; 365 case OPCODE_COLOR_SUB_TABLE: 366 FREE( n[6].data ); 367 n += InstSize[n[0].opcode]; 368 break; 369 case OPCODE_POLYGON_STIPPLE: 370 FREE( n[1].data ); 371 n += InstSize[n[0].opcode]; 372 break; 373 case OPCODE_TEX_IMAGE1D: 374 FREE(n[8].data); 375 n += InstSize[n[0].opcode]; 376 break; 377 case OPCODE_TEX_IMAGE2D: 378 FREE( n[9]. data ); 379 n += InstSize[n[0].opcode]; 380 break; 381 case OPCODE_TEX_IMAGE3D: 382 FREE( n[10]. data ); 383 n += InstSize[n[0].opcode]; 384 break; 385 case OPCODE_TEX_SUB_IMAGE1D: 386 FREE(n[7].data); 387 n += InstSize[n[0].opcode]; 388 break; 389 case OPCODE_TEX_SUB_IMAGE2D: 390 FREE(n[9].data); 391 n += InstSize[n[0].opcode]; 392 break; 393 case OPCODE_TEX_SUB_IMAGE3D: 394 FREE(n[11].data); 395 n += InstSize[n[0].opcode]; 396 break; 397 case OPCODE_CONTINUE: 398 n = (Node *) n[1].next; 399 FREE( block ); 400 block = n; 401 break; 402 case OPCODE_END_OF_LIST: 403 FREE( block ); 404 done = GL_TRUE; 405 break; 406 default: 407 /* Most frequent case */ 408 n += InstSize[n[0].opcode]; 409 break; 410 } 411 } 412 413 _mesa_HashRemove(ctx->Shared->DisplayList, list); 414} 415 416 417 418/* 419 * Translate the nth element of list from type to GLuint. 420 */ 421static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list ) 422{ 423 GLbyte *bptr; 424 GLubyte *ubptr; 425 GLshort *sptr; 426 GLushort *usptr; 427 GLint *iptr; 428 GLuint *uiptr; 429 GLfloat *fptr; 430 431 switch (type) { 432 case GL_BYTE: 433 bptr = (GLbyte *) list; 434 return (GLuint) *(bptr+n); 435 case GL_UNSIGNED_BYTE: 436 ubptr = (GLubyte *) list; 437 return (GLuint) *(ubptr+n); 438 case GL_SHORT: 439 sptr = (GLshort *) list; 440 return (GLuint) *(sptr+n); 441 case GL_UNSIGNED_SHORT: 442 usptr = (GLushort *) list; 443 return (GLuint) *(usptr+n); 444 case GL_INT: 445 iptr = (GLint *) list; 446 return (GLuint) *(iptr+n); 447 case GL_UNSIGNED_INT: 448 uiptr = (GLuint *) list; 449 return (GLuint) *(uiptr+n); 450 case GL_FLOAT: 451 fptr = (GLfloat *) list; 452 return (GLuint) *(fptr+n); 453 case GL_2_BYTES: 454 ubptr = ((GLubyte *) list) + 2*n; 455 return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1); 456 case GL_3_BYTES: 457 ubptr = ((GLubyte *) list) + 3*n; 458 return (GLuint) *ubptr * 65536 459 + (GLuint) *(ubptr+1) * 256 460 + (GLuint) *(ubptr+2); 461 case GL_4_BYTES: 462 ubptr = ((GLubyte *) list) + 4*n; 463 return (GLuint) *ubptr * 16777216 464 + (GLuint) *(ubptr+1) * 65536 465 + (GLuint) *(ubptr+2) * 256 466 + (GLuint) *(ubptr+3); 467 default: 468 return 0; 469 } 470} 471 472 473 474 475/**********************************************************************/ 476/***** Public *****/ 477/**********************************************************************/ 478 479void gl_init_lists( void ) 480{ 481 static int init_flag = 0; 482 483 if (init_flag==0) { 484 InstSize[OPCODE_ACCUM] = 3; 485 InstSize[OPCODE_ALPHA_FUNC] = 3; 486 InstSize[OPCODE_BIND_TEXTURE] = 3; 487 InstSize[OPCODE_BITMAP] = 8; 488 InstSize[OPCODE_BLEND_COLOR] = 5; 489 InstSize[OPCODE_BLEND_EQUATION] = 2; 490 InstSize[OPCODE_BLEND_FUNC] = 3; 491 InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5; 492 InstSize[OPCODE_CALL_LIST] = 2; 493 InstSize[OPCODE_CALL_LIST_OFFSET] = 2; 494 InstSize[OPCODE_CLEAR] = 2; 495 InstSize[OPCODE_CLEAR_ACCUM] = 5; 496 InstSize[OPCODE_CLEAR_COLOR] = 5; 497 InstSize[OPCODE_CLEAR_DEPTH] = 2; 498 InstSize[OPCODE_CLEAR_INDEX] = 2; 499 InstSize[OPCODE_CLEAR_STENCIL] = 2; 500 InstSize[OPCODE_CLIP_PLANE] = 6; 501 InstSize[OPCODE_COLOR_MASK] = 5; 502 InstSize[OPCODE_COLOR_MATERIAL] = 3; 503 InstSize[OPCODE_COLOR_TABLE] = 7; 504 InstSize[OPCODE_COLOR_SUB_TABLE] = 7; 505 InstSize[OPCODE_COPY_PIXELS] = 6; 506 InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8; 507 InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9; 508 InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7; 509 InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9; 510 InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10; 511 InstSize[OPCODE_CULL_FACE] = 2; 512 InstSize[OPCODE_DEPTH_FUNC] = 2; 513 InstSize[OPCODE_DEPTH_MASK] = 2; 514 InstSize[OPCODE_DEPTH_RANGE] = 3; 515 InstSize[OPCODE_DISABLE] = 2; 516 InstSize[OPCODE_DRAW_BUFFER] = 2; 517 InstSize[OPCODE_DRAW_PIXELS] = 6; 518 InstSize[OPCODE_ENABLE] = 2; 519 InstSize[OPCODE_EVALCOORD1] = 2; 520 InstSize[OPCODE_EVALCOORD2] = 3; 521 InstSize[OPCODE_EVALMESH1] = 4; 522 InstSize[OPCODE_EVALMESH2] = 6; 523 InstSize[OPCODE_EVALPOINT1] = 2; 524 InstSize[OPCODE_EVALPOINT2] = 3; 525 InstSize[OPCODE_FOG] = 6; 526 InstSize[OPCODE_FRONT_FACE] = 2; 527 InstSize[OPCODE_FRUSTUM] = 7; 528 InstSize[OPCODE_HINT] = 3; 529 InstSize[OPCODE_HINT_PGI] = 3; 530 InstSize[OPCODE_INDEX_MASK] = 2; 531 InstSize[OPCODE_INIT_NAMES] = 1; 532 InstSize[OPCODE_LIGHT] = 7; 533 InstSize[OPCODE_LIGHT_MODEL] = 6; 534 InstSize[OPCODE_LINE_STIPPLE] = 3; 535 InstSize[OPCODE_LINE_WIDTH] = 2; 536 InstSize[OPCODE_LIST_BASE] = 2; 537 InstSize[OPCODE_LOAD_IDENTITY] = 1; 538 InstSize[OPCODE_LOAD_MATRIX] = 17; 539 InstSize[OPCODE_LOAD_NAME] = 2; 540 InstSize[OPCODE_LOGIC_OP] = 2; 541 InstSize[OPCODE_MAP1] = 7; 542 InstSize[OPCODE_MAP2] = 11; 543 InstSize[OPCODE_MAPGRID1] = 4; 544 InstSize[OPCODE_MAPGRID2] = 7; 545 InstSize[OPCODE_MATRIX_MODE] = 2; 546 InstSize[OPCODE_MULT_MATRIX] = 17; 547 InstSize[OPCODE_ORTHO] = 7; 548 InstSize[OPCODE_PASSTHROUGH] = 2; 549 InstSize[OPCODE_PIXEL_MAP] = 4; 550 InstSize[OPCODE_PIXEL_TRANSFER] = 3; 551 InstSize[OPCODE_PIXEL_ZOOM] = 3; 552 InstSize[OPCODE_POINT_SIZE] = 2; 553 InstSize[OPCODE_POINT_PARAMETERS] = 5; 554 InstSize[OPCODE_POLYGON_MODE] = 3; 555 InstSize[OPCODE_POLYGON_STIPPLE] = 2; 556 InstSize[OPCODE_POLYGON_OFFSET] = 3; 557 InstSize[OPCODE_POP_ATTRIB] = 1; 558 InstSize[OPCODE_POP_MATRIX] = 1; 559 InstSize[OPCODE_POP_NAME] = 1; 560 InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3; 561 InstSize[OPCODE_PUSH_ATTRIB] = 2; 562 InstSize[OPCODE_PUSH_MATRIX] = 1; 563 InstSize[OPCODE_PUSH_NAME] = 2; 564 InstSize[OPCODE_RASTER_POS] = 5; 565 InstSize[OPCODE_RECTF] = 5; 566 InstSize[OPCODE_READ_BUFFER] = 2; 567 InstSize[OPCODE_SCALE] = 4; 568 InstSize[OPCODE_SCISSOR] = 5; 569 InstSize[OPCODE_STENCIL_FUNC] = 4; 570 InstSize[OPCODE_STENCIL_MASK] = 2; 571 InstSize[OPCODE_STENCIL_OP] = 4; 572 InstSize[OPCODE_SHADE_MODEL] = 2; 573 InstSize[OPCODE_TEXENV] = 7; 574 InstSize[OPCODE_TEXGEN] = 7; 575 InstSize[OPCODE_TEXPARAMETER] = 7; 576 InstSize[OPCODE_TEX_IMAGE1D] = 9; 577 InstSize[OPCODE_TEX_IMAGE2D] = 10; 578 InstSize[OPCODE_TEX_IMAGE3D] = 11; 579 InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8; 580 InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10; 581 InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12; 582 InstSize[OPCODE_TRANSLATE] = 4; 583 InstSize[OPCODE_VIEWPORT] = 5; 584 InstSize[OPCODE_WINDOW_POS] = 5; 585 InstSize[OPCODE_CONTINUE] = 2; 586 InstSize[OPCODE_ERROR] = 3; 587 InstSize[OPCODE_VERTEX_CASSETTE] = 9; 588 InstSize[OPCODE_END_OF_LIST] = 1; 589 /* GL_ARB_multitexture */ 590 InstSize[OPCODE_ACTIVE_TEXTURE] = 2; 591 InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2; 592 } 593 init_flag = 1; 594} 595 596 597/* 598 * Display List compilation functions 599 */ 600 601 602 603static void save_Accum( GLenum op, GLfloat value ) 604{ 605 GET_CURRENT_CONTEXT(ctx); 606 Node *n; 607 FLUSH_VB(ctx, "dlist"); 608 n = alloc_instruction( ctx, OPCODE_ACCUM, 2 ); 609 if (n) { 610 n[1].e = op; 611 n[2].f = value; 612 } 613 if (ctx->ExecuteFlag) { 614 (*ctx->Exec->Accum)( op, value ); 615 } 616} 617 618 619static void save_AlphaFunc( GLenum func, GLclampf ref ) 620{ 621 GET_CURRENT_CONTEXT(ctx); 622 Node *n; 623 FLUSH_VB(ctx, "dlist"); 624 n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 ); 625 if (n) { 626 n[1].e = func; 627 n[2].f = (GLfloat) ref; 628 } 629 if (ctx->ExecuteFlag) { 630 (*ctx->Exec->AlphaFunc)( func, ref ); 631 } 632} 633 634 635static void save_Begin( GLenum mode ) 636{ 637 _mesa_Begin(mode); /* special case */ 638} 639 640 641static void save_BindTexture( GLenum target, GLuint texture ) 642{ 643 GET_CURRENT_CONTEXT(ctx); 644 Node *n; 645 FLUSH_VB(ctx, "dlist"); 646 n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 ); 647 if (n) { 648 n[1].e = target; 649 n[2].ui = texture; 650 } 651 if (ctx->ExecuteFlag) { 652 (*ctx->Exec->BindTexture)( target, texture ); 653 } 654} 655 656 657static void save_Bitmap( GLsizei width, GLsizei height, 658 GLfloat xorig, GLfloat yorig, 659 GLfloat xmove, GLfloat ymove, 660 const GLubyte *pixels ) 661{ 662 GET_CURRENT_CONTEXT(ctx); 663 GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack ); 664 Node *n; 665 FLUSH_VB(ctx, "dlist"); 666 n = alloc_instruction( ctx, OPCODE_BITMAP, 7 ); 667 if (n) { 668 n[1].i = (GLint) width; 669 n[2].i = (GLint) height; 670 n[3].f = xorig; 671 n[4].f = yorig; 672 n[5].f = xmove; 673 n[6].f = ymove; 674 n[7].data = image; 675 } 676 else if (image) { 677 FREE(image); 678 } 679 if (ctx->ExecuteFlag) { 680 (*ctx->Exec->Bitmap)( width, height, 681 xorig, yorig, xmove, ymove, pixels ); 682 } 683} 684 685 686static void save_BlendEquation( GLenum mode ) 687{ 688 GET_CURRENT_CONTEXT(ctx); 689 Node *n; 690 FLUSH_VB(ctx, "dlist"); 691 n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 ); 692 if (n) { 693 n[1].e = mode; 694 } 695 if (ctx->ExecuteFlag) { 696 (*ctx->Exec->BlendEquation)( mode ); 697 } 698} 699 700 701static void save_BlendFunc( GLenum sfactor, GLenum dfactor ) 702{ 703 GET_CURRENT_CONTEXT(ctx); 704 Node *n; 705 FLUSH_VB(ctx, "dlist"); 706 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 ); 707 if (n) { 708 n[1].e = sfactor; 709 n[2].e = dfactor; 710 } 711 if (ctx->ExecuteFlag) { 712 (*ctx->Exec->BlendFunc)( sfactor, dfactor ); 713 } 714} 715 716 717static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, 718 GLenum sfactorA, GLenum dfactorA) 719{ 720 GET_CURRENT_CONTEXT(ctx); 721 Node *n; 722 FLUSH_VB(ctx, "dlist"); 723 n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 ); 724 if (n) { 725 n[1].e = sfactorRGB; 726 n[2].e = dfactorRGB; 727 n[3].e = sfactorA; 728 n[4].e = dfactorA; 729 } 730 if (ctx->ExecuteFlag) { 731 (*ctx->Exec->BlendFuncSeparateEXT)( sfactorRGB, dfactorRGB, 732 sfactorA, dfactorA); 733 } 734} 735 736 737static void save_BlendColor( GLfloat red, GLfloat green, 738 GLfloat blue, GLfloat alpha ) 739{ 740 GET_CURRENT_CONTEXT(ctx); 741 Node *n; 742 FLUSH_VB(ctx, "dlist"); 743 n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 ); 744 if (n) { 745 n[1].f = red; 746 n[2].f = green; 747 n[3].f = blue; 748 n[4].f = alpha; 749 } 750 if (ctx->ExecuteFlag) { 751 (*ctx->Exec->BlendColor)( red, green, blue, alpha ); 752 } 753} 754 755 756static void save_CallList( GLuint list ) 757{ 758 GET_CURRENT_CONTEXT(ctx); 759 Node *n; 760 FLUSH_VB(ctx, "dlist"); 761 n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 ); 762 if (n) { 763 n[1].ui = list; 764 } 765 if (ctx->ExecuteFlag) { 766 (*ctx->Exec->CallList)( list ); 767 } 768} 769 770 771static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) 772{ 773 GET_CURRENT_CONTEXT(ctx); 774 GLint i; 775 FLUSH_VB(ctx, "dlist"); 776 777 for (i=0;i<n;i++) { 778 GLuint list = translate_id( i, type, lists ); 779 Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 ); 780 if (n) { 781 n[1].ui = list; 782 } 783 } 784 if (ctx->ExecuteFlag) { 785 (*ctx->Exec->CallLists)( n, type, lists ); 786 } 787} 788 789 790static void save_Clear( GLbitfield mask ) 791{ 792 GET_CURRENT_CONTEXT(ctx); 793 Node *n; 794 FLUSH_VB(ctx, "dlist"); 795 n = alloc_instruction( ctx, OPCODE_CLEAR, 1 ); 796 if (n) { 797 n[1].bf = mask; 798 } 799 if (ctx->ExecuteFlag) { 800 (*ctx->Exec->Clear)( mask ); 801 } 802} 803 804 805static void save_ClearAccum( GLfloat red, GLfloat green, 806 GLfloat blue, GLfloat alpha ) 807{ 808 GET_CURRENT_CONTEXT(ctx); 809 Node *n; 810 FLUSH_VB(ctx, "dlist"); 811 n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 ); 812 if (n) { 813 n[1].f = red; 814 n[2].f = green; 815 n[3].f = blue; 816 n[4].f = alpha; 817 } 818 if (ctx->ExecuteFlag) { 819 (*ctx->Exec->ClearAccum)( red, green, blue, alpha ); 820 } 821} 822 823 824static void save_ClearColor( GLclampf red, GLclampf green, 825 GLclampf blue, GLclampf alpha ) 826{ 827 GET_CURRENT_CONTEXT(ctx); 828 Node *n; 829 FLUSH_VB(ctx, "dlist"); 830 n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 ); 831 if (n) { 832 n[1].f = red; 833 n[2].f = green; 834 n[3].f = blue; 835 n[4].f = alpha; 836 } 837 if (ctx->ExecuteFlag) { 838 (*ctx->Exec->ClearColor)( red, green, blue, alpha ); 839 } 840} 841 842 843static void save_ClearDepth( GLclampd depth ) 844{ 845 GET_CURRENT_CONTEXT(ctx); 846 Node *n; 847 FLUSH_VB(ctx, "dlist"); 848 n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 ); 849 if (n) { 850 n[1].f = (GLfloat) depth; 851 } 852 if (ctx->ExecuteFlag) { 853 (*ctx->Exec->ClearDepth)( depth ); 854 } 855} 856 857 858static void save_ClearIndex( GLfloat c ) 859{ 860 GET_CURRENT_CONTEXT(ctx); 861 Node *n; 862 FLUSH_VB(ctx, "dlist"); 863 n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 ); 864 if (n) { 865 n[1].f = c; 866 } 867 if (ctx->ExecuteFlag) { 868 (*ctx->Exec->ClearIndex)( c ); 869 } 870} 871 872 873static void save_ClearStencil( GLint s ) 874{ 875 GET_CURRENT_CONTEXT(ctx); 876 Node *n; 877 FLUSH_VB(ctx, "dlist"); 878 n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 ); 879 if (n) { 880 n[1].i = s; 881 } 882 if (ctx->ExecuteFlag) { 883 (*ctx->Exec->ClearStencil)( s ); 884 } 885} 886 887 888static void save_ClipPlane( GLenum plane, const GLdouble *equ ) 889{ 890 GET_CURRENT_CONTEXT(ctx); 891 Node *n; 892 FLUSH_VB(ctx, "dlist"); 893 n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 ); 894 if (n) { 895 n[1].e = plane; 896 n[2].f = equ[0]; 897 n[3].f = equ[1]; 898 n[4].f = equ[2]; 899 n[5].f = equ[3]; 900 } 901 if (ctx->ExecuteFlag) { 902 (*ctx->Exec->ClipPlane)( plane, equ ); 903 } 904} 905 906 907 908static void save_ColorMask( GLboolean red, GLboolean green, 909 GLboolean blue, GLboolean alpha ) 910{ 911 GET_CURRENT_CONTEXT(ctx); 912 Node *n; 913 FLUSH_VB(ctx, "dlist"); 914 n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 ); 915 if (n) { 916 n[1].b = red; 917 n[2].b = green; 918 n[3].b = blue; 919 n[4].b = alpha; 920 } 921 if (ctx->ExecuteFlag) { 922 (*ctx->Exec->ColorMask)( red, green, blue, alpha ); 923 } 924} 925 926 927static void save_ColorMaterial( GLenum face, GLenum mode ) 928{ 929 GET_CURRENT_CONTEXT(ctx); 930 Node *n; 931 FLUSH_VB(ctx, "dlist"); 932 n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 ); 933 if (n) { 934 n[1].e = face; 935 n[2].e = mode; 936 } 937 if (ctx->ExecuteFlag) { 938 (*ctx->Exec->ColorMaterial)( face, mode ); 939 } 940} 941 942 943static void save_ColorTable( GLenum target, GLenum internalFormat, 944 GLsizei width, GLenum format, GLenum type, 945 const GLvoid *table ) 946{ 947 GET_CURRENT_CONTEXT(ctx); 948 if (target == GL_PROXY_TEXTURE_1D || 949 target == GL_PROXY_TEXTURE_2D || 950 target == GL_PROXY_TEXTURE_3D) { 951 /* execute immediately */ 952 (*ctx->Exec->ColorTable)( target, internalFormat, width, 953 format, type, table ); 954 } 955 else { 956 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table, 957 &ctx->Unpack); 958 Node *n; 959 FLUSH_VB(ctx, "dlist"); 960 n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 6 ); 961 if (n) { 962 n[1].e = target; 963 n[2].e = internalFormat; 964 n[3].i = width; 965 n[4].e = format; 966 n[5].e = type; 967 n[6].data = image; 968 } 969 else if (image) { 970 FREE(image); 971 } 972 if (ctx->ExecuteFlag) { 973 (*ctx->Exec->ColorTable)( target, internalFormat, width, 974 format, type, table ); 975 } 976 } 977} 978 979 980static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count, 981 GLenum format, GLenum type, 982 const GLvoid *table) 983{ 984 GET_CURRENT_CONTEXT(ctx); 985 GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table, 986 &ctx->Unpack); 987 Node *n; 988 FLUSH_VB(ctx, "dlist"); 989 n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 6 ); 990 if (n) { 991 n[1].e = target; 992 n[2].i = start; 993 n[3].i = count; 994 n[4].e = format; 995 n[5].e = type; 996 n[6].data = image; 997 } 998 else if (image) { 999 FREE(image); 1000 } 1001 if (ctx->ExecuteFlag) { 1002 (*ctx->Exec->ColorSubTable)(target, start, count, format, type, table); 1003 } 1004} 1005 1006 1007 1008static void save_CopyPixels( GLint x, GLint y, 1009 GLsizei width, GLsizei height, GLenum type ) 1010{ 1011 GET_CURRENT_CONTEXT(ctx); 1012 Node *n; 1013 FLUSH_VB(ctx, "dlist"); 1014 n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 ); 1015 if (n) { 1016 n[1].i = x; 1017 n[2].i = y; 1018 n[3].i = (GLint) width; 1019 n[4].i = (GLint) height; 1020 n[5].e = type; 1021 } 1022 if (ctx->ExecuteFlag) { 1023 (*ctx->Exec->CopyPixels)( x, y, width, height, type ); 1024 } 1025} 1026 1027 1028 1029static void 1030save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat, 1031 GLint x, GLint y, GLsizei width, GLint border ) 1032{ 1033 GET_CURRENT_CONTEXT(ctx); 1034 Node *n; 1035 FLUSH_VB(ctx, "dlist"); 1036 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 ); 1037 if (n) { 1038 n[1].e = target; 1039 n[2].i = level; 1040 n[3].e = internalformat; 1041 n[4].i = x; 1042 n[5].i = y; 1043 n[6].i = width; 1044 n[7].i = border; 1045 } 1046 if (ctx->ExecuteFlag) { 1047 (*ctx->Exec->CopyTexImage1D)( target, level, internalformat, 1048 x, y, width, border ); 1049 } 1050} 1051 1052 1053static void 1054save_CopyTexImage2D( GLenum target, GLint level, 1055 GLenum internalformat, 1056 GLint x, GLint y, GLsizei width, 1057 GLsizei height, GLint border ) 1058{ 1059 GET_CURRENT_CONTEXT(ctx); 1060 Node *n; 1061 FLUSH_VB(ctx, "dlist"); 1062 n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 ); 1063 if (n) { 1064 n[1].e = target; 1065 n[2].i = level; 1066 n[3].e = internalformat; 1067 n[4].i = x; 1068 n[5].i = y; 1069 n[6].i = width; 1070 n[7].i = height; 1071 n[8].i = border; 1072 } 1073 if (ctx->ExecuteFlag) { 1074 (*ctx->Exec->CopyTexImage2D)( target, level, internalformat, 1075 x, y, width, height, border ); 1076 } 1077} 1078 1079 1080 1081static void 1082save_CopyTexSubImage1D( GLenum target, GLint level, 1083 GLint xoffset, GLint x, GLint y, 1084 GLsizei width ) 1085{ 1086 GET_CURRENT_CONTEXT(ctx); 1087 Node *n; 1088 FLUSH_VB(ctx, "dlist"); 1089 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 ); 1090 if (n) { 1091 n[1].e = target; 1092 n[2].i = level; 1093 n[3].i = xoffset; 1094 n[4].i = x; 1095 n[5].i = y; 1096 n[6].i = width; 1097 } 1098 if (ctx->ExecuteFlag) { 1099 (*ctx->Exec->CopyTexSubImage1D)( target, level, xoffset, x, y, width ); 1100 } 1101} 1102 1103 1104static void 1105save_CopyTexSubImage2D( GLenum target, GLint level, 1106 GLint xoffset, GLint yoffset, 1107 GLint x, GLint y, 1108 GLsizei width, GLint height ) 1109{ 1110 GET_CURRENT_CONTEXT(ctx); 1111 Node *n; 1112 FLUSH_VB(ctx, "dlist"); 1113 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 ); 1114 if (n) { 1115 n[1].e = target; 1116 n[2].i = level; 1117 n[3].i = xoffset; 1118 n[4].i = yoffset; 1119 n[5].i = x; 1120 n[6].i = y; 1121 n[7].i = width; 1122 n[8].i = height; 1123 } 1124 if (ctx->ExecuteFlag) { 1125 (*ctx->Exec->CopyTexSubImage2D)( target, level, xoffset, yoffset, 1126 x, y, width, height ); 1127 } 1128} 1129 1130 1131static void 1132save_CopyTexSubImage3D( GLenum target, GLint level, 1133 GLint xoffset, GLint yoffset, GLint zoffset, 1134 GLint x, GLint y, 1135 GLsizei width, GLint height ) 1136{ 1137 GET_CURRENT_CONTEXT(ctx); 1138 Node *n; 1139 FLUSH_VB(ctx, "dlist"); 1140 n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 ); 1141 if (n) { 1142 n[1].e = target; 1143 n[2].i = level; 1144 n[3].i = xoffset; 1145 n[4].i = yoffset; 1146 n[5].i = zoffset; 1147 n[6].i = x; 1148 n[7].i = y; 1149 n[8].i = width; 1150 n[9].i = height; 1151 } 1152 if (ctx->ExecuteFlag) { 1153 (*ctx->Exec->CopyTexSubImage3D)( target, level, 1154 xoffset, yoffset, zoffset, 1155 x, y, width, height ); 1156 } 1157} 1158 1159 1160static void save_CullFace( GLenum mode ) 1161{ 1162 GET_CURRENT_CONTEXT(ctx); 1163 Node *n; 1164 FLUSH_VB(ctx, "dlist"); 1165 n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 ); 1166 if (n) { 1167 n[1].e = mode; 1168 } 1169 if (ctx->ExecuteFlag) { 1170 (*ctx->Exec->CullFace)( mode ); 1171 } 1172} 1173 1174 1175static void save_DepthFunc( GLenum func ) 1176{ 1177 GET_CURRENT_CONTEXT(ctx); 1178 Node *n; 1179 FLUSH_VB(ctx, "dlist"); 1180 n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 ); 1181 if (n) { 1182 n[1].e = func; 1183 } 1184 if (ctx->ExecuteFlag) { 1185 (*ctx->Exec->DepthFunc)( func ); 1186 } 1187} 1188 1189 1190static void save_DepthMask( GLboolean mask ) 1191{ 1192 GET_CURRENT_CONTEXT(ctx); 1193 Node *n; 1194 FLUSH_VB(ctx, "dlist"); 1195 n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 ); 1196 if (n) { 1197 n[1].b = mask; 1198 } 1199 if (ctx->ExecuteFlag) { 1200 (*ctx->Exec->DepthMask)( mask ); 1201 } 1202} 1203 1204 1205static void save_DepthRange( GLclampd nearval, GLclampd farval ) 1206{ 1207 GET_CURRENT_CONTEXT(ctx); 1208 Node *n; 1209 FLUSH_VB(ctx, "dlist"); 1210 n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 ); 1211 if (n) { 1212 n[1].f = (GLfloat) nearval; 1213 n[2].f = (GLfloat) farval; 1214 } 1215 if (ctx->ExecuteFlag) { 1216 (*ctx->Exec->DepthRange)( nearval, farval ); 1217 } 1218} 1219 1220 1221static void save_Disable( GLenum cap ) 1222{ 1223 GET_CURRENT_CONTEXT(ctx); 1224 Node *n; 1225 FLUSH_VB(ctx, "dlist"); 1226 n = alloc_instruction( ctx, OPCODE_DISABLE, 1 ); 1227 if (n) { 1228 n[1].e = cap; 1229 } 1230 if (ctx->ExecuteFlag) { 1231 (*ctx->Exec->Disable)( cap ); 1232 } 1233} 1234 1235 1236static void save_DrawBuffer( GLenum mode ) 1237{ 1238 GET_CURRENT_CONTEXT(ctx); 1239 Node *n; 1240 FLUSH_VB(ctx, "dlist"); 1241 n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 ); 1242 if (n) { 1243 n[1].e = mode; 1244 } 1245 if (ctx->ExecuteFlag) { 1246 (*ctx->Exec->DrawBuffer)( mode ); 1247 } 1248} 1249 1250 1251static void save_DrawPixels( GLsizei width, GLsizei height, 1252 GLenum format, GLenum type, 1253 const GLvoid *pixels ) 1254{ 1255 GET_CURRENT_CONTEXT(ctx); 1256 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, 1257 pixels, &ctx->Unpack); 1258 Node *n; 1259 FLUSH_VB(ctx, "dlist"); 1260 n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 ); 1261 if (n) { 1262 n[1].i = width; 1263 n[2].i = height; 1264 n[3].e = format; 1265 n[4].e = type; 1266 n[5].data = image; 1267 } 1268 else if (image) { 1269 FREE(image); 1270 } 1271 if (ctx->ExecuteFlag) { 1272 (*ctx->Exec->DrawPixels)( width, height, format, type, pixels ); 1273 } 1274} 1275 1276 1277 1278static void save_Enable( GLenum cap ) 1279{ 1280 GET_CURRENT_CONTEXT(ctx); 1281 Node *n; 1282 FLUSH_VB(ctx, "dlist"); 1283 n = alloc_instruction( ctx, OPCODE_ENABLE, 1 ); 1284 if (n) { 1285 n[1].e = cap; 1286 } 1287 if (ctx->ExecuteFlag) { 1288 (*ctx->Exec->Enable)( cap ); 1289 } 1290} 1291 1292 1293 1294static void save_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) 1295{ 1296 GET_CURRENT_CONTEXT(ctx); 1297 Node *n; 1298 FLUSH_VB(ctx, "dlist"); 1299 n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 ); 1300 if (n) { 1301 n[1].e = mode; 1302 n[2].i = i1; 1303 n[3].i = i2; 1304 } 1305 if (ctx->ExecuteFlag) { 1306 (*ctx->Exec->EvalMesh1)( mode, i1, i2 ); 1307 } 1308} 1309 1310 1311static void save_EvalMesh2( 1312 GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) 1313{ 1314 GET_CURRENT_CONTEXT(ctx); 1315 Node *n; 1316 FLUSH_VB(ctx, "dlist"); 1317 n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 ); 1318 if (n) { 1319 n[1].e = mode; 1320 n[2].i = i1; 1321 n[3].i = i2; 1322 n[4].i = j1; 1323 n[5].i = j2; 1324 } 1325 if (ctx->ExecuteFlag) { 1326 (*ctx->Exec->EvalMesh2)( mode, i1, i2, j1, j2 ); 1327 } 1328} 1329 1330 1331 1332 1333static void save_Fogfv( GLenum pname, const GLfloat *params ) 1334{ 1335 GET_CURRENT_CONTEXT(ctx); 1336 Node *n; 1337 FLUSH_VB(ctx, "dlist"); 1338 n = alloc_instruction( ctx, OPCODE_FOG, 5 ); 1339 if (n) { 1340 n[1].e = pname; 1341 n[2].f = params[0]; 1342 n[3].f = params[1]; 1343 n[4].f = params[2]; 1344 n[5].f = params[3]; 1345 } 1346 if (ctx->ExecuteFlag) { 1347 (*ctx->Exec->Fogfv)( pname, params ); 1348 } 1349} 1350 1351 1352static void save_Fogf( GLenum pname, GLfloat param ) 1353{ 1354 save_Fogfv(pname, ¶m); 1355} 1356 1357 1358static void save_Fogiv(GLenum pname, const GLint *params ) 1359{ 1360 GLfloat p[4]; 1361 switch (pname) { 1362 case GL_FOG_MODE: 1363 case GL_FOG_DENSITY: 1364 case GL_FOG_START: 1365 case GL_FOG_END: 1366 case GL_FOG_INDEX: 1367 p[0] = (GLfloat) *params; 1368 break; 1369 case GL_FOG_COLOR: 1370 p[0] = INT_TO_FLOAT( params[0] ); 1371 p[1] = INT_TO_FLOAT( params[1] ); 1372 p[2] = INT_TO_FLOAT( params[2] ); 1373 p[3] = INT_TO_FLOAT( params[3] ); 1374 break; 1375 default: 1376 /* Error will be caught later in gl_Fogfv */ 1377 ; 1378 } 1379 save_Fogfv(pname, p); 1380} 1381 1382 1383static void save_Fogi(GLenum pname, GLint param ) 1384{ 1385 save_Fogiv(pname, ¶m); 1386} 1387 1388 1389static void save_FrontFace( GLenum mode ) 1390{ 1391 GET_CURRENT_CONTEXT(ctx); 1392 Node *n; 1393 FLUSH_VB(ctx, "dlist"); 1394 n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 ); 1395 if (n) { 1396 n[1].e = mode; 1397 } 1398 if (ctx->ExecuteFlag) { 1399 (*ctx->Exec->FrontFace)( mode ); 1400 } 1401} 1402 1403 1404static void save_Frustum( GLdouble left, GLdouble right, 1405 GLdouble bottom, GLdouble top, 1406 GLdouble nearval, GLdouble farval ) 1407{ 1408 GET_CURRENT_CONTEXT(ctx); 1409 Node *n; 1410 FLUSH_VB(ctx, "dlist"); 1411 n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 ); 1412 if (n) { 1413 n[1].f = left; 1414 n[2].f = right; 1415 n[3].f = bottom; 1416 n[4].f = top; 1417 n[5].f = nearval; 1418 n[6].f = farval; 1419 } 1420 if (ctx->ExecuteFlag) { 1421 (*ctx->Exec->Frustum)( left, right, bottom, top, nearval, farval ); 1422 } 1423} 1424 1425 1426static void save_Hint( GLenum target, GLenum mode ) 1427{ 1428 GET_CURRENT_CONTEXT(ctx); 1429 Node *n; 1430 FLUSH_VB(ctx, "dlist"); 1431 n = alloc_instruction( ctx, OPCODE_HINT, 2 ); 1432 if (n) { 1433 n[1].e = target; 1434 n[2].e = mode; 1435 } 1436 if (ctx->ExecuteFlag) { 1437 (*ctx->Exec->Hint)( target, mode ); 1438 } 1439} 1440 1441 1442/* GL_PGI_misc_hints*/ 1443static void save_HintPGI( GLenum target, GLint mode ) 1444{ 1445 GET_CURRENT_CONTEXT(ctx); 1446 Node *n; 1447 FLUSH_VB(ctx, "dlist"); 1448 n = alloc_instruction( ctx, OPCODE_HINT_PGI, 2 ); 1449 if (n) { 1450 n[1].e = target; 1451 n[2].i = mode; 1452 } 1453 if (ctx->ExecuteFlag) { 1454 (*ctx->Exec->HintPGI)( target, mode ); 1455 } 1456} 1457 1458 1459static void save_IndexMask( GLuint mask ) 1460{ 1461 GET_CURRENT_CONTEXT(ctx); 1462 Node *n; 1463 FLUSH_VB(ctx, "dlist"); 1464 n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 ); 1465 if (n) { 1466 n[1].ui = mask; 1467 } 1468 if (ctx->ExecuteFlag) { 1469 (*ctx->Exec->IndexMask)( mask ); 1470 } 1471} 1472 1473 1474static void save_InitNames( void ) 1475{ 1476 GET_CURRENT_CONTEXT(ctx); 1477 FLUSH_VB(ctx, "dlist"); 1478 (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 ); 1479 if (ctx->ExecuteFlag) { 1480 (*ctx->Exec->InitNames)(); 1481 } 1482} 1483 1484 1485static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) 1486{ 1487 GET_CURRENT_CONTEXT(ctx); 1488 Node *n; 1489 FLUSH_VB(ctx, "dlist"); 1490 n = alloc_instruction( ctx, OPCODE_LIGHT, 6 ); 1491 if (OPCODE_LIGHT) { 1492 GLint i, nParams; 1493 n[1].e = light; 1494 n[2].e = pname; 1495 switch (pname) { 1496 case GL_AMBIENT: 1497 nParams = 4; 1498 break; 1499 case GL_DIFFUSE: 1500 nParams = 4; 1501 break; 1502 case GL_SPECULAR: 1503 nParams = 4; 1504 break; 1505 case GL_POSITION: 1506 nParams = 4; 1507 break; 1508 case GL_SPOT_DIRECTION: 1509 nParams = 3; 1510 break; 1511 case GL_SPOT_EXPONENT: 1512 nParams = 1; 1513 break; 1514 case GL_SPOT_CUTOFF: 1515 nParams = 1; 1516 break; 1517 case GL_CONSTANT_ATTENUATION: 1518 nParams = 1; 1519 break; 1520 case GL_LINEAR_ATTENUATION: 1521 nParams = 1; 1522 break; 1523 case GL_QUADRATIC_ATTENUATION: 1524 nParams = 1; 1525 break; 1526 default: 1527 nParams = 0; 1528 } 1529 for (i = 0; i < nParams; i++) { 1530 n[3+i].f = params[i]; 1531 } 1532 } 1533 if (ctx->ExecuteFlag) { 1534 (*ctx->Exec->Lightfv)( light, pname, params ); 1535 } 1536} 1537 1538 1539static void save_Lightf( GLenum light, GLenum pname, GLfloat params ) 1540{ 1541 save_Lightfv(light, pname, ¶ms); 1542} 1543 1544 1545static void save_Lightiv( GLenum light, GLenum pname, const GLint *params ) 1546{ 1547 GLfloat fparam[4]; 1548 switch (pname) { 1549 case GL_AMBIENT: 1550 case GL_DIFFUSE: 1551 case GL_SPECULAR: 1552 fparam[0] = INT_TO_FLOAT( params[0] ); 1553 fparam[1] = INT_TO_FLOAT( params[1] ); 1554 fparam[2] = INT_TO_FLOAT( params[2] ); 1555 fparam[3] = INT_TO_FLOAT( params[3] ); 1556 break; 1557 case GL_POSITION: 1558 fparam[0] = (GLfloat) params[0]; 1559 fparam[1] = (GLfloat) params[1]; 1560 fparam[2] = (GLfloat) params[2]; 1561 fparam[3] = (GLfloat) params[3]; 1562 break; 1563 case GL_SPOT_DIRECTION: 1564 fparam[0] = (GLfloat) params[0]; 1565 fparam[1] = (GLfloat) params[1]; 1566 fparam[2] = (GLfloat) params[2]; 1567 break; 1568 case GL_SPOT_EXPONENT: 1569 case GL_SPOT_CUTOFF: 1570 case GL_CONSTANT_ATTENUATION: 1571 case GL_LINEAR_ATTENUATION: 1572 case GL_QUADRATIC_ATTENUATION: 1573 fparam[0] = (GLfloat) params[0]; 1574 break; 1575 default: 1576 /* error will be caught later in gl_Lightfv */ 1577 ; 1578 } 1579 save_Lightfv( light, pname, fparam ); 1580} 1581 1582 1583static void save_Lighti( GLenum light, GLenum pname, GLint param ) 1584{ 1585 save_Lightiv( light, pname, ¶m ); 1586} 1587 1588 1589static void save_LightModelfv( GLenum pname, const GLfloat *params ) 1590{ 1591 GET_CURRENT_CONTEXT(ctx); 1592 Node *n; 1593 FLUSH_VB(ctx, "dlist"); 1594 n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 ); 1595 if (n) { 1596 n[1].e = pname; 1597 n[2].f = params[0]; 1598 n[3].f = params[1]; 1599 n[4].f = params[2]; 1600 n[5].f = params[3]; 1601 } 1602 if (ctx->ExecuteFlag) { 1603 (*ctx->Exec->LightModelfv)( pname, params ); 1604 } 1605} 1606 1607 1608static void save_LightModelf( GLenum pname, GLfloat param ) 1609{ 1610 save_LightModelfv(pname, ¶m); 1611} 1612 1613 1614static void save_LightModeliv( GLenum pname, const GLint *params ) 1615{ 1616 GLfloat fparam[4]; 1617 switch (pname) { 1618 case GL_LIGHT_MODEL_AMBIENT: 1619 fparam[0] = INT_TO_FLOAT( params[0] ); 1620 fparam[1] = INT_TO_FLOAT( params[1] ); 1621 fparam[2] = INT_TO_FLOAT( params[2] ); 1622 fparam[3] = INT_TO_FLOAT( params[3] ); 1623 break; 1624 case GL_LIGHT_MODEL_LOCAL_VIEWER: 1625 case GL_LIGHT_MODEL_TWO_SIDE: 1626 case GL_LIGHT_MODEL_COLOR_CONTROL: 1627 fparam[0] = (GLfloat) params[0]; 1628 break; 1629 default: 1630 /* Error will be caught later in gl_LightModelfv */ 1631 ; 1632 } 1633 save_LightModelfv(pname, fparam); 1634} 1635 1636 1637static void save_LightModeli( GLenum pname, GLint param ) 1638{ 1639 save_LightModeliv(pname, ¶m); 1640} 1641 1642 1643static void save_LineStipple( GLint factor, GLushort pattern ) 1644{ 1645 GET_CURRENT_CONTEXT(ctx); 1646 Node *n; 1647 FLUSH_VB(ctx, "dlist"); 1648 n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 ); 1649 if (n) { 1650 n[1].i = factor; 1651 n[2].us = pattern; 1652 } 1653 if (ctx->ExecuteFlag) { 1654 (*ctx->Exec->LineStipple)( factor, pattern ); 1655 } 1656} 1657 1658 1659static void save_LineWidth( GLfloat width ) 1660{ 1661 GET_CURRENT_CONTEXT(ctx); 1662 Node *n; 1663 FLUSH_VB(ctx, "dlist"); 1664 n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 ); 1665 if (n) { 1666 n[1].f = width; 1667 } 1668 if (ctx->ExecuteFlag) { 1669 (*ctx->Exec->LineWidth)( width ); 1670 } 1671} 1672 1673 1674static void save_ListBase( GLuint base ) 1675{ 1676 GET_CURRENT_CONTEXT(ctx); 1677 Node *n; 1678 FLUSH_VB(ctx, "dlist"); 1679 n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 ); 1680 if (n) { 1681 n[1].ui = base; 1682 } 1683 if (ctx->ExecuteFlag) { 1684 (*ctx->Exec->ListBase)( base ); 1685 } 1686} 1687 1688 1689static void save_LoadIdentity( void ) 1690{ 1691 GET_CURRENT_CONTEXT(ctx); 1692 FLUSH_VB(ctx, "dlist"); 1693 (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 ); 1694 if (ctx->ExecuteFlag) { 1695 (*ctx->Exec->LoadIdentity)(); 1696 } 1697} 1698 1699 1700static void save_LoadMatrixf( const GLfloat *m ) 1701{ 1702 GET_CURRENT_CONTEXT(ctx); 1703 Node *n; 1704 FLUSH_VB(ctx, "dlist"); 1705 n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 ); 1706 if (n) { 1707 GLuint i; 1708 for (i=0;i<16;i++) { 1709 n[1+i].f = m[i]; 1710 } 1711 } 1712 if (ctx->ExecuteFlag) { 1713 (*ctx->Exec->LoadMatrixf)( m ); 1714 } 1715} 1716 1717 1718static void save_LoadMatrixd( const GLdouble *m ) 1719{ 1720 GLfloat f[16]; 1721 GLint i; 1722 for (i = 0; i < 16; i++) { 1723 f[i] = m[i]; 1724 } 1725 save_LoadMatrixf(f); 1726} 1727 1728 1729static void save_LoadName( GLuint name ) 1730{ 1731 GET_CURRENT_CONTEXT(ctx); 1732 Node *n; 1733 FLUSH_VB(ctx, "dlist"); 1734 n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 ); 1735 if (n) { 1736 n[1].ui = name; 1737 } 1738 if (ctx->ExecuteFlag) { 1739 (*ctx->Exec->LoadName)( name ); 1740 } 1741} 1742 1743 1744static void save_LogicOp( GLenum opcode ) 1745{ 1746 GET_CURRENT_CONTEXT(ctx); 1747 Node *n; 1748 FLUSH_VB(ctx, "dlist"); 1749 n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 ); 1750 if (n) { 1751 n[1].e = opcode; 1752 } 1753 if (ctx->ExecuteFlag) { 1754 (*ctx->Exec->LogicOp)( opcode ); 1755 } 1756} 1757 1758 1759static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, 1760 GLint order, const GLdouble *points) 1761{ 1762 GET_CURRENT_CONTEXT(ctx); 1763 Node *n; 1764 FLUSH_VB(ctx, "dlist"); 1765 n = alloc_instruction( ctx, OPCODE_MAP1, 6 ); 1766 if (n) { 1767 GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points ); 1768 n[1].e = target; 1769 n[2].f = u1; 1770 n[3].f = u2; 1771 n[4].i = _mesa_evaluator_components(target); /* stride */ 1772 n[5].i = order; 1773 n[6].data = (void *) pnts; 1774 } 1775 if (ctx->ExecuteFlag) { 1776 (*ctx->Exec->Map1d)( target, u1, u2, stride, order, points ); 1777 } 1778} 1779 1780static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, 1781 GLint order, const GLfloat *points) 1782{ 1783 GET_CURRENT_CONTEXT(ctx); 1784 Node *n; 1785 FLUSH_VB(ctx, "dlist"); 1786 n = alloc_instruction( ctx, OPCODE_MAP1, 6 ); 1787 if (n) { 1788 GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points ); 1789 n[1].e = target; 1790 n[2].f = u1; 1791 n[3].f = u2; 1792 n[4].i = _mesa_evaluator_components(target); /* stride */ 1793 n[5].i = order; 1794 n[6].data = (void *) pnts; 1795 } 1796 if (ctx->ExecuteFlag) { 1797 (*ctx->Exec->Map1f)( target, u1, u2, stride, order, points ); 1798 } 1799} 1800 1801 1802static void save_Map2d( GLenum target, 1803 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, 1804 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, 1805 const GLdouble *points ) 1806{ 1807 GET_CURRENT_CONTEXT(ctx); 1808 Node *n; 1809 FLUSH_VB(ctx, "dlist"); 1810 n = alloc_instruction( ctx, OPCODE_MAP2, 10 ); 1811 if (n) { 1812 GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder, 1813 vstride, vorder, points ); 1814 n[1].e = target; 1815 n[2].f = u1; 1816 n[3].f = u2; 1817 n[4].f = v1; 1818 n[5].f = v2; 1819 /* XXX verify these strides are correct */ 1820 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/ 1821 n[7].i = _mesa_evaluator_components(target); /*vstride*/ 1822 n[8].i = uorder; 1823 n[9].i = vorder; 1824 n[10].data = (void *) pnts; 1825 } 1826 if (ctx->ExecuteFlag) { 1827 (*ctx->Exec->Map2d)( target, 1828 u1, u2, ustride, uorder, 1829 v1, v2, vstride, vorder, points ); 1830 } 1831} 1832 1833 1834static void save_Map2f( GLenum target, 1835 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, 1836 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, 1837 const GLfloat *points ) 1838{ 1839 GET_CURRENT_CONTEXT(ctx); 1840 Node *n; 1841 FLUSH_VB(ctx, "dlist"); 1842 n = alloc_instruction( ctx, OPCODE_MAP2, 10 ); 1843 if (n) { 1844 GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder, 1845 vstride, vorder, points ); 1846 n[1].e = target; 1847 n[2].f = u1; 1848 n[3].f = u2; 1849 n[4].f = v1; 1850 n[5].f = v2; 1851 /* XXX verify these strides are correct */ 1852 n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/ 1853 n[7].i = _mesa_evaluator_components(target); /*vstride*/ 1854 n[8].i = uorder; 1855 n[9].i = vorder; 1856 n[10].data = (void *) pnts; 1857 } 1858 if (ctx->ExecuteFlag) { 1859 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder, 1860 v1, v2, vstride, vorder, points ); 1861 } 1862} 1863 1864 1865static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) 1866{ 1867 GET_CURRENT_CONTEXT(ctx); 1868 Node *n; 1869 FLUSH_VB(ctx, "dlist"); 1870 n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 ); 1871 if (n) { 1872 n[1].i = un; 1873 n[2].f = u1; 1874 n[3].f = u2; 1875 } 1876 if (ctx->ExecuteFlag) { 1877 (*ctx->Exec->MapGrid1f)( un, u1, u2 ); 1878 } 1879} 1880 1881 1882static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) 1883{ 1884 save_MapGrid1f(un, u1, u2); 1885} 1886 1887 1888static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, 1889 GLint vn, GLfloat v1, GLfloat v2 ) 1890{ 1891 GET_CURRENT_CONTEXT(ctx); 1892 Node *n; 1893 FLUSH_VB(ctx, "dlist"); 1894 n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 ); 1895 if (n) { 1896 n[1].i = un; 1897 n[2].f = u1; 1898 n[3].f = u2; 1899 n[4].i = vn; 1900 n[5].f = v1; 1901 n[6].f = v2; 1902 } 1903 if (ctx->ExecuteFlag) { 1904 (*ctx->Exec->MapGrid2f)( un, u1, u2, vn, v1, v2 ); 1905 } 1906} 1907 1908 1909 1910static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, 1911 GLint vn, GLdouble v1, GLdouble v2 ) 1912{ 1913 save_MapGrid2f(un, u1, u2, vn, v1, v2); 1914} 1915 1916 1917static void save_MatrixMode( GLenum mode ) 1918{ 1919 GET_CURRENT_CONTEXT(ctx); 1920 Node *n; 1921 FLUSH_VB(ctx, "dlist"); 1922 n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 ); 1923 if (n) { 1924 n[1].e = mode; 1925 } 1926 if (ctx->ExecuteFlag) { 1927 (*ctx->Exec->MatrixMode)( mode ); 1928 } 1929} 1930 1931 1932static void save_MultMatrixf( const GLfloat *m ) 1933{ 1934 GET_CURRENT_CONTEXT(ctx); 1935 Node *n; 1936 FLUSH_VB(ctx, "dlist"); 1937 n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 ); 1938 if (n) { 1939 GLuint i; 1940 for (i=0;i<16;i++) { 1941 n[1+i].f = m[i]; 1942 } 1943 } 1944 if (ctx->ExecuteFlag) { 1945 (*ctx->Exec->MultMatrixf)( m ); 1946 } 1947} 1948 1949 1950static void save_MultMatrixd( const GLdouble *m ) 1951{ 1952 GLfloat f[16]; 1953 GLint i; 1954 for (i = 0; i < 16; i++) { 1955 f[i] = m[i]; 1956 } 1957 save_MultMatrixf(f); 1958} 1959 1960 1961static void save_NewList( GLuint list, GLenum mode ) 1962{ 1963 GET_CURRENT_CONTEXT(ctx); 1964 /* It's an error to call this function while building a display list */ 1965 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" ); 1966 (void) list; 1967 (void) mode; 1968} 1969 1970 1971 1972static void save_Ortho( GLdouble left, GLdouble right, 1973 GLdouble bottom, GLdouble top, 1974 GLdouble nearval, GLdouble farval ) 1975{ 1976 GET_CURRENT_CONTEXT(ctx); 1977 Node *n; 1978 FLUSH_VB(ctx, "dlist"); 1979 n = alloc_instruction( ctx, OPCODE_ORTHO, 6 ); 1980 if (n) { 1981 n[1].f = left; 1982 n[2].f = right; 1983 n[3].f = bottom; 1984 n[4].f = top; 1985 n[5].f = nearval; 1986 n[6].f = farval; 1987 } 1988 if (ctx->ExecuteFlag) { 1989 (*ctx->Exec->Ortho)( left, right, bottom, top, nearval, farval ); 1990 } 1991} 1992 1993 1994static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ) 1995{ 1996 GET_CURRENT_CONTEXT(ctx); 1997 Node *n; 1998 FLUSH_VB(ctx, "dlist"); 1999 n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 ); 2000 if (n) { 2001 n[1].e = map; 2002 n[2].i = mapsize; 2003 n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) ); 2004 MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) ); 2005 } 2006 if (ctx->ExecuteFlag) { 2007 (*ctx->Exec->PixelMapfv)( map, mapsize, values ); 2008 } 2009} 2010 2011 2012static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values ) 2013{ 2014 GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; 2015 GLint i; 2016 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { 2017 for (i=0;i<mapsize;i++) { 2018 fvalues[i] = (GLfloat) values[i]; 2019 } 2020 } 2021 else { 2022 for (i=0;i<mapsize;i++) { 2023 fvalues[i] = UINT_TO_FLOAT( values[i] ); 2024 } 2025 } 2026 save_PixelMapfv(map, mapsize, fvalues); 2027} 2028 2029 2030static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) 2031{ 2032 GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; 2033 GLint i; 2034 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { 2035 for (i=0;i<mapsize;i++) { 2036 fvalues[i] = (GLfloat) values[i]; 2037 } 2038 } 2039 else { 2040 for (i=0;i<mapsize;i++) { 2041 fvalues[i] = USHORT_TO_FLOAT( values[i] ); 2042 } 2043 } 2044 save_PixelMapfv(map, mapsize, fvalues); 2045} 2046 2047 2048static void save_PixelTransferf( GLenum pname, GLfloat param ) 2049{ 2050 GET_CURRENT_CONTEXT(ctx); 2051 Node *n; 2052 FLUSH_VB(ctx, "dlist"); 2053 n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 ); 2054 if (n) { 2055 n[1].e = pname; 2056 n[2].f = param; 2057 } 2058 if (ctx->ExecuteFlag) { 2059 (*ctx->Exec->PixelTransferf)( pname, param ); 2060 } 2061} 2062 2063 2064static void save_PixelTransferi( GLenum pname, GLint param ) 2065{ 2066 save_PixelTransferf( pname, (GLfloat) param ); 2067} 2068 2069 2070static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor ) 2071{ 2072 GET_CURRENT_CONTEXT(ctx); 2073 Node *n; 2074 FLUSH_VB(ctx, "dlist"); 2075 n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 ); 2076 if (n) { 2077 n[1].f = xfactor; 2078 n[2].f = yfactor; 2079 } 2080 if (ctx->ExecuteFlag) { 2081 (*ctx->Exec->PixelZoom)( xfactor, yfactor ); 2082 } 2083} 2084 2085 2086static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params ) 2087{ 2088 GET_CURRENT_CONTEXT(ctx); 2089 Node *n; 2090 FLUSH_VB(ctx, "dlist"); 2091 n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 ); 2092 if (n) { 2093 n[1].e = pname; 2094 n[2].f = params[0]; 2095 n[3].f = params[1]; 2096 n[4].f = params[2]; 2097 } 2098 if (ctx->ExecuteFlag) { 2099 (*ctx->Exec->PointParameterfvEXT)( pname, params ); 2100 } 2101} 2102 2103 2104static void save_PointParameterfEXT( GLenum pname, GLfloat param ) 2105{ 2106 save_PointParameterfvEXT(pname, ¶m); 2107} 2108 2109 2110static void save_PointSize( GLfloat size ) 2111{ 2112 GET_CURRENT_CONTEXT(ctx); 2113 Node *n; 2114 FLUSH_VB(ctx, "dlist"); 2115 n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 ); 2116 if (n) { 2117 n[1].f = size; 2118 } 2119 if (ctx->ExecuteFlag) { 2120 (*ctx->Exec->PointSize)( size ); 2121 } 2122} 2123 2124 2125static void save_PolygonMode( GLenum face, GLenum mode ) 2126{ 2127 GET_CURRENT_CONTEXT(ctx); 2128 Node *n; 2129 FLUSH_VB(ctx, "dlist"); 2130 n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 ); 2131 if (n) { 2132 n[1].e = face; 2133 n[2].e = mode; 2134 } 2135 if (ctx->ExecuteFlag) { 2136 (*ctx->Exec->PolygonMode)( face, mode ); 2137 } 2138} 2139 2140 2141/* 2142 * Polygon stipple must have been upacked already! 2143 */ 2144static void save_PolygonStipple( const GLubyte *pattern ) 2145{ 2146 GET_CURRENT_CONTEXT(ctx); 2147 Node *n; 2148 FLUSH_VB(ctx, "dlist"); 2149 n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 ); 2150 if (n) { 2151 void *data; 2152 n[1].data = MALLOC( 32 * 4 ); 2153 data = n[1].data; /* This needed for Acorn compiler */ 2154 MEMCPY( data, pattern, 32 * 4 ); 2155 } 2156 if (ctx->ExecuteFlag) { 2157 (*ctx->Exec->PolygonStipple)( (GLubyte*) pattern ); 2158 } 2159} 2160 2161 2162static void save_PolygonOffset( GLfloat factor, GLfloat units ) 2163{ 2164 GET_CURRENT_CONTEXT(ctx); 2165 Node *n; 2166 FLUSH_VB(ctx, "dlist"); 2167 n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 ); 2168 if (n) { 2169 n[1].f = factor; 2170 n[2].f = units; 2171 } 2172 if (ctx->ExecuteFlag) { 2173 (*ctx->Exec->PolygonOffset)( factor, units ); 2174 } 2175} 2176 2177 2178static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) 2179{ 2180 save_PolygonOffset(factor, DEPTH_SCALE * bias); 2181} 2182 2183 2184static void save_PopAttrib( void ) 2185{ 2186 GET_CURRENT_CONTEXT(ctx); 2187 FLUSH_VB(ctx, "dlist"); 2188 (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 ); 2189 if (ctx->ExecuteFlag) { 2190 (*ctx->Exec->PopAttrib)(); 2191 } 2192} 2193 2194 2195static void save_PopMatrix( void ) 2196{ 2197 GET_CURRENT_CONTEXT(ctx); 2198 FLUSH_VB(ctx, "dlist"); 2199 (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 ); 2200 if (ctx->ExecuteFlag) { 2201 (*ctx->Exec->PopMatrix)(); 2202 } 2203} 2204 2205 2206static void save_PopName( void ) 2207{ 2208 GET_CURRENT_CONTEXT(ctx); 2209 FLUSH_VB(ctx, "dlist"); 2210 (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 ); 2211 if (ctx->ExecuteFlag) { 2212 (*ctx->Exec->PopName)(); 2213 } 2214} 2215 2216 2217static void save_PrioritizeTextures( GLsizei num, const GLuint *textures, 2218 const GLclampf *priorities ) 2219{ 2220 GET_CURRENT_CONTEXT(ctx); 2221 GLint i; 2222 FLUSH_VB(ctx, "dlist"); 2223 2224 for (i=0;i<num;i++) { 2225 Node *n; 2226 n = alloc_instruction( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 ); 2227 if (n) { 2228 n[1].ui = textures[i]; 2229 n[2].f = priorities[i]; 2230 } 2231 } 2232 if (ctx->ExecuteFlag) { 2233 (*ctx->Exec->PrioritizeTextures)( num, textures, priorities ); 2234 } 2235} 2236 2237 2238static void save_PushAttrib( GLbitfield mask ) 2239{ 2240 GET_CURRENT_CONTEXT(ctx); 2241 Node *n; 2242 FLUSH_VB(ctx, "dlist"); 2243 n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 ); 2244 if (n) { 2245 n[1].bf = mask; 2246 } 2247 if (ctx->ExecuteFlag) { 2248 (*ctx->Exec->PushAttrib)( mask ); 2249 } 2250} 2251 2252 2253static void save_PushMatrix( void ) 2254{ 2255 GET_CURRENT_CONTEXT(ctx); 2256 FLUSH_VB(ctx, "dlist"); 2257 (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 ); 2258 if (ctx->ExecuteFlag) { 2259 (*ctx->Exec->PushMatrix)(); 2260 } 2261} 2262 2263 2264static void save_PushName( GLuint name ) 2265{ 2266 GET_CURRENT_CONTEXT(ctx); 2267 Node *n; 2268 FLUSH_VB(ctx, "dlist"); 2269 n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 ); 2270 if (n) { 2271 n[1].ui = name; 2272 } 2273 if (ctx->ExecuteFlag) { 2274 (*ctx->Exec->PushName)( name ); 2275 } 2276} 2277 2278 2279static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) 2280{ 2281 GET_CURRENT_CONTEXT(ctx); 2282 Node *n; 2283 FLUSH_VB(ctx, "dlist"); 2284 n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 ); 2285 if (n) { 2286 n[1].f = x; 2287 n[2].f = y; 2288 n[3].f = z; 2289 n[4].f = w; 2290 } 2291 if (ctx->ExecuteFlag) { 2292 (*ctx->Exec->RasterPos4f)( x, y, z, w ); 2293 } 2294} 2295 2296static void save_RasterPos2d(GLdouble x, GLdouble y) 2297{ 2298 save_RasterPos4f(x, y, 0.0F, 1.0F); 2299} 2300 2301static void save_RasterPos2f(GLfloat x, GLfloat y) 2302{ 2303 save_RasterPos4f(x, y, 0.0F, 1.0F); 2304} 2305 2306static void save_RasterPos2i(GLint x, GLint y) 2307{ 2308 save_RasterPos4f(x, y, 0.0F, 1.0F); 2309} 2310 2311static void save_RasterPos2s(GLshort x, GLshort y) 2312{ 2313 save_RasterPos4f(x, y, 0.0F, 1.0F); 2314} 2315 2316static void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) 2317{ 2318 save_RasterPos4f(x, y, z, 1.0F); 2319} 2320 2321static void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) 2322{ 2323 save_RasterPos4f(x, y, z, 1.0F); 2324} 2325 2326static void save_RasterPos3i(GLint x, GLint y, GLint z) 2327{ 2328 save_RasterPos4f(x, y, z, 1.0F); 2329} 2330 2331static void save_RasterPos3s(GLshort x, GLshort y, GLshort z) 2332{ 2333 save_RasterPos4f(x, y, z, 1.0F); 2334} 2335 2336static void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) 2337{ 2338 save_RasterPos4f(x, y, z, w); 2339} 2340 2341static void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) 2342{ 2343 save_RasterPos4f(x, y, z, w); 2344} 2345 2346static void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) 2347{ 2348 save_RasterPos4f(x, y, z, w); 2349} 2350 2351static void save_RasterPos2dv(const GLdouble *v) 2352{ 2353 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); 2354} 2355 2356static void save_RasterPos2fv(const GLfloat *v) 2357{ 2358 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); 2359} 2360 2361static void save_RasterPos2iv(const GLint *v) 2362{ 2363 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); 2364} 2365 2366static void save_RasterPos2sv(const GLshort *v) 2367{ 2368 save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); 2369} 2370 2371static void save_RasterPos3dv(const GLdouble *v) 2372{ 2373 save_RasterPos4f(v[0], v[1], v[2], 1.0F); 2374} 2375 2376static void save_RasterPos3fv(const GLfloat *v) 2377{ 2378 save_RasterPos4f(v[0], v[1], v[2], 1.0F); 2379} 2380 2381static void save_RasterPos3iv(const GLint *v) 2382{ 2383 save_RasterPos4f(v[0], v[1], v[2], 1.0F); 2384} 2385 2386static void save_RasterPos3sv(const GLshort *v) 2387{ 2388 save_RasterPos4f(v[0], v[1], v[2], 1.0F); 2389} 2390 2391static void save_RasterPos4dv(const GLdouble *v) 2392{ 2393 save_RasterPos4f(v[0], v[1], v[2], v[3]); 2394} 2395 2396static void save_RasterPos4fv(const GLfloat *v) 2397{ 2398 save_RasterPos4f(v[0], v[1], v[2], v[3]); 2399} 2400 2401static void save_RasterPos4iv(const GLint *v) 2402{ 2403 save_RasterPos4f(v[0], v[1], v[2], v[3]); 2404} 2405 2406static void save_RasterPos4sv(const GLshort *v) 2407{ 2408 save_RasterPos4f(v[0], v[1], v[2], v[3]); 2409} 2410 2411 2412static void save_PassThrough( GLfloat token ) 2413{ 2414 GET_CURRENT_CONTEXT(ctx); 2415 Node *n; 2416 FLUSH_VB(ctx, "dlist"); 2417 n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 ); 2418 if (n) { 2419 n[1].f = token; 2420 } 2421 if (ctx->ExecuteFlag) { 2422 (*ctx->Exec->PassThrough)( token ); 2423 } 2424} 2425 2426 2427static void save_ReadBuffer( GLenum mode ) 2428{ 2429 GET_CURRENT_CONTEXT(ctx); 2430 Node *n; 2431 FLUSH_VB(ctx, "dlist"); 2432 n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 ); 2433 if (n) { 2434 n[1].e = mode; 2435 } 2436 if (ctx->ExecuteFlag) { 2437 (*ctx->Exec->ReadBuffer)( mode ); 2438 } 2439} 2440 2441 2442static void save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) 2443{ 2444 GET_CURRENT_CONTEXT(ctx); 2445 Node *n; 2446 FLUSH_VB(ctx, "dlist"); 2447 n = alloc_instruction( ctx, OPCODE_RECTF, 4 ); 2448 if (n) { 2449 n[1].f = x1; 2450 n[2].f = y1; 2451 n[3].f = x2; 2452 n[4].f = y2; 2453 } 2454 if (ctx->ExecuteFlag) { 2455 (*ctx->Exec->Rectf)( x1, y1, x2, y2 ); 2456 } 2457} 2458 2459static void save_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) 2460{ 2461 save_Rectf(x1, y1, x2, y2); 2462} 2463 2464static void save_Rectdv(const GLdouble *v1, const GLdouble *v2) 2465{ 2466 save_Rectf(v1[0], v1[1], v2[0], v2[1]); 2467} 2468 2469static void save_Rectfv( const GLfloat *v1, const GLfloat *v2 ) 2470{ 2471 save_Rectf(v1[0], v1[1], v2[0], v2[1]); 2472} 2473 2474static void save_Recti(GLint x1, GLint y1, GLint x2, GLint y2) 2475{ 2476 save_Rectf(x1, y1, x2, y2); 2477} 2478 2479static void save_Rectiv(const GLint *v1, const GLint *v2) 2480{ 2481 save_Rectf(v1[0], v1[1], v2[0], v2[1]); 2482} 2483 2484static void save_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) 2485{ 2486 save_Rectf(x1, y1, x2, y2); 2487} 2488 2489static void save_Rectsv(const GLshort *v1, const GLshort *v2) 2490{ 2491 save_Rectf(v1[0], v1[1], v2[0], v2[1]); 2492} 2493 2494 2495static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) 2496{ 2497 GLfloat m[16]; 2498 gl_rotation_matrix( angle, x, y, z, m ); 2499 save_MultMatrixf( m ); /* save and maybe execute */ 2500} 2501 2502 2503static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) 2504{ 2505 save_Rotatef(angle, x, y, z); 2506} 2507 2508 2509static void save_Scalef( GLfloat x, GLfloat y, GLfloat z ) 2510{ 2511 GET_CURRENT_CONTEXT(ctx); 2512 Node *n; 2513 FLUSH_VB(ctx, "dlist"); 2514 n = alloc_instruction( ctx, OPCODE_SCALE, 3 ); 2515 if (n) { 2516 n[1].f = x; 2517 n[2].f = y; 2518 n[3].f = z; 2519 } 2520 if (ctx->ExecuteFlag) { 2521 (*ctx->Exec->Scalef)( x, y, z ); 2522 } 2523} 2524 2525 2526static void save_Scaled( GLdouble x, GLdouble y, GLdouble z ) 2527{ 2528 save_Scalef(x, y, z); 2529} 2530 2531 2532static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) 2533{ 2534 GET_CURRENT_CONTEXT(ctx); 2535 Node *n; 2536 FLUSH_VB(ctx, "dlist"); 2537 n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 ); 2538 if (n) { 2539 n[1].i = x; 2540 n[2].i = y; 2541 n[3].i = width; 2542 n[4].i = height; 2543 } 2544 if (ctx->ExecuteFlag) { 2545 (*ctx->Exec->Scissor)( x, y, width, height ); 2546 } 2547} 2548 2549 2550static void save_ShadeModel( GLenum mode ) 2551{ 2552 GET_CURRENT_CONTEXT(ctx); 2553 Node *n; 2554 FLUSH_VB(ctx, "dlist"); 2555 n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 ); 2556 if (n) { 2557 n[1].e = mode; 2558 } 2559 if (ctx->ExecuteFlag) { 2560 (*ctx->Exec->ShadeModel)( mode ); 2561 } 2562} 2563 2564 2565static void save_StencilFunc( GLenum func, GLint ref, GLuint mask ) 2566{ 2567 GET_CURRENT_CONTEXT(ctx); 2568 Node *n; 2569 FLUSH_VB(ctx, "dlist"); 2570 n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 ); 2571 if (n) { 2572 n[1].e = func; 2573 n[2].i = ref; 2574 n[3].ui = mask; 2575 } 2576 if (ctx->ExecuteFlag) { 2577 (*ctx->Exec->StencilFunc)( func, ref, mask ); 2578 } 2579} 2580 2581 2582static void save_StencilMask( GLuint mask ) 2583{ 2584 GET_CURRENT_CONTEXT(ctx); 2585 Node *n; 2586 FLUSH_VB(ctx, "dlist"); 2587 n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 ); 2588 if (n) { 2589 n[1].ui = mask; 2590 } 2591 if (ctx->ExecuteFlag) { 2592 (*ctx->Exec->StencilMask)( mask ); 2593 } 2594} 2595 2596 2597static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) 2598{ 2599 GET_CURRENT_CONTEXT(ctx); 2600 Node *n; 2601 FLUSH_VB(ctx, "dlist"); 2602 n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 ); 2603 if (n) { 2604 n[1].e = fail; 2605 n[2].e = zfail; 2606 n[3].e = zpass; 2607 } 2608 if (ctx->ExecuteFlag) { 2609 (*ctx->Exec->StencilOp)( fail, zfail, zpass ); 2610 } 2611} 2612 2613 2614static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params ) 2615{ 2616 GET_CURRENT_CONTEXT(ctx); 2617 Node *n; 2618 FLUSH_VB(ctx, "dlist"); 2619 n = alloc_instruction( ctx, OPCODE_TEXENV, 6 ); 2620 if (n) { 2621 n[1].e = target; 2622 n[2].e = pname; 2623 n[3].f = params[0]; 2624 n[4].f = params[1]; 2625 n[5].f = params[2]; 2626 n[6].f = params[3]; 2627 } 2628 if (ctx->ExecuteFlag) { 2629 (*ctx->Exec->TexEnvfv)( target, pname, params ); 2630 } 2631} 2632 2633 2634static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param ) 2635{ 2636 save_TexEnvfv( target, pname, ¶m ); 2637} 2638 2639 2640static void save_TexEnvi( GLenum target, GLenum pname, GLint param ) 2641{ 2642 GLfloat p[4]; 2643 p[0] = (GLfloat) param; 2644 p[1] = p[2] = p[3] = 0.0; 2645 save_TexEnvfv( target, pname, p ); 2646} 2647 2648 2649static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param ) 2650{ 2651 GLfloat p[4]; 2652 p[0] = INT_TO_FLOAT( param[0] ); 2653 p[1] = INT_TO_FLOAT( param[1] ); 2654 p[2] = INT_TO_FLOAT( param[2] ); 2655 p[3] = INT_TO_FLOAT( param[3] ); 2656 save_TexEnvfv( target, pname, p ); 2657} 2658 2659 2660static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) 2661{ 2662 GET_CURRENT_CONTEXT(ctx); 2663 Node *n; 2664 FLUSH_VB(ctx, "dlist"); 2665 n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 ); 2666 if (n) { 2667 n[1].e = coord; 2668 n[2].e = pname; 2669 n[3].f = params[0]; 2670 n[4].f = params[1]; 2671 n[5].f = params[2]; 2672 n[6].f = params[3]; 2673 } 2674 if (ctx->ExecuteFlag) { 2675 (*ctx->Exec->TexGenfv)( coord, pname, params ); 2676 } 2677} 2678 2679 2680static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) 2681{ 2682 GLfloat p[4]; 2683 p[0] = params[0]; 2684 p[1] = params[1]; 2685 p[2] = params[2]; 2686 p[3] = params[3]; 2687 save_TexGenfv(coord, pname, p); 2688} 2689 2690 2691static void save_TexGend(GLenum coord, GLenum pname, GLdouble param ) 2692{ 2693 GLfloat p = (GLfloat) param; 2694 save_TexGenfv( coord, pname, &p ); 2695} 2696 2697 2698static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) 2699{ 2700 GLfloat p[4]; 2701 p[0] = params[0]; 2702 p[1] = params[1]; 2703 p[2] = params[2]; 2704 p[3] = params[3]; 2705 save_TexGenfv( coord, pname, p ); 2706} 2707 2708 2709static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param ) 2710{ 2711 save_TexGenfv(coord, pname, ¶m); 2712} 2713 2714 2715static void save_TexGeni( GLenum coord, GLenum pname, GLint param ) 2716{ 2717 save_TexGeniv( coord, pname, ¶m ); 2718} 2719 2720 2721static void save_TexParameterfv( GLenum target, 2722 GLenum pname, const GLfloat *params ) 2723{ 2724 GET_CURRENT_CONTEXT(ctx); 2725 Node *n; 2726 FLUSH_VB(ctx, "dlist"); 2727 n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 ); 2728 if (n) { 2729 n[1].e = target; 2730 n[2].e = pname; 2731 n[3].f = params[0]; 2732 n[4].f = params[1]; 2733 n[5].f = params[2]; 2734 n[6].f = params[3]; 2735 } 2736 if (ctx->ExecuteFlag) { 2737 (*ctx->Exec->TexParameterfv)( target, pname, params ); 2738 } 2739} 2740 2741 2742static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param ) 2743{ 2744 save_TexParameterfv(target, pname, ¶m); 2745} 2746 2747 2748static void save_TexParameteri( GLenum target, GLenum pname, const GLint param ) 2749{ 2750 GLfloat fparam[4]; 2751 fparam[0] = (GLfloat) param; 2752 fparam[1] = fparam[2] = fparam[3] = 0.0; 2753 save_TexParameterfv(target, pname, fparam); 2754} 2755 2756 2757static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params ) 2758{ 2759 GLfloat fparam[4]; 2760 fparam[0] = (GLfloat) params[0]; 2761 fparam[1] = fparam[2] = fparam[3] = 0.0; 2762 save_TexParameterfv(target, pname, fparam); 2763} 2764 2765 2766static void save_TexImage1D( GLenum target, 2767 GLint level, GLint components, 2768 GLsizei width, GLint border, 2769 GLenum format, GLenum type, 2770 const GLvoid *pixels ) 2771{ 2772 GET_CURRENT_CONTEXT(ctx); 2773 if (target == GL_PROXY_TEXTURE_1D) { 2774 /* don't compile, execute immediately */ 2775 (*ctx->Exec->TexImage1D)( target, level, components, width, 2776 border, format, type, pixels ); 2777 } 2778 else { 2779 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, 2780 pixels, &ctx->Unpack); 2781 Node *n; 2782 FLUSH_VB(ctx, "dlist"); 2783 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 ); 2784 if (n) { 2785 n[1].e = target; 2786 n[2].i = level; 2787 n[3].i = components; 2788 n[4].i = (GLint) width; 2789 n[5].i = border; 2790 n[6].e = format; 2791 n[7].e = type; 2792 n[8].data = image; 2793 } 2794 else if (image) { 2795 FREE(image); 2796 } 2797 if (ctx->ExecuteFlag) { 2798 (*ctx->Exec->TexImage1D)( target, level, components, width, 2799 border, format, type, pixels ); 2800 } 2801 } 2802} 2803 2804 2805static void save_TexImage2D( GLenum target, 2806 GLint level, GLint components, 2807 GLsizei width, GLsizei height, GLint border, 2808 GLenum format, GLenum type, 2809 const GLvoid *pixels) 2810{ 2811 GET_CURRENT_CONTEXT(ctx); 2812 if (target == GL_PROXY_TEXTURE_2D) { 2813 /* don't compile, execute immediately */ 2814 (*ctx->Exec->TexImage2D)( target, level, components, width, 2815 height, border, format, type, pixels ); 2816 } 2817 else { 2818 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, 2819 pixels, &ctx->Unpack); 2820 Node *n; 2821 FLUSH_VB(ctx, "dlist"); 2822 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 ); 2823 if (n) { 2824 n[1].e = target; 2825 n[2].i = level; 2826 n[3].i = components; 2827 n[4].i = (GLint) width; 2828 n[5].i = (GLint) height; 2829 n[6].i = border; 2830 n[7].e = format; 2831 n[8].e = type; 2832 n[9].data = image; 2833 } 2834 else if (image) { 2835 FREE(image); 2836 } 2837 if (ctx->ExecuteFlag) { 2838 (*ctx->Exec->TexImage2D)( target, level, components, width, 2839 height, border, format, type, pixels ); 2840 } 2841 } 2842} 2843 2844 2845static void save_TexImage3D( GLenum target, 2846 GLint level, GLint components, 2847 GLsizei width, GLsizei height, GLsizei depth, 2848 GLint border, 2849 GLenum format, GLenum type, 2850 const GLvoid *pixels ) 2851{ 2852 GET_CURRENT_CONTEXT(ctx); 2853 if (target == GL_PROXY_TEXTURE_3D) { 2854 /* don't compile, execute immediately */ 2855 (*ctx->Exec->TexImage3D)( target, level, components, width, 2856 height, depth, border, format, type, pixels ); 2857 } 2858 else { 2859 Node *n; 2860 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type, 2861 pixels, &ctx->Unpack); 2862 FLUSH_VB(ctx, "dlist"); 2863 n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 ); 2864 if (n) { 2865 n[1].e = target; 2866 n[2].i = level; 2867 n[3].i = components; 2868 n[4].i = (GLint) width; 2869 n[5].i = (GLint) height; 2870 n[6].i = (GLint) depth; 2871 n[7].i = border; 2872 n[8].e = format; 2873 n[9].e = type; 2874 n[10].data = image; 2875 } 2876 else if (image) { 2877 FREE(image); 2878 } 2879 if (ctx->ExecuteFlag) { 2880 (*ctx->Exec->TexImage3D)( target, level, components, width, 2881 height, depth, border, format, type, pixels ); 2882 } 2883 } 2884} 2885 2886 2887static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset, 2888 GLsizei width, GLenum format, GLenum type, 2889 const GLvoid *pixels ) 2890{ 2891 GET_CURRENT_CONTEXT(ctx); 2892 Node *n; 2893 GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, 2894 pixels, &ctx->Unpack); 2895 FLUSH_VB(ctx, "dlist"); 2896 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 ); 2897 if (n) { 2898 n[1].e = target; 2899 n[2].i = level; 2900 n[3].i = xoffset; 2901 n[4].i = (GLint) width; 2902 n[5].e = format; 2903 n[6].e = type; 2904 n[7].data = image; 2905 } 2906 else if (image) { 2907 FREE(image); 2908 } 2909 if (ctx->ExecuteFlag) { 2910 (*ctx->Exec->TexSubImage1D)( target, level, xoffset, width, 2911 format, type, pixels ); 2912 } 2913} 2914 2915 2916static void save_TexSubImage2D( GLenum target, GLint level, 2917 GLint xoffset, GLint yoffset, 2918 GLsizei width, GLsizei height, 2919 GLenum format, GLenum type, 2920 const GLvoid *pixels ) 2921{ 2922 GET_CURRENT_CONTEXT(ctx); 2923 Node *n; 2924 GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, 2925 pixels, &ctx->Unpack); 2926 FLUSH_VB(ctx, "dlist"); 2927 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 ); 2928 if (n) { 2929 n[1].e = target; 2930 n[2].i = level; 2931 n[3].i = xoffset; 2932 n[4].i = yoffset; 2933 n[5].i = (GLint) width; 2934 n[6].i = (GLint) height; 2935 n[7].e = format; 2936 n[8].e = type; 2937 n[9].data = image; 2938 } 2939 else if (image) { 2940 FREE(image); 2941 } 2942 if (ctx->ExecuteFlag) { 2943 (*ctx->Exec->TexSubImage2D)( target, level, xoffset, yoffset, 2944 width, height, format, type, pixels ); 2945 } 2946} 2947 2948 2949static void save_TexSubImage3D( GLenum target, GLint level, 2950 GLint xoffset, GLint yoffset,GLint zoffset, 2951 GLsizei width, GLsizei height, GLsizei depth, 2952 GLenum format, GLenum type, 2953 const GLvoid *pixels ) 2954{ 2955 GET_CURRENT_CONTEXT(ctx); 2956 Node *n; 2957 GLvoid *image = _mesa_unpack_image(width, height, depth, format, type, 2958 pixels, &ctx->Unpack); 2959 FLUSH_VB(ctx, "dlist"); 2960 n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 ); 2961 if (n) { 2962 n[1].e = target; 2963 n[2].i = level; 2964 n[3].i = xoffset; 2965 n[4].i = yoffset; 2966 n[5].i = zoffset; 2967 n[6].i = (GLint) width; 2968 n[7].i = (GLint) height; 2969 n[8].i = (GLint) depth; 2970 n[9].e = format; 2971 n[10].e = type; 2972 n[11].data = image; 2973 } 2974 else if (image) { 2975 FREE(image); 2976 } 2977 if (ctx->ExecuteFlag) { 2978 (*ctx->Exec->TexSubImage3D)( target, level, 2979 xoffset, yoffset, zoffset, 2980 width, height, depth, format, type, pixels ); 2981 } 2982} 2983 2984 2985static void save_Translatef( GLfloat x, GLfloat y, GLfloat z ) 2986{ 2987 GET_CURRENT_CONTEXT(ctx); 2988 Node *n; 2989 FLUSH_VB(ctx, "dlist"); 2990 n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 ); 2991 if (n) { 2992 n[1].f = x; 2993 n[2].f = y; 2994 n[3].f = z; 2995 } 2996 if (ctx->ExecuteFlag) { 2997 (*ctx->Exec->Translatef)( x, y, z ); 2998 } 2999} 3000 3001 3002static void save_Translated( GLdouble x, GLdouble y, GLdouble z ) 3003{ 3004 save_Translatef(x, y, z); 3005} 3006 3007 3008 3009static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) 3010{ 3011 GET_CURRENT_CONTEXT(ctx); 3012 Node *n; 3013 FLUSH_VB(ctx, "dlist"); 3014 n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 ); 3015 if (n) { 3016 n[1].i = x; 3017 n[2].i = y; 3018 n[3].i = (GLint) width; 3019 n[4].i = (GLint) height; 3020 } 3021 if (ctx->ExecuteFlag) { 3022 (*ctx->Exec->Viewport)( x, y, width, height ); 3023 } 3024} 3025 3026 3027static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) 3028{ 3029 GET_CURRENT_CONTEXT(ctx); 3030 Node *n; 3031 FLUSH_VB(ctx, "dlist"); 3032 n = alloc_instruction( ctx, OPCODE_WINDOW_POS, 4 ); 3033 if (n) { 3034 n[1].f = x; 3035 n[2].f = y; 3036 n[3].f = z; 3037 n[4].f = w; 3038 } 3039 if (ctx->ExecuteFlag) { 3040 (*ctx->Exec->WindowPos4fMESA)( x, y, z, w ); 3041 } 3042} 3043 3044static void save_WindowPos2dMESA(GLdouble x, GLdouble y) 3045{ 3046 save_WindowPos4fMESA(x, y, 0.0F, 1.0F); 3047} 3048 3049static void save_WindowPos2fMESA(GLfloat x, GLfloat y) 3050{ 3051 save_WindowPos4fMESA(x, y, 0.0F, 1.0F); 3052} 3053 3054static void save_WindowPos2iMESA(GLint x, GLint y) 3055{ 3056 save_WindowPos4fMESA(x, y, 0.0F, 1.0F); 3057} 3058 3059static void save_WindowPos2sMESA(GLshort x, GLshort y) 3060{ 3061 save_WindowPos4fMESA(x, y, 0.0F, 1.0F); 3062} 3063 3064static void save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) 3065{ 3066 save_WindowPos4fMESA(x, y, z, 1.0F); 3067} 3068 3069static void save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) 3070{ 3071 save_WindowPos4fMESA(x, y, z, 1.0F); 3072} 3073 3074static void save_WindowPos3iMESA(GLint x, GLint y, GLint z) 3075{ 3076 save_WindowPos4fMESA(x, y, z, 1.0F); 3077} 3078 3079static void save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) 3080{ 3081 save_WindowPos4fMESA(x, y, z, 1.0F); 3082} 3083 3084static void save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) 3085{ 3086 save_WindowPos4fMESA(x, y, z, w); 3087} 3088 3089static void save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) 3090{ 3091 save_WindowPos4fMESA(x, y, z, w); 3092} 3093 3094static void save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) 3095{ 3096 save_WindowPos4fMESA(x, y, z, w); 3097} 3098 3099static void save_WindowPos2dvMESA(const GLdouble *v) 3100{ 3101 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); 3102} 3103 3104static void save_WindowPos2fvMESA(const GLfloat *v) 3105{ 3106 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); 3107} 3108 3109static void save_WindowPos2ivMESA(const GLint *v) 3110{ 3111 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); 3112} 3113 3114static void save_WindowPos2svMESA(const GLshort *v) 3115{ 3116 save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); 3117} 3118 3119static void save_WindowPos3dvMESA(const GLdouble *v) 3120{ 3121 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); 3122} 3123 3124static void save_WindowPos3fvMESA(const GLfloat *v) 3125{ 3126 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); 3127} 3128 3129static void save_WindowPos3ivMESA(const GLint *v) 3130{ 3131 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); 3132} 3133 3134static void save_WindowPos3svMESA(const GLshort *v) 3135{ 3136 save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); 3137} 3138 3139static void save_WindowPos4dvMESA(const GLdouble *v) 3140{ 3141 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); 3142} 3143 3144static void save_WindowPos4fvMESA(const GLfloat *v) 3145{ 3146 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); 3147} 3148 3149static void save_WindowPos4ivMESA(const GLint *v) 3150{ 3151 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); 3152} 3153 3154static void save_WindowPos4svMESA(const GLshort *v) 3155{ 3156 save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); 3157} 3158 3159 3160 3161/* GL_ARB_multitexture */ 3162static void save_ActiveTextureARB( GLenum target ) 3163{ 3164 GET_CURRENT_CONTEXT(ctx); 3165 Node *n; 3166 FLUSH_VB(ctx, "dlist"); 3167 n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 ); 3168 if (n) { 3169 n[1].e = target; 3170 } 3171 if (ctx->ExecuteFlag) { 3172 (*ctx->Exec->ActiveTextureARB)( target ); 3173 } 3174} 3175 3176 3177/* GL_ARB_multitexture */ 3178static void save_ClientActiveTextureARB( GLenum target ) 3179{ 3180 GET_CURRENT_CONTEXT(ctx); 3181 Node *n; 3182 FLUSH_VB(ctx, "dlist"); 3183 n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 ); 3184 if (n) { 3185 n[1].e = target; 3186 } 3187 if (ctx->ExecuteFlag) { 3188 (*ctx->Exec->ClientActiveTextureARB)( target ); 3189 } 3190} 3191 3192 3193 3194static void save_LoadTransposeMatrixdARB( const GLdouble m[16] ) 3195{ 3196 GLdouble tm[16]; 3197 gl_matrix_transposed(tm, m); 3198 save_LoadMatrixd(tm); 3199} 3200 3201 3202static void save_LoadTransposeMatrixfARB( const GLfloat m[16] ) 3203{ 3204 GLfloat tm[16]; 3205 gl_matrix_transposef(tm, m); 3206 save_LoadMatrixf(tm); 3207} 3208 3209 3210static void save_MultTransposeMatrixdARB( const GLdouble m[16] ) 3211{ 3212 GLdouble tm[16]; 3213 gl_matrix_transposed(tm, m); 3214 save_MultMatrixd(tm); 3215} 3216 3217 3218static void save_MultTransposeMatrixfARB( const GLfloat m[16] ) 3219{ 3220 GLfloat tm[16]; 3221 gl_matrix_transposef(tm, m); 3222 save_MultMatrixf(tm); 3223} 3224 3225 3226 3227void gl_compile_cassette( GLcontext *ctx ) 3228{ 3229 Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 8 ); 3230 struct immediate *im = ctx->input; 3231 3232 if (!n) 3233 return; 3234 3235 3236 /* Do some easy optimizations of the cassette. 3237 */ 3238#if 0 3239 if (0 && im->v.Obj.size < 4 && im->Count > 15) { 3240 im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat)); 3241 (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj ); 3242 } 3243#endif 3244 3245 n[1].data = (void *)im; 3246 n[2].ui = im->Start; 3247 n[3].ui = im->Count; 3248 n[4].ui = im->BeginState; 3249 n[5].ui = im->OrFlag; 3250 n[6].ui = im->AndFlag; 3251 n[7].ui = im->LastData; 3252 n[8].ui = im->LastPrimitive; 3253 3254 if (im->Count > VB_MAX - 4) { 3255 3256 struct immediate *new_im = gl_immediate_alloc(ctx); 3257 if (!new_im) return; 3258 SET_IMMEDIATE( ctx, new_im ); 3259 gl_reset_input( ctx ); 3260 3261 } else { 3262 im->Count++;; 3263 im->Start = im->Count; /* don't clear anything in reset_input */ 3264 im->ref_count++; 3265 3266 im->Primitive[im->Start] = ctx->Current.Primitive; 3267 im->LastPrimitive = im->Start; 3268 im->BeginState = VERT_BEGIN_0; 3269 im->OrFlag = 0; 3270 im->AndFlag = ~0; 3271 3272 if (0) 3273 fprintf(stderr, "in compile_cassette, BeginState is %x\n", 3274 im->BeginState); 3275 } 3276} 3277 3278/* KW: Compile commands 3279 * 3280 * Will appear in the list before the vertex buffer containing the 3281 * command that provoked the error. I don't see this as a problem. 3282 */ 3283void gl_save_error( GLcontext *ctx, GLenum error, const char *s ) 3284{ 3285 Node *n; 3286 n = alloc_instruction( ctx, OPCODE_ERROR, 2 ); 3287 if (n) { 3288 n[1].e = error; 3289 n[2].data = (void *) s; 3290 } 3291 /* execute already done */ 3292} 3293 3294 3295static GLboolean 3296islist(GLcontext *ctx, GLuint list) 3297{ 3298 if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) { 3299 return GL_TRUE; 3300 } 3301 else { 3302 return GL_FALSE; 3303 } 3304} 3305 3306 3307 3308/**********************************************************************/ 3309/* Display list execution */ 3310/**********************************************************************/ 3311 3312 3313/* 3314 * Execute a display list. Note that the ListBase offset must have already 3315 * been added before calling this function. I.e. the list argument is 3316 * the absolute list number, not relative to ListBase. 3317 * Input: list - display list number 3318 */ 3319static void execute_list( GLcontext *ctx, GLuint list ) 3320{ 3321 Node *n; 3322 GLboolean done; 3323 OpCode opcode; 3324 3325 if (!islist(ctx,list)) 3326 return; 3327 3328/* mesa_print_display_list( list ); */ 3329 3330 ctx->CallDepth++; 3331 3332 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list); 3333 3334 done = GL_FALSE; 3335 while (!done) { 3336 opcode = n[0].opcode; 3337 3338 switch (opcode) { 3339 case OPCODE_ERROR: 3340 gl_error( ctx, n[1].e, (const char *) n[2].data ); 3341 break; 3342 case OPCODE_VERTEX_CASSETTE: { 3343 struct immediate *IM; 3344 3345 if (ctx->NewState) 3346 gl_update_state(ctx); 3347 if (ctx->CompileCVAFlag) { 3348 ctx->CompileCVAFlag = 0; 3349 ctx->CVA.elt.pipeline_valid = 0; 3350 } 3351 if (!ctx->CVA.elt.pipeline_valid) 3352 gl_build_immediate_pipeline( ctx ); 3353 3354 3355 IM = (struct immediate *) n[1].data; 3356 IM->Start = n[2].ui; 3357 IM->Count = n[3].ui; 3358 IM->BeginState = n[4].ui; 3359 IM->OrFlag = n[5].ui; 3360 IM->AndFlag = n[6].ui; 3361 IM->LastData = n[7].ui; 3362 IM->LastPrimitive = n[8].ui; 3363 3364 if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) && 3365 (MESA_VERBOSE & VERBOSE_IMMEDIATE)) 3366 gl_print_cassette( (struct immediate *) n[1].data ); 3367 3368 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) { 3369 fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ", 3370 IM->id, 3371 IM->Start, IM->Count, IM->BeginState); 3372 gl_print_vert_flags("orflag", IM->OrFlag); 3373 } 3374 3375 gl_fixup_cassette( ctx, (struct immediate *) n[1].data ); 3376 gl_execute_cassette( ctx, (struct immediate *) n[1].data ); 3377 break; 3378 } 3379 case OPCODE_ACCUM: 3380 (*ctx->Exec->Accum)( n[1].e, n[2].f ); 3381 break; 3382 case OPCODE_ALPHA_FUNC: 3383 (*ctx->Exec->AlphaFunc)( n[1].e, n[2].f ); 3384 break; 3385 case OPCODE_BIND_TEXTURE: 3386 (*ctx->Exec->BindTexture)( n[1].e, n[2].ui ); 3387 break; 3388 case OPCODE_BITMAP: 3389 { 3390 struct gl_pixelstore_attrib save = ctx->Unpack; 3391 ctx->Unpack = _mesa_native_packing; 3392 (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i, 3393 n[3].f, n[4].f, n[5].f, n[6].f, n[7].data ); 3394 ctx->Unpack = save; /* restore */ 3395 } 3396 break; 3397 case OPCODE_BLEND_COLOR: 3398 (*ctx->Exec->BlendColor)( n[1].f, n[2].f, n[3].f, n[4].f ); 3399 break; 3400 case OPCODE_BLEND_EQUATION: 3401 (*ctx->Exec->BlendEquation)( n[1].e ); 3402 break; 3403 case OPCODE_BLEND_FUNC: 3404 (*ctx->Exec->BlendFunc)( n[1].e, n[2].e ); 3405 break; 3406 case OPCODE_BLEND_FUNC_SEPARATE: 3407 (*ctx->Exec->BlendFuncSeparateEXT)(n[1].e, n[2].e, n[3].e, n[4].e); 3408 break; 3409 case OPCODE_CALL_LIST: 3410 /* Generated by glCallList(), don't add ListBase */ 3411 if (ctx->CallDepth<MAX_LIST_NESTING) { 3412 execute_list( ctx, n[1].ui ); 3413 } 3414 break; 3415 case OPCODE_CALL_LIST_OFFSET: 3416 /* Generated by glCallLists() so we must add ListBase */ 3417 if (ctx->CallDepth<MAX_LIST_NESTING) { 3418 execute_list( ctx, ctx->List.ListBase + n[1].ui ); 3419 } 3420 break; 3421 case OPCODE_CLEAR: 3422 (*ctx->Exec->Clear)( n[1].bf ); 3423 break; 3424 case OPCODE_CLEAR_COLOR: 3425 (*ctx->Exec->ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f ); 3426 break; 3427 case OPCODE_CLEAR_ACCUM: 3428 (*ctx->Exec->ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f ); 3429 break; 3430 case OPCODE_CLEAR_DEPTH: 3431 (*ctx->Exec->ClearDepth)( (GLclampd) n[1].f ); 3432 break; 3433 case OPCODE_CLEAR_INDEX: 3434 (*ctx->Exec->ClearIndex)( n[1].ui ); 3435 break; 3436 case OPCODE_CLEAR_STENCIL: 3437 (*ctx->Exec->ClearStencil)( n[1].i ); 3438 break; 3439 case OPCODE_CLIP_PLANE: 3440 { 3441 GLdouble eq[4]; 3442 eq[0] = n[2].f; 3443 eq[1] = n[3].f; 3444 eq[2] = n[4].f; 3445 eq[3] = n[5].f; 3446 (*ctx->Exec->ClipPlane)( n[1].e, eq ); 3447 } 3448 break; 3449 case OPCODE_COLOR_MASK: 3450 (*ctx->Exec->ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b ); 3451 break; 3452 case OPCODE_COLOR_MATERIAL: 3453 (*ctx->Exec->ColorMaterial)( n[1].e, n[2].e ); 3454 break; 3455 case OPCODE_COLOR_TABLE: 3456 { 3457 struct gl_pixelstore_attrib save = ctx->Unpack; 3458 ctx->Unpack = _mesa_native_packing; 3459 (*ctx->Exec->ColorTable)( n[1].e, n[2].e, n[3].i, n[4].e, 3460 n[5].e, n[6].data ); 3461 ctx->Unpack = save; /* restore */ 3462 } 3463 break; 3464 case OPCODE_COLOR_SUB_TABLE: 3465 { 3466 struct gl_pixelstore_attrib save = ctx->Unpack; 3467 ctx->Unpack = _mesa_native_packing; 3468 (*ctx->Exec->ColorSubTable)( n[1].e, n[2].i, n[3].i, 3469 n[4].e, n[5].e, n[6].data ); 3470 ctx->Unpack = save; /* restore */ 3471 } 3472 break; 3473 case OPCODE_COPY_PIXELS: 3474 (*ctx->Exec->CopyPixels)( n[1].i, n[2].i, 3475 (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e ); 3476 break; 3477 case OPCODE_COPY_TEX_IMAGE1D: 3478 (*ctx->Exec->CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i, 3479 n[5].i, n[6].i, n[7].i ); 3480 break; 3481 case OPCODE_COPY_TEX_IMAGE2D: 3482 (*ctx->Exec->CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i, 3483 n[5].i, n[6].i, n[7].i, n[8].i ); 3484 break; 3485 case OPCODE_COPY_TEX_SUB_IMAGE1D: 3486 (*ctx->Exec->CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i, 3487 n[4].i, n[5].i, n[6].i ); 3488 break; 3489 case OPCODE_COPY_TEX_SUB_IMAGE2D: 3490 (*ctx->Exec->CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i, 3491 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i ); 3492 break; 3493 case OPCODE_COPY_TEX_SUB_IMAGE3D: 3494 (*ctx->Exec->CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i, 3495 n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i); 3496 break; 3497 case OPCODE_CULL_FACE: 3498 (*ctx->Exec->CullFace)( n[1].e ); 3499 break; 3500 case OPCODE_DEPTH_FUNC: 3501 (*ctx->Exec->DepthFunc)( n[1].e ); 3502 break; 3503 case OPCODE_DEPTH_MASK: 3504 (*ctx->Exec->DepthMask)( n[1].b ); 3505 break; 3506 case OPCODE_DEPTH_RANGE: 3507 (*ctx->Exec->DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f ); 3508 break; 3509 case OPCODE_DISABLE: 3510 (*ctx->Exec->Disable)( n[1].e ); 3511 break; 3512 case OPCODE_DRAW_BUFFER: 3513 (*ctx->Exec->DrawBuffer)( n[1].e ); 3514 break; 3515 case OPCODE_DRAW_PIXELS: 3516 { 3517 struct gl_pixelstore_attrib save = ctx->Unpack; 3518 ctx->Unpack = _mesa_native_packing; 3519 (*ctx->Exec->DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e, 3520 n[5].data ); 3521 ctx->Unpack = save; /* restore */ 3522 } 3523 break; 3524 case OPCODE_ENABLE: 3525 (*ctx->Exec->Enable)( n[1].e ); 3526 break; 3527 case OPCODE_EVALMESH1: 3528 (*ctx->Exec->EvalMesh1)( n[1].e, n[2].i, n[3].i ); 3529 break; 3530 case OPCODE_EVALMESH2: 3531 (*ctx->Exec->EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i ); 3532 break; 3533 case OPCODE_FOG: 3534 { 3535 GLfloat p[4]; 3536 p[0] = n[2].f; 3537 p[1] = n[3].f; 3538 p[2] = n[4].f; 3539 p[3] = n[5].f; 3540 (*ctx->Exec->Fogfv)( n[1].e, p ); 3541 } 3542 break; 3543 case OPCODE_FRONT_FACE: 3544 (*ctx->Exec->FrontFace)( n[1].e ); 3545 break; 3546 case OPCODE_FRUSTUM: 3547 (*ctx->Exec->Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); 3548 break; 3549 case OPCODE_HINT: 3550 (*ctx->Exec->Hint)( n[1].e, n[2].e ); 3551 break; 3552 case OPCODE_HINT_PGI: 3553 (*ctx->Exec->HintPGI)( n[1].e, n[2].i ); 3554 break; 3555 case OPCODE_INDEX_MASK: 3556 (*ctx->Exec->IndexMask)( n[1].ui ); 3557 break; 3558 case OPCODE_INIT_NAMES: 3559 (*ctx->Exec->InitNames)(); 3560 break; 3561 case OPCODE_LIGHT: 3562 { 3563 GLfloat p[4]; 3564 p[0] = n[3].f; 3565 p[1] = n[4].f; 3566 p[2] = n[5].f; 3567 p[3] = n[6].f; 3568 (*ctx->Exec->Lightfv)( n[1].e, n[2].e, p ); 3569 } 3570 break; 3571 case OPCODE_LIGHT_MODEL: 3572 { 3573 GLfloat p[4]; 3574 p[0] = n[2].f; 3575 p[1] = n[3].f; 3576 p[2] = n[4].f; 3577 p[3] = n[5].f; 3578 (*ctx->Exec->LightModelfv)( n[1].e, p ); 3579 } 3580 break; 3581 case OPCODE_LINE_STIPPLE: 3582 (*ctx->Exec->LineStipple)( n[1].i, n[2].us ); 3583 break; 3584 case OPCODE_LINE_WIDTH: 3585 (*ctx->Exec->LineWidth)( n[1].f ); 3586 break; 3587 case OPCODE_LIST_BASE: 3588 (*ctx->Exec->ListBase)( n[1].ui ); 3589 break; 3590 case OPCODE_LOAD_IDENTITY: 3591 (*ctx->Exec->LoadIdentity)(); 3592 break; 3593 case OPCODE_LOAD_MATRIX: 3594 if (sizeof(Node)==sizeof(GLfloat)) { 3595 (*ctx->Exec->LoadMatrixf)( &n[1].f ); 3596 } 3597 else { 3598 GLfloat m[16]; 3599 GLuint i; 3600 for (i=0;i<16;i++) { 3601 m[i] = n[1+i].f; 3602 } 3603 (*ctx->Exec->LoadMatrixf)( m ); 3604 } 3605 break; 3606 case OPCODE_LOAD_NAME: 3607 (*ctx->Exec->LoadName)( n[1].ui ); 3608 break; 3609 case OPCODE_LOGIC_OP: 3610 (*ctx->Exec->LogicOp)( n[1].e ); 3611 break; 3612 case OPCODE_MAP1: 3613 { 3614 GLenum target = n[1].e; 3615 GLint ustride = _mesa_evaluator_components(target); 3616 GLint uorder = n[5].i; 3617 GLfloat u1 = n[2].f; 3618 GLfloat u2 = n[3].f; 3619 (*ctx->Exec->Map1f)( target, u1, u2, ustride, uorder, 3620 (GLfloat *) n[6].data ); 3621 } 3622 break; 3623 case OPCODE_MAP2: 3624 { 3625 GLenum target = n[1].e; 3626 GLfloat u1 = n[2].f; 3627 GLfloat u2 = n[3].f; 3628 GLfloat v1 = n[4].f; 3629 GLfloat v2 = n[5].f; 3630 GLint ustride = n[6].i; 3631 GLint vstride = n[7].i; 3632 GLint uorder = n[8].i; 3633 GLint vorder = n[9].i; 3634 (*ctx->Exec->Map2f)( target, u1, u2, ustride, uorder, 3635 v1, v2, vstride, vorder, 3636 (GLfloat *) n[10].data ); 3637 } 3638 break; 3639 case OPCODE_MAPGRID1: 3640 (*ctx->Exec->MapGrid1f)( n[1].i, n[2].f, n[3].f ); 3641 break; 3642 case OPCODE_MAPGRID2: 3643 (*ctx->Exec->MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); 3644 break; 3645 case OPCODE_MATRIX_MODE: 3646 (*ctx->Exec->MatrixMode)( n[1].e ); 3647 break; 3648 case OPCODE_MULT_MATRIX: 3649 if (sizeof(Node)==sizeof(GLfloat)) { 3650 (*ctx->Exec->MultMatrixf)( &n[1].f ); 3651 } 3652 else { 3653 GLfloat m[16]; 3654 GLuint i; 3655 for (i=0;i<16;i++) { 3656 m[i] = n[1+i].f; 3657 } 3658 (*ctx->Exec->MultMatrixf)( m ); 3659 } 3660 break; 3661 case OPCODE_ORTHO: 3662 (*ctx->Exec->Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); 3663 break; 3664 case OPCODE_PASSTHROUGH: 3665 (*ctx->Exec->PassThrough)( n[1].f ); 3666 break; 3667 case OPCODE_PIXEL_MAP: 3668 (*ctx->Exec->PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data ); 3669 break; 3670 case OPCODE_PIXEL_TRANSFER: 3671 (*ctx->Exec->PixelTransferf)( n[1].e, n[2].f ); 3672 break; 3673 case OPCODE_PIXEL_ZOOM: 3674 (*ctx->Exec->PixelZoom)( n[1].f, n[2].f ); 3675 break; 3676 case OPCODE_POINT_SIZE: 3677 (*ctx->Exec->PointSize)( n[1].f ); 3678 break; 3679 case OPCODE_POINT_PARAMETERS: 3680 { 3681 GLfloat params[3]; 3682 params[0] = n[2].f; 3683 params[1] = n[3].f; 3684 params[2] = n[4].f; 3685 (*ctx->Exec->PointParameterfvEXT)( n[1].e, params ); 3686 } 3687 break; 3688 case OPCODE_POLYGON_MODE: 3689 (*ctx->Exec->PolygonMode)( n[1].e, n[2].e ); 3690 break; 3691 case OPCODE_POLYGON_STIPPLE: 3692 (*ctx->Exec->PolygonStipple)( (GLubyte *) n[1].data ); 3693 break; 3694 case OPCODE_POLYGON_OFFSET: 3695 (*ctx->Exec->PolygonOffset)( n[1].f, n[2].f ); 3696 break; 3697 case OPCODE_POP_ATTRIB: 3698 (*ctx->Exec->PopAttrib)(); 3699 break; 3700 case OPCODE_POP_MATRIX: 3701 (*ctx->Exec->PopMatrix)(); 3702 break; 3703 case OPCODE_POP_NAME: 3704 (*ctx->Exec->PopName)(); 3705 break; 3706 case OPCODE_PRIORITIZE_TEXTURE: 3707 (*ctx->Exec->PrioritizeTextures)( 1, &n[1].ui, &n[2].f ); 3708 break; 3709 case OPCODE_PUSH_ATTRIB: 3710 (*ctx->Exec->PushAttrib)( n[1].bf ); 3711 break; 3712 case OPCODE_PUSH_MATRIX: 3713 (*ctx->Exec->PushMatrix)(); 3714 break; 3715 case OPCODE_PUSH_NAME: 3716 (*ctx->Exec->PushName)( n[1].ui ); 3717 break; 3718 case OPCODE_RASTER_POS: 3719 (*ctx->Exec->RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f ); 3720 break; 3721 case OPCODE_READ_BUFFER: 3722 (*ctx->Exec->ReadBuffer)( n[1].e ); 3723 break; 3724 case OPCODE_RECTF: 3725 (*ctx->Exec->Rectf)( n[1].f, n[2].f, n[3].f, n[4].f ); 3726 break; 3727 case OPCODE_SCALE: 3728 (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f ); 3729 break; 3730 case OPCODE_SCISSOR: 3731 (*ctx->Exec->Scissor)( n[1].i, n[2].i, n[3].i, n[4].i ); 3732 break; 3733 case OPCODE_SHADE_MODEL: 3734 (*ctx->Exec->ShadeModel)( n[1].e ); 3735 break; 3736 case OPCODE_STENCIL_FUNC: 3737 (*ctx->Exec->StencilFunc)( n[1].e, n[2].i, n[3].ui ); 3738 break; 3739 case OPCODE_STENCIL_MASK: 3740 (*ctx->Exec->StencilMask)( n[1].ui ); 3741 break; 3742 case OPCODE_STENCIL_OP: 3743 (*ctx->Exec->StencilOp)( n[1].e, n[2].e, n[3].e ); 3744 break; 3745 case OPCODE_TEXENV: 3746 { 3747 GLfloat params[4]; 3748 params[0] = n[3].f; 3749 params[1] = n[4].f; 3750 params[2] = n[5].f; 3751 params[3] = n[6].f; 3752 (*ctx->Exec->TexEnvfv)( n[1].e, n[2].e, params ); 3753 } 3754 break; 3755 case OPCODE_TEXGEN: 3756 { 3757 GLfloat params[4]; 3758 params[0] = n[3].f; 3759 params[1] = n[4].f; 3760 params[2] = n[5].f; 3761 params[3] = n[6].f; 3762 (*ctx->Exec->TexGenfv)( n[1].e, n[2].e, params ); 3763 } 3764 break; 3765 case OPCODE_TEXPARAMETER: 3766 { 3767 GLfloat params[4]; 3768 params[0] = n[3].f; 3769 params[1] = n[4].f; 3770 params[2] = n[5].f; 3771 params[3] = n[6].f; 3772 (*ctx->Exec->TexParameterfv)( n[1].e, n[2].e, params ); 3773 } 3774 break; 3775 case OPCODE_TEX_IMAGE1D: 3776 { 3777 struct gl_pixelstore_attrib save = ctx->Unpack; 3778 ctx->Unpack = _mesa_native_packing; 3779 (*ctx->Exec->TexImage1D)( 3780 n[1].e, /* target */ 3781 n[2].i, /* level */ 3782 n[3].i, /* components */ 3783 n[4].i, /* width */ 3784 n[5].e, /* border */ 3785 n[6].e, /* format */ 3786 n[7].e, /* type */ 3787 n[8].data ); 3788 ctx->Unpack = save; /* restore */ 3789 } 3790 break; 3791 case OPCODE_TEX_IMAGE2D: 3792 { 3793 struct gl_pixelstore_attrib save = ctx->Unpack; 3794 ctx->Unpack = _mesa_native_packing; 3795 (*ctx->Exec->TexImage2D)( 3796 n[1].e, /* target */ 3797 n[2].i, /* level */ 3798 n[3].i, /* components */ 3799 n[4].i, /* width */ 3800 n[5].i, /* height */ 3801 n[6].e, /* border */ 3802 n[7].e, /* format */ 3803 n[8].e, /* type */ 3804 n[9].data ); 3805 ctx->Unpack = save; /* restore */ 3806 } 3807 break; 3808 case OPCODE_TEX_IMAGE3D: 3809 { 3810 struct gl_pixelstore_attrib save = ctx->Unpack; 3811 ctx->Unpack = _mesa_native_packing; 3812 (*ctx->Exec->TexImage3D)( 3813 n[1].e, /* target */ 3814 n[2].i, /* level */ 3815 n[3].i, /* components */ 3816 n[4].i, /* width */ 3817 n[5].i, /* height */ 3818 n[6].i, /* depth */ 3819 n[7].e, /* border */ 3820 n[8].e, /* format */ 3821 n[9].e, /* type */ 3822 n[10].data ); 3823 ctx->Unpack = save; /* restore */ 3824 } 3825 break; 3826 case OPCODE_TEX_SUB_IMAGE1D: 3827 { 3828 struct gl_pixelstore_attrib save = ctx->Unpack; 3829 ctx->Unpack = _mesa_native_packing; 3830 (*ctx->Exec->TexSubImage1D)( n[1].e, n[2].i, n[3].i, 3831 n[4].i, n[5].e, 3832 n[6].e, n[7].data ); 3833 ctx->Unpack = save; /* restore */ 3834 } 3835 break; 3836 case OPCODE_TEX_SUB_IMAGE2D: 3837 { 3838 struct gl_pixelstore_attrib save = ctx->Unpack; 3839 ctx->Unpack = _mesa_native_packing; 3840 (*ctx->Exec->TexSubImage2D)( n[1].e, n[2].i, n[3].i, 3841 n[4].i, n[5].e, 3842 n[6].i, n[7].e, n[8].e, n[9].data ); 3843 ctx->Unpack = save; /* restore */ 3844 } 3845 break; 3846 case OPCODE_TEX_SUB_IMAGE3D: 3847 { 3848 struct gl_pixelstore_attrib save = ctx->Unpack; 3849 ctx->Unpack = _mesa_native_packing; 3850 (*ctx->Exec->TexSubImage3D)( n[1].e, n[2].i, n[3].i, 3851 n[4].i, n[5].i, n[6].i, n[7].i, 3852 n[8].i, n[9].e, n[10].e, 3853 n[11].data ); 3854 ctx->Unpack = save; /* restore */ 3855 } 3856 break; 3857 case OPCODE_TRANSLATE: 3858 (*ctx->Exec->Translatef)( n[1].f, n[2].f, n[3].f ); 3859 break; 3860 case OPCODE_VIEWPORT: 3861 (*ctx->Exec->Viewport)(n[1].i, n[2].i, 3862 (GLsizei) n[3].i, (GLsizei) n[4].i); 3863 break; 3864 case OPCODE_WINDOW_POS: 3865 (*ctx->Exec->WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f ); 3866 break; 3867 case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ 3868 (*ctx->Exec->ActiveTextureARB)( n[1].e ); 3869 break; 3870 case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ 3871 (*ctx->Exec->ClientActiveTextureARB)( n[1].e ); 3872 break; 3873 case OPCODE_CONTINUE: 3874 n = (Node *) n[1].next; 3875 break; 3876 case OPCODE_END_OF_LIST: 3877 done = GL_TRUE; 3878 break; 3879 default: 3880 { 3881 char msg[1000]; 3882 sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode); 3883 gl_problem( ctx, msg ); 3884 } 3885 done = GL_TRUE; 3886 } 3887 3888 /* increment n to point to next compiled command */ 3889 if (opcode!=OPCODE_CONTINUE) { 3890 n += InstSize[opcode]; 3891 } 3892 3893 } 3894 ctx->CallDepth--; 3895} 3896 3897 3898 3899 3900 3901/**********************************************************************/ 3902/* GL functions */ 3903/**********************************************************************/ 3904 3905 3906 3907 3908/* 3909 * Test if a display list number is valid. 3910 */ 3911GLboolean 3912_mesa_IsList( GLuint list ) 3913{ 3914 GET_CURRENT_CONTEXT(ctx); 3915 return islist(ctx, list); 3916} 3917 3918 3919/* 3920 * Delete a sequence of consecutive display lists. 3921 */ 3922void 3923_mesa_DeleteLists( GLuint list, GLsizei range ) 3924{ 3925 GET_CURRENT_CONTEXT(ctx); 3926 GLuint i; 3927 3928 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists"); 3929 if (range<0) { 3930 gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" ); 3931 return; 3932 } 3933 for (i=list;i<list+range;i++) { 3934 gl_destroy_list( ctx, i ); 3935 } 3936} 3937 3938 3939 3940/* 3941 * Return a display list number, n, such that lists n through n+range-1 3942 * are free. 3943 */ 3944GLuint 3945_mesa_GenLists(GLsizei range ) 3946{ 3947 GET_CURRENT_CONTEXT(ctx); 3948 GLuint base; 3949 3950 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0); 3951 if (range<0) { 3952 gl_error( ctx, GL_INVALID_VALUE, "glGenLists" ); 3953 return 0; 3954 } 3955 if (range==0) { 3956 return 0; 3957 } 3958 3959 base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); 3960 if (base) { 3961 /* reserve the list IDs by with empty/dummy lists */ 3962 GLint i; 3963 for (i=0; i<range; i++) { 3964 _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list()); 3965 } 3966 } 3967 return base; 3968} 3969 3970 3971 3972/* 3973 * Begin a new display list. 3974 */ 3975void 3976_mesa_NewList( GLuint list, GLenum mode ) 3977{ 3978 GET_CURRENT_CONTEXT(ctx); 3979 struct immediate *IM; 3980 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList"); 3981 3982 if (MESA_VERBOSE&VERBOSE_API) 3983 fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode)); 3984 3985 if (list==0) { 3986 gl_error( ctx, GL_INVALID_VALUE, "glNewList" ); 3987 return; 3988 } 3989 3990 if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) { 3991 gl_error( ctx, GL_INVALID_ENUM, "glNewList" ); 3992 return; 3993 } 3994 3995 if (ctx->CurrentListPtr) { 3996 /* already compiling a display list */ 3997 gl_error( ctx, GL_INVALID_OPERATION, "glNewList" ); 3998 return; 3999 } 4000 4001 /* Allocate new display list */ 4002 ctx->CurrentListNum = list; 4003 ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE ); 4004 ctx->CurrentListPtr = ctx->CurrentBlock; 4005 ctx->CurrentPos = 0; 4006 4007 IM = gl_immediate_alloc( ctx ); 4008 SET_IMMEDIATE( ctx, IM ); 4009 gl_reset_input( ctx ); 4010 4011 ctx->CompileFlag = GL_TRUE; 4012 ctx->CompileCVAFlag = GL_FALSE; 4013 ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); 4014 4015 ctx->CurrentDispatch = ctx->Save; 4016 _glapi_set_dispatch( ctx->CurrentDispatch ); 4017} 4018 4019 4020 4021/* 4022 * End definition of current display list. 4023 */ 4024void 4025_mesa_EndList( void ) 4026{ 4027 GET_CURRENT_CONTEXT(ctx); 4028 if (MESA_VERBOSE&VERBOSE_API) 4029 fprintf(stderr, "glEndList\n"); 4030 4031 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" ); 4032 4033 /* Check that a list is under construction */ 4034 if (!ctx->CurrentListPtr) { 4035 gl_error( ctx, GL_INVALID_OPERATION, "glEndList" ); 4036 return; 4037 } 4038 4039 (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 ); 4040 4041 /* Destroy old list, if any */ 4042 gl_destroy_list(ctx, ctx->CurrentListNum); 4043 /* Install the list */ 4044 _mesa_HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr); 4045 4046 4047 if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) 4048 mesa_print_display_list(ctx->CurrentListNum); 4049 4050 ctx->CurrentListNum = 0; 4051 ctx->CurrentListPtr = NULL; 4052 ctx->ExecuteFlag = GL_TRUE; 4053 ctx->CompileFlag = GL_FALSE; 4054 /* ctx->CompileCVAFlag = ...; */ 4055 4056 /* KW: Put back the old input pointer. 4057 */ 4058 if (--ctx->input->ref_count == 0) 4059 gl_immediate_free( ctx->input ); 4060 4061 SET_IMMEDIATE( ctx, ctx->VB->IM ); 4062 gl_reset_input( ctx ); 4063 4064 /* Haven't tracked down why this is needed. 4065 */ 4066 ctx->NewState = ~0; 4067 4068 ctx->CurrentDispatch = ctx->Exec; 4069 _glapi_set_dispatch( ctx->CurrentDispatch ); 4070} 4071 4072 4073 4074void 4075_mesa_CallList( GLuint list ) 4076{ 4077 GET_CURRENT_CONTEXT(ctx); 4078 /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ 4079 /* execute the display list, and restore the CompileFlag. */ 4080 GLboolean save_compile_flag; 4081 4082 if (MESA_VERBOSE&VERBOSE_API) { 4083 fprintf(stderr, "glCallList %u\n", list); 4084 mesa_print_display_list( list ); 4085 } 4086 4087 save_compile_flag = ctx->CompileFlag; 4088 ctx->CompileFlag = GL_FALSE; 4089 4090 FLUSH_VB( ctx, "call list" ); 4091 execute_list( ctx, list ); 4092 ctx->CompileFlag = save_compile_flag; 4093 4094 /* also restore API function pointers to point to "save" versions */ 4095 if (save_compile_flag) { 4096 ctx->CurrentDispatch = ctx->Save; 4097 _glapi_set_dispatch( ctx->CurrentDispatch ); 4098 } 4099} 4100 4101 4102 4103/* 4104 * Execute glCallLists: call multiple display lists. 4105 */ 4106void 4107_mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) 4108{ 4109 GET_CURRENT_CONTEXT(ctx); 4110 GLuint list; 4111 GLint i; 4112 GLboolean save_compile_flag; 4113 4114 /* Save the CompileFlag status, turn it off, execute display list, 4115 * and restore the CompileFlag. 4116 */ 4117 save_compile_flag = ctx->CompileFlag; 4118 ctx->CompileFlag = GL_FALSE; 4119 4120 FLUSH_VB( ctx, "call lists" ); 4121 4122 for (i=0;i<n;i++) { 4123 list = translate_id( i, type, lists ); 4124 execute_list( ctx, ctx->List.ListBase + list ); 4125 } 4126 4127 ctx->CompileFlag = save_compile_flag; 4128 4129 /* also restore API function pointers to point to "save" versions */ 4130 if (save_compile_flag) { 4131 ctx->CurrentDispatch = ctx->Save; 4132 _glapi_set_dispatch( ctx->CurrentDispatch ); 4133 } 4134 4135/* RESET_IMMEDIATE( ctx ); */ 4136} 4137 4138 4139 4140/* 4141 * Set the offset added to list numbers in glCallLists. 4142 */ 4143void 4144_mesa_ListBase( GLuint base ) 4145{ 4146 GET_CURRENT_CONTEXT(ctx); 4147 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase"); 4148 ctx->List.ListBase = base; 4149} 4150 4151 4152 4153 4154/* 4155 * Assign all the pointers in 'table' to point to Mesa's display list 4156 * building functions. 4157 */ 4158void 4159_mesa_init_dlist_table( struct _glapi_table *table ) 4160{ 4161 _mesa_init_no_op_table(table); 4162 4163 /* GL 1.0 */ 4164 table->Accum = save_Accum; 4165 table->AlphaFunc = save_AlphaFunc; 4166 table->Begin = save_Begin; 4167 table->Bitmap = save_Bitmap; 4168 table->BlendFunc = save_BlendFunc; 4169 table->CallList = save_CallList; 4170 table->CallLists = save_CallLists; 4171 table->Clear = save_Clear; 4172 table->ClearAccum = save_ClearAccum; 4173 table->ClearColor = save_ClearColor; 4174 table->ClearDepth = save_ClearDepth; 4175 table->ClearIndex = save_ClearIndex; 4176 table->ClearStencil = save_ClearStencil; 4177 table->ClipPlane = save_ClipPlane; 4178 table->Color3b = _mesa_Color3b; 4179 table->Color3bv = _mesa_Color3bv; 4180 table->Color3d = _mesa_Color3d; 4181 table->Color3dv = _mesa_Color3dv; 4182 table->Color3f = _mesa_Color3f; 4183 table->Color3fv = _mesa_Color3fv; 4184 table->Color3i = _mesa_Color3i; 4185 table->Color3iv = _mesa_Color3iv; 4186 table->Color3s = _mesa_Color3s; 4187 table->Color3sv = _mesa_Color3sv; 4188 table->Color3ub = _mesa_Color3ub; 4189 table->Color3ubv = _mesa_Color3ubv; 4190 table->Color3ui = _mesa_Color3ui; 4191 table->Color3uiv = _mesa_Color3uiv; 4192 table->Color3us = _mesa_Color3us; 4193 table->Color3usv = _mesa_Color3usv; 4194 table->Color4b = _mesa_Color4b; 4195 table->Color4bv = _mesa_Color4bv; 4196 table->Color4d = _mesa_Color4d; 4197 table->Color4dv = _mesa_Color4dv; 4198 table->Color4f = _mesa_Color4f; 4199 table->Color4fv = _mesa_Color4fv; 4200 table->Color4i = _mesa_Color4i; 4201 table->Color4iv = _mesa_Color4iv; 4202 table->Color4s = _mesa_Color4s; 4203 table->Color4sv = _mesa_Color4sv; 4204 table->Color4ub = _mesa_Color4ub; 4205 table->Color4ubv = _mesa_Color4ubv; 4206 table->Color4ui = _mesa_Color4ui; 4207 table->Color4uiv = _mesa_Color4uiv; 4208 table->Color4us = _mesa_Color4us; 4209 table->Color4usv = _mesa_Color4usv; 4210 table->ColorMask = save_ColorMask; 4211 table->ColorMaterial = save_ColorMaterial; 4212 table->CopyPixels = save_CopyPixels; 4213 table->CullFace = save_CullFace; 4214 table->DeleteLists = _mesa_DeleteLists; 4215 table->DepthFunc = save_DepthFunc; 4216 table->DepthMask = save_DepthMask; 4217 table->DepthRange = save_DepthRange; 4218 table->Disable = save_Disable; 4219 table->DrawBuffer = save_DrawBuffer; 4220 table->DrawPixels = save_DrawPixels; 4221 table->EdgeFlag = _mesa_EdgeFlag; 4222 table->EdgeFlagv = _mesa_EdgeFlagv; 4223 table->Enable = save_Enable; 4224 table->End = _mesa_End; 4225 table->EndList = _mesa_EndList; 4226 table->EvalCoord1d = _mesa_EvalCoord1d; 4227 table->EvalCoord1dv = _mesa_EvalCoord1dv; 4228 table->EvalCoord1f = _mesa_EvalCoord1f; 4229 table->EvalCoord1fv = _mesa_EvalCoord1fv; 4230 table->EvalCoord2d = _mesa_EvalCoord2d; 4231 table->EvalCoord2dv = _mesa_EvalCoord2dv; 4232 table->EvalCoord2f = _mesa_EvalCoord2f; 4233 table->EvalCoord2fv = _mesa_EvalCoord2fv; 4234 table->EvalMesh1 = save_EvalMesh1; 4235 table->EvalMesh2 = save_EvalMesh2; 4236 table->EvalPoint1 = _mesa_EvalPoint1; 4237 table->EvalPoint2 = _mesa_EvalPoint2; 4238 table->FeedbackBuffer = _mesa_FeedbackBuffer; 4239 table->Finish = _mesa_Finish; 4240 table->Flush = _mesa_Flush; 4241 table->Fogf = save_Fogf; 4242 table->Fogfv = save_Fogfv; 4243 table->Fogi = save_Fogi; 4244 table->Fogiv = save_Fogiv; 4245 table->FrontFace = save_FrontFace; 4246 table->Frustum = save_Frustum; 4247 table->GenLists = _mesa_GenLists; 4248 table->GetBooleanv = _mesa_GetBooleanv; 4249 table->GetClipPlane = _mesa_GetClipPlane; 4250 table->GetDoublev = _mesa_GetDoublev; 4251 table->GetError = _mesa_GetError; 4252 table->GetFloatv = _mesa_GetFloatv; 4253 table->GetIntegerv = _mesa_GetIntegerv; 4254 table->GetLightfv = _mesa_GetLightfv; 4255 table->GetLightiv = _mesa_GetLightiv; 4256 table->GetMapdv = _mesa_GetMapdv; 4257 table->GetMapfv = _mesa_GetMapfv; 4258 table->GetMapiv = _mesa_GetMapiv; 4259 table->GetMaterialfv = _mesa_GetMaterialfv; 4260 table->GetMaterialiv = _mesa_GetMaterialiv; 4261 table->GetPixelMapfv = _mesa_GetPixelMapfv; 4262 table->GetPixelMapuiv = _mesa_GetPixelMapuiv; 4263 table->GetPixelMapusv = _mesa_GetPixelMapusv; 4264 table->GetPolygonStipple = _mesa_GetPolygonStipple; 4265 table->GetString = _mesa_GetString; 4266 table->GetTexEnvfv = _mesa_GetTexEnvfv; 4267 table->GetTexEnviv = _mesa_GetTexEnviv; 4268 table->GetTexGendv = _mesa_GetTexGendv; 4269 table->GetTexGenfv = _mesa_GetTexGenfv; 4270 table->GetTexGeniv = _mesa_GetTexGeniv; 4271 table->GetTexImage = _mesa_GetTexImage; 4272 table->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv; 4273 table->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv; 4274 table->GetTexParameterfv = _mesa_GetTexParameterfv; 4275 table->GetTexParameteriv = _mesa_GetTexParameteriv; 4276 table->Hint = save_Hint; 4277 table->IndexMask = save_IndexMask; 4278 table->Indexd = _mesa_Indexd; 4279 table->Indexdv = _mesa_Indexdv; 4280 table->Indexf = _mesa_Indexf; 4281 table->Indexfv = _mesa_Indexfv; 4282 table->Indexi = _mesa_Indexi; 4283 table->Indexiv = _mesa_Indexiv; 4284 table->Indexs = _mesa_Indexs; 4285 table->Indexsv = _mesa_Indexsv; 4286 table->InitNames = save_InitNames; 4287 table->IsEnabled = _mesa_IsEnabled; 4288 table->IsList = _mesa_IsList; 4289 table->LightModelf = save_LightModelf; 4290 table->LightModelfv = save_LightModelfv; 4291 table->LightModeli = save_LightModeli; 4292 table->LightModeliv = save_LightModeliv; 4293 table->Lightf = save_Lightf; 4294 table->Lightfv = save_Lightfv; 4295 table->Lighti = save_Lighti; 4296 table->Lightiv = save_Lightiv; 4297 table->LineStipple = save_LineStipple; 4298 table->LineWidth = save_LineWidth; 4299 table->ListBase = save_ListBase; 4300 table->LoadIdentity = save_LoadIdentity; 4301 table->LoadMatrixd = save_LoadMatrixd; 4302 table->LoadMatrixf = save_LoadMatrixf; 4303 table->LoadName = save_LoadName; 4304 table->LogicOp = save_LogicOp; 4305 table->Map1d = save_Map1d; 4306 table->Map1f = save_Map1f; 4307 table->Map2d = save_Map2d; 4308 table->Map2f = save_Map2f; 4309 table->MapGrid1d = save_MapGrid1d; 4310 table->MapGrid1f = save_MapGrid1f; 4311 table->MapGrid2d = save_MapGrid2d; 4312 table->MapGrid2f = save_MapGrid2f; 4313 table->Materialf = _mesa_Materialf; 4314 table->Materialfv = _mesa_Materialfv; 4315 table->Materiali = _mesa_Materiali; 4316 table->Materialiv = _mesa_Materialiv; 4317 table->MatrixMode = save_MatrixMode; 4318 table->MultMatrixd = save_MultMatrixd; 4319 table->MultMatrixf = save_MultMatrixf; 4320 table->NewList = save_NewList; 4321 table->Normal3b = _mesa_Normal3b; 4322 table->Normal3bv = _mesa_Normal3bv; 4323 table->Normal3d = _mesa_Normal3d; 4324 table->Normal3dv = _mesa_Normal3dv; 4325 table->Normal3f = _mesa_Normal3f; 4326 table->Normal3fv = _mesa_Normal3fv; 4327 table->Normal3i = _mesa_Normal3i; 4328 table->Normal3iv = _mesa_Normal3iv; 4329 table->Normal3s = _mesa_Normal3s; 4330 table->Normal3sv = _mesa_Normal3sv; 4331 table->Ortho = save_Ortho; 4332 table->PassThrough = save_PassThrough; 4333 table->PixelMapfv = save_PixelMapfv; 4334 table->PixelMapuiv = save_PixelMapuiv; 4335 table->PixelMapusv = save_PixelMapusv; 4336 table->PixelStoref = _mesa_PixelStoref; 4337 table->PixelStorei = _mesa_PixelStorei; 4338 table->PixelTransferf = save_PixelTransferf; 4339 table->PixelTransferi = save_PixelTransferi; 4340 table->PixelZoom = save_PixelZoom; 4341 table->PointSize = save_PointSize; 4342 table->PolygonMode = save_PolygonMode; 4343 table->PolygonOffset = save_PolygonOffset; 4344 table->PolygonStipple = save_PolygonStipple; 4345 table->PopAttrib = save_PopAttrib; 4346 table->PopMatrix = save_PopMatrix; 4347 table->PopName = save_PopName; 4348 table->PushAttrib = save_PushAttrib; 4349 table->PushMatrix = save_PushMatrix; 4350 table->PushName = save_PushName; 4351 table->RasterPos2d = save_RasterPos2d; 4352 table->RasterPos2dv = save_RasterPos2dv; 4353 table->RasterPos2f = save_RasterPos2f; 4354 table->RasterPos2fv = save_RasterPos2fv; 4355 table->RasterPos2i = save_RasterPos2i; 4356 table->RasterPos2iv = save_RasterPos2iv; 4357 table->RasterPos2s = save_RasterPos2s; 4358 table->RasterPos2sv = save_RasterPos2sv; 4359 table->RasterPos3d = save_RasterPos3d; 4360 table->RasterPos3dv = save_RasterPos3dv; 4361 table->RasterPos3f = save_RasterPos3f; 4362 table->RasterPos3fv = save_RasterPos3fv; 4363 table->RasterPos3i = save_RasterPos3i; 4364 table->RasterPos3iv = save_RasterPos3iv; 4365 table->RasterPos3s = save_RasterPos3s; 4366 table->RasterPos3sv = save_RasterPos3sv; 4367 table->RasterPos4d = save_RasterPos4d; 4368 table->RasterPos4dv = save_RasterPos4dv; 4369 table->RasterPos4f = save_RasterPos4f; 4370 table->RasterPos4fv = save_RasterPos4fv; 4371 table->RasterPos4i = save_RasterPos4i; 4372 table->RasterPos4iv = save_RasterPos4iv; 4373 table->RasterPos4s = save_RasterPos4s; 4374 table->RasterPos4sv = save_RasterPos4sv; 4375 table->ReadBuffer = save_ReadBuffer; 4376 table->ReadPixels = _mesa_ReadPixels; 4377 table->Rectd = save_Rectd; 4378 table->Rectdv = save_Rectdv; 4379 table->Rectf = save_Rectf; 4380 table->Rectfv = save_Rectfv; 4381 table->Recti = save_Recti; 4382 table->Rectiv = save_Rectiv; 4383 table->Rects = save_Rects; 4384 table->Rectsv = save_Rectsv; 4385 table->RenderMode = _mesa_RenderMode; 4386 table->Rotated = save_Rotated; 4387 table->Rotatef = save_Rotatef; 4388 table->Scaled = save_Scaled; 4389 table->Scalef = save_Scalef; 4390 table->Scissor = save_Scissor; 4391 table->SelectBuffer = _mesa_SelectBuffer; 4392 table->ShadeModel = save_ShadeModel; 4393 table->StencilFunc = save_StencilFunc; 4394 table->StencilMask = save_StencilMask; 4395 table->StencilOp = save_StencilOp; 4396 table->TexCoord1d = _mesa_TexCoord1d; 4397 table->TexCoord1dv = _mesa_TexCoord1dv; 4398 table->TexCoord1f = _mesa_TexCoord1f; 4399 table->TexCoord1fv = _mesa_TexCoord1fv; 4400 table->TexCoord1i = _mesa_TexCoord1i; 4401 table->TexCoord1iv = _mesa_TexCoord1iv; 4402 table->TexCoord1s = _mesa_TexCoord1s; 4403 table->TexCoord1sv = _mesa_TexCoord1sv; 4404 table->TexCoord2d = _mesa_TexCoord2d; 4405 table->TexCoord2dv = _mesa_TexCoord2dv; 4406 table->TexCoord2f = _mesa_TexCoord2f; 4407 table->TexCoord2fv = _mesa_TexCoord2fv; 4408 table->TexCoord2i = _mesa_TexCoord2i; 4409 table->TexCoord2iv = _mesa_TexCoord2iv; 4410 table->TexCoord2s = _mesa_TexCoord2s; 4411 table->TexCoord2sv = _mesa_TexCoord2sv; 4412 table->TexCoord3d = _mesa_TexCoord3d; 4413 table->TexCoord3dv = _mesa_TexCoord3dv; 4414 table->TexCoord3f = _mesa_TexCoord3f; 4415 table->TexCoord3fv = _mesa_TexCoord3fv; 4416 table->TexCoord3i = _mesa_TexCoord3i; 4417 table->TexCoord3iv = _mesa_TexCoord3iv; 4418 table->TexCoord3s = _mesa_TexCoord3s; 4419 table->TexCoord3sv = _mesa_TexCoord3sv; 4420 table->TexCoord4d = _mesa_TexCoord4d; 4421 table->TexCoord4dv = _mesa_TexCoord4dv; 4422 table->TexCoord4f = _mesa_TexCoord4f; 4423 table->TexCoord4fv = _mesa_TexCoord4fv; 4424 table->TexCoord4i = _mesa_TexCoord4i; 4425 table->TexCoord4iv = _mesa_TexCoord4iv; 4426 table->TexCoord4s = _mesa_TexCoord4s; 4427 table->TexCoord4sv = _mesa_TexCoord4sv; 4428 table->TexEnvf = save_TexEnvf; 4429 table->TexEnvfv = save_TexEnvfv; 4430 table->TexEnvi = save_TexEnvi; 4431 table->TexEnviv = save_TexEnviv; 4432 table->TexGend = save_TexGend; 4433 table->TexGendv = save_TexGendv; 4434 table->TexGenf = save_TexGenf; 4435 table->TexGenfv = save_TexGenfv; 4436 table->TexGeni = save_TexGeni; 4437 table->TexGeniv = save_TexGeniv; 4438 table->TexImage1D = save_TexImage1D; 4439 table->TexImage2D = save_TexImage2D; 4440 table->TexParameterf = save_TexParameterf; 4441 table->TexParameterfv = save_TexParameterfv; 4442 table->TexParameteri = save_TexParameteri; 4443 table->TexParameteriv = save_TexParameteriv; 4444 table->Translated = save_Translated; 4445 table->Translatef = save_Translatef; 4446 table->Vertex2d = _mesa_Vertex2d; 4447 table->Vertex2dv = _mesa_Vertex2dv; 4448 table->Vertex2f = _mesa_Vertex2f; 4449 table->Vertex2fv = _mesa_Vertex2fv; 4450 table->Vertex2i = _mesa_Vertex2i; 4451 table->Vertex2iv = _mesa_Vertex2iv; 4452 table->Vertex2s = _mesa_Vertex2s; 4453 table->Vertex2sv = _mesa_Vertex2sv; 4454 table->Vertex3d = _mesa_Vertex3d; 4455 table->Vertex3dv = _mesa_Vertex3dv; 4456 table->Vertex3f = _mesa_Vertex3f; 4457 table->Vertex3fv = _mesa_Vertex3fv; 4458 table->Vertex3i = _mesa_Vertex3i; 4459 table->Vertex3iv = _mesa_Vertex3iv; 4460 table->Vertex3s = _mesa_Vertex3s; 4461 table->Vertex3sv = _mesa_Vertex3sv; 4462 table->Vertex4d = _mesa_Vertex4d; 4463 table->Vertex4dv = _mesa_Vertex4dv; 4464 table->Vertex4f = _mesa_Vertex4f; 4465 table->Vertex4fv = _mesa_Vertex4fv; 4466 table->Vertex4i = _mesa_Vertex4i; 4467 table->Vertex4iv = _mesa_Vertex4iv; 4468 table->Vertex4s = _mesa_Vertex4s; 4469 table->Vertex4sv = _mesa_Vertex4sv; 4470 table->Viewport = save_Viewport; 4471 4472 /* GL 1.1 */ 4473 table->AreTexturesResident = _mesa_AreTexturesResident; 4474 table->ArrayElement = _mesa_ArrayElement; 4475 table->BindTexture = save_BindTexture; 4476 table->ColorPointer = _mesa_ColorPointer; 4477 table->CopyTexImage1D = save_CopyTexImage1D; 4478 table->CopyTexImage2D = save_CopyTexImage2D; 4479 table->CopyTexSubImage1D = save_CopyTexSubImage1D; 4480 table->CopyTexSubImage2D = save_CopyTexSubImage2D; 4481 table->DeleteTextures = _mesa_DeleteTextures; 4482 table->DisableClientState = _mesa_DisableClientState; 4483 table->DrawArrays = _mesa_DrawArrays; 4484 table->DrawElements = _mesa_DrawElements; 4485 table->EdgeFlagPointer = _mesa_EdgeFlagPointer; 4486 table->EnableClientState = _mesa_EnableClientState; 4487 table->GenTextures = _mesa_GenTextures; 4488 table->GetPointerv = _mesa_GetPointerv; 4489 table->IndexPointer = _mesa_IndexPointer; 4490 table->Indexub = _mesa_Indexub; 4491 table->Indexubv = _mesa_Indexubv; 4492 table->InterleavedArrays = _mesa_InterleavedArrays; 4493 table->IsTexture = _mesa_IsTexture; 4494 table->NormalPointer = _mesa_NormalPointer; 4495 table->PopClientAttrib = _mesa_PopClientAttrib; 4496 table->PrioritizeTextures = save_PrioritizeTextures; 4497 table->PushClientAttrib = _mesa_PushClientAttrib; 4498 table->TexCoordPointer = _mesa_TexCoordPointer; 4499 table->TexSubImage1D = save_TexSubImage1D; 4500 table->TexSubImage2D = save_TexSubImage2D; 4501 table->VertexPointer = _mesa_VertexPointer; 4502 4503 /* GL 1.2 */ 4504 table->CopyTexSubImage3D = save_CopyTexSubImage3D; 4505 table->DrawRangeElements = _mesa_DrawRangeElements; 4506 table->TexImage3D = save_TexImage3D; 4507 table->TexSubImage3D = save_TexSubImage3D; 4508 4509 /* GL_ARB_imaging */ 4510 /* Not all are supported */ 4511 table->BlendColor = save_BlendColor; 4512 table->BlendEquation = save_BlendEquation; 4513 table->ColorSubTable = save_ColorSubTable; 4514 table->ColorTable = save_ColorTable; 4515 table->ColorTableParameterfv = _mesa_ColorTableParameterfv; 4516 table->ColorTableParameteriv = _mesa_ColorTableParameteriv; 4517 table->ConvolutionFilter1D = _mesa_ConvolutionFilter1D; 4518 table->ConvolutionFilter2D = _mesa_ConvolutionFilter2D; 4519 table->ConvolutionParameterf = _mesa_ConvolutionParameterf; 4520 table->ConvolutionParameterfv = _mesa_ConvolutionParameterfv; 4521 table->ConvolutionParameteri = _mesa_ConvolutionParameteri; 4522 table->ConvolutionParameteriv = _mesa_ConvolutionParameteriv; 4523 table->CopyColorSubTable = _mesa_CopyColorSubTable; 4524 table->CopyColorTable = _mesa_CopyColorTable; 4525 table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D; 4526 table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D; 4527 table->GetColorTable = _mesa_GetColorTable; 4528 table->GetColorTableParameterfv = _mesa_GetColorTableParameterfv; 4529 table->GetColorTableParameteriv = _mesa_GetColorTableParameteriv; 4530 table->GetConvolutionFilter = _mesa_GetConvolutionFilter; 4531 table->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv; 4532 table->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv; 4533 table->GetHistogram = _mesa_GetHistogram; 4534 table->GetHistogramParameterfv = _mesa_GetHistogramParameterfv; 4535 table->GetHistogramParameteriv = _mesa_GetHistogramParameteriv; 4536 table->GetMinmax = _mesa_GetMinmax; 4537 table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv; 4538 table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv; 4539 table->GetSeparableFilter = _mesa_GetSeparableFilter; 4540 table->Histogram = _mesa_Histogram; 4541 table->Minmax = _mesa_Minmax; 4542 table->ResetHistogram = _mesa_ResetHistogram; 4543 table->ResetMinmax = _mesa_ResetMinmax; 4544 table->SeparableFilter2D = _mesa_SeparableFilter2D; 4545 4546 /* GL_EXT_texture3d */ 4547#if 0 4548 table->CopyTexSubImage3DEXT = save_CopyTexSubImage3D; 4549 table->TexImage3DEXT = save_TexImage3DEXT; 4550 table->TexSubImage3DEXT = save_TexSubImage3D; 4551#endif 4552 4553 /* GL_EXT_paletted_texture */ 4554#if 0 4555 table->ColorTableEXT = save_ColorTable; 4556 table->ColorSubTableEXT = save_ColorSubTable; 4557#endif 4558 table->GetColorTableEXT = _mesa_GetColorTable; 4559 table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; 4560 table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; 4561 4562 /* GL_EXT_compiled_vertex_array */ 4563 table->LockArraysEXT = _mesa_LockArraysEXT; 4564 table->UnlockArraysEXT = _mesa_UnlockArraysEXT; 4565 4566 /* GL_EXT_point_parameters */ 4567 table->PointParameterfEXT = save_PointParameterfEXT; 4568 table->PointParameterfvEXT = save_PointParameterfvEXT; 4569 4570 /* GL_PGI_misc_hints */ 4571 table->HintPGI = save_HintPGI; 4572 4573 /* GL_EXT_polygon_offset */ 4574 table->PolygonOffsetEXT = save_PolygonOffsetEXT; 4575 4576 /* GL_EXT_blend_minmax */ 4577#if 0 4578 table->BlendEquationEXT = save_BlendEquationEXT; 4579#endif 4580 4581 /* GL_EXT_blend_color */ 4582#if 0 4583 table->BlendColorEXT = save_BlendColorEXT; 4584#endif 4585 4586 /* GL_ARB_multitexture */ 4587 table->ActiveTextureARB = save_ActiveTextureARB; 4588 table->ClientActiveTextureARB = save_ClientActiveTextureARB; 4589 table->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB; 4590 table->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB; 4591 table->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB; 4592 table->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB; 4593 table->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB; 4594 table->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB; 4595 table->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB; 4596 table->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB; 4597 table->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB; 4598 table->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB; 4599 table->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB; 4600 table->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB; 4601 table->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB; 4602 table->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB; 4603 table->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB; 4604 table->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB; 4605 table->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB; 4606 table->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB; 4607 table->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB; 4608 table->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB; 4609 table->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB; 4610 table->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB; 4611 table->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB; 4612 table->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB; 4613 table->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB; 4614 table->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB; 4615 table->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB; 4616 table->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB; 4617 table->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB; 4618 table->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB; 4619 table->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB; 4620 table->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB; 4621 4622 /* GL_EXT_blend_func_separate */ 4623 table->BlendFuncSeparateEXT = save_BlendFuncSeparateEXT; 4624 4625 /* GL_MESA_window_pos */ 4626 table->WindowPos2dMESA = save_WindowPos2dMESA; 4627 table->WindowPos2dvMESA = save_WindowPos2dvMESA; 4628 table->WindowPos2fMESA = save_WindowPos2fMESA; 4629 table->WindowPos2fvMESA = save_WindowPos2fvMESA; 4630 table->WindowPos2iMESA = save_WindowPos2iMESA; 4631 table->WindowPos2ivMESA = save_WindowPos2ivMESA; 4632 table->WindowPos2sMESA = save_WindowPos2sMESA; 4633 table->WindowPos2svMESA = save_WindowPos2svMESA; 4634 table->WindowPos3dMESA = save_WindowPos3dMESA; 4635 table->WindowPos3dvMESA = save_WindowPos3dvMESA; 4636 table->WindowPos3fMESA = save_WindowPos3fMESA; 4637 table->WindowPos3fvMESA = save_WindowPos3fvMESA; 4638 table->WindowPos3iMESA = save_WindowPos3iMESA; 4639 table->WindowPos3ivMESA = save_WindowPos3ivMESA; 4640 table->WindowPos3sMESA = save_WindowPos3sMESA; 4641 table->WindowPos3svMESA = save_WindowPos3svMESA; 4642 table->WindowPos4dMESA = save_WindowPos4dMESA; 4643 table->WindowPos4dvMESA = save_WindowPos4dvMESA; 4644 table->WindowPos4fMESA = save_WindowPos4fMESA; 4645 table->WindowPos4fvMESA = save_WindowPos4fvMESA; 4646 table->WindowPos4iMESA = save_WindowPos4iMESA; 4647 table->WindowPos4ivMESA = save_WindowPos4ivMESA; 4648 table->WindowPos4sMESA = save_WindowPos4sMESA; 4649 table->WindowPos4svMESA = save_WindowPos4svMESA; 4650 4651 /* GL_MESA_resize_buffers */ 4652 table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; 4653 4654 /* GL_ARB_transpose_matrix */ 4655 table->LoadTransposeMatrixdARB = save_LoadTransposeMatrixdARB; 4656 table->LoadTransposeMatrixfARB = save_LoadTransposeMatrixfARB; 4657 table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB; 4658 table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB; 4659 4660} 4661 4662 4663 4664/*** 4665 *** Debugging code 4666 ***/ 4667static const char *enum_string( GLenum k ) 4668{ 4669 return gl_lookup_enum_by_nr( k ); 4670} 4671 4672 4673/* 4674 * Print the commands in a display list. For debugging only. 4675 * TODO: many commands aren't handled yet. 4676 */ 4677static void print_list( GLcontext *ctx, FILE *f, GLuint list ) 4678{ 4679 Node *n; 4680 GLboolean done; 4681 OpCode opcode; 4682 4683 if (!glIsList(list)) { 4684 fprintf(f,"%u is not a display list ID\n",list); 4685 return; 4686 } 4687 4688 n = (Node *) _mesa_HashLookup(ctx->Shared->DisplayList, list); 4689 4690 fprintf( f, "START-LIST %u, address %p\n", list, (void*)n ); 4691 4692 done = n ? GL_FALSE : GL_TRUE; 4693 while (!done) { 4694 opcode = n[0].opcode; 4695 4696 switch (opcode) { 4697 case OPCODE_ACCUM: 4698 fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f ); 4699 break; 4700 case OPCODE_BITMAP: 4701 fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, 4702 n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data ); 4703 break; 4704 case OPCODE_CALL_LIST: 4705 fprintf(f,"CallList %d\n", (int) n[1].ui ); 4706 break; 4707 case OPCODE_CALL_LIST_OFFSET: 4708 fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui, 4709 ctx->List.ListBase, ctx->List.ListBase + n[1].ui ); 4710 break; 4711 case OPCODE_DISABLE: 4712 fprintf(f,"Disable %s\n", enum_string(n[1].e)); 4713 break; 4714 case OPCODE_ENABLE: 4715 fprintf(f,"Enable %s\n", enum_string(n[1].e)); 4716 break; 4717 case OPCODE_FRUSTUM: 4718 fprintf(f,"Frustum %g %g %g %g %g %g\n", 4719 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); 4720 break; 4721 case OPCODE_LINE_STIPPLE: 4722 fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us ); 4723 break; 4724 case OPCODE_LOAD_IDENTITY: 4725 fprintf(f,"LoadIdentity\n"); 4726 break; 4727 case OPCODE_LOAD_MATRIX: 4728 fprintf(f,"LoadMatrix\n"); 4729 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f); 4730 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f); 4731 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f); 4732 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f); 4733 break; 4734 case OPCODE_MULT_MATRIX: 4735 fprintf(f,"MultMatrix (or Rotate)\n"); 4736 fprintf(f," %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f); 4737 fprintf(f," %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f); 4738 fprintf(f," %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f); 4739 fprintf(f," %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f); 4740 break; 4741 case OPCODE_ORTHO: 4742 fprintf(f,"Ortho %g %g %g %g %g %g\n", 4743 n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); 4744 break; 4745 case OPCODE_POP_ATTRIB: 4746 fprintf(f,"PopAttrib\n"); 4747 break; 4748 case OPCODE_POP_MATRIX: 4749 fprintf(f,"PopMatrix\n"); 4750 break; 4751 case OPCODE_POP_NAME: 4752 fprintf(f,"PopName\n"); 4753 break; 4754 case OPCODE_PUSH_ATTRIB: 4755 fprintf(f,"PushAttrib %x\n", n[1].bf ); 4756 break; 4757 case OPCODE_PUSH_MATRIX: 4758 fprintf(f,"PushMatrix\n"); 4759 break; 4760 case OPCODE_PUSH_NAME: 4761 fprintf(f,"PushName %d\n", (int) n[1].ui ); 4762 break; 4763 case OPCODE_RASTER_POS: 4764 fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f); 4765 break; 4766 case OPCODE_RECTF: 4767 fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f); 4768 break; 4769 case OPCODE_SCALE: 4770 fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f ); 4771 break; 4772 case OPCODE_TRANSLATE: 4773 fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f ); 4774 break; 4775 case OPCODE_BIND_TEXTURE: 4776 fprintf(f,"BindTexture %s %d\n", gl_lookup_enum_by_nr(n[1].ui), 4777 n[2].ui); 4778 break; 4779 case OPCODE_SHADE_MODEL: 4780 fprintf(f,"ShadeModel %s\n", gl_lookup_enum_by_nr(n[1].ui)); 4781 break; 4782 4783 /* 4784 * meta opcodes/commands 4785 */ 4786 case OPCODE_ERROR: 4787 fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data ); 4788 break; 4789 case OPCODE_VERTEX_CASSETTE: 4790 fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n", 4791 ((struct immediate *) n[1].data)->id, 4792 n[2].ui, 4793 n[3].ui); 4794 gl_print_cassette( (struct immediate *) n[1].data ); 4795 break; 4796 case OPCODE_CONTINUE: 4797 fprintf(f,"DISPLAY-LIST-CONTINUE\n"); 4798 n = (Node *) n[1].next; 4799 break; 4800 case OPCODE_END_OF_LIST: 4801 fprintf(f,"END-LIST %u\n", list); 4802 done = GL_TRUE; 4803 break; 4804 default: 4805 if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { 4806 fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", 4807 opcode, (void*) n); 4808 return; 4809 } 4810 else { 4811 fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]); 4812 } 4813 } 4814 4815 /* increment n to point to next compiled command */ 4816 if (opcode!=OPCODE_CONTINUE) { 4817 n += InstSize[opcode]; 4818 } 4819 } 4820} 4821 4822 4823 4824/* 4825 * Clients may call this function to help debug display list problems. 4826 * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, 4827 * changed, or break in the future without notice. 4828 */ 4829void mesa_print_display_list( GLuint list ) 4830{ 4831 GET_CURRENT_CONTEXT(ctx); 4832 print_list( ctx, stderr, list ); 4833} 4834