Changeset 3598 for trunk/src/opengl/mesa/attrib.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/attrib.c
r2938 r3598 1 /* $Id: attrib.c,v 1. 1 2000-02-29 00:49:58 sandervlExp $ */1 /* $Id: attrib.c,v 1.2 2000-05-23 20:40:22 jeroen Exp $ */ 2 2 3 3 /* … … 26 26 27 27 28 29 #include <stdlib.h>30 31 28 #ifdef PC_HEADER 32 29 #include "all.h" 33 30 #else 34 #ifndef XFree86Server 35 #include <stdio.h> 36 #else 37 #include "GL/xf86glx.h" 38 #endif 31 #include "glheader.h" 39 32 #include "attrib.h" 40 33 #include "context.h" 41 #include "glmisc.h"42 34 #include "enable.h" 43 35 #include "enums.h" 36 #include "mem.h" 37 #include "buffers.h" 44 38 #include "macros.h" 45 39 #include "simple_list.h" … … 55 49 * "kind" value and a pointer to a struct of state data. 56 50 */ 57 static struct gl_attrib_node *new_attrib_node( GLbitfield kind ) 51 static struct gl_attrib_node * 52 new_attrib_node( GLbitfield kind ) 58 53 { 59 54 struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node); … … 69 64 * Copy texture object state from one texture object to another. 70 65 */ 71 static void copy_texobj_state( struct gl_texture_object *dest, 72 const struct gl_texture_object *src ) 66 static void 67 copy_texobj_state( struct gl_texture_object *dest, 68 const struct gl_texture_object *src ) 73 69 { 74 70 /* … … 93 89 dest->M = src->M; 94 90 dest->MinMagThresh = src->MinMagThresh; 95 memcpy( dest->Palette, src->Palette, 96 sizeof(GLubyte) * MAX_TEXTURE_PALETTE_SIZE * 4 ); 97 dest->PaletteSize = src->PaletteSize; 98 dest->PaletteIntFormat = src->PaletteIntFormat; 99 dest->PaletteFormat = src->PaletteFormat; 91 dest->Palette = src->Palette; 100 92 dest->Complete = src->Complete; 101 93 dest->SampleFunc = src->SampleFunc; … … 104 96 105 97 106 void gl_PushAttrib( GLcontext* ctx, GLbitfield mask ) 98 void 99 _mesa_PushAttrib(GLbitfield mask) 107 100 { 108 101 struct gl_attrib_node *newnode; 109 102 struct gl_attrib_node *head; 110 103 104 GET_CURRENT_CONTEXT(ctx); 111 105 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushAttrib"); 112 106 113 107 if (MESA_VERBOSE&VERBOSE_API) 114 fprintf(stderr, "glPushAttrib %x\n", mask);108 fprintf(stderr, "glPushAttrib %x\n", (int)mask); 115 109 116 110 if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) { … … 350 344 /* Take care of texture object reference counters */ 351 345 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 352 353 354 346 ctx->Texture.Unit[u].CurrentD[1]->RefCount++; 347 ctx->Texture.Unit[u].CurrentD[2]->RefCount++; 348 ctx->Texture.Unit[u].CurrentD[3]->RefCount++; 355 349 } 356 350 attr = MALLOC_STRUCT( gl_texture_attrib ); … … 398 392 * of device driver functions to update device driver state. 399 393 */ 400 void gl_PopAttrib( GLcontext* ctx ) 394 void 395 _mesa_PopAttrib(void) 401 396 { 402 397 struct gl_attrib_node *attr, *next; 398 GET_CURRENT_CONTEXT(ctx); 403 399 404 400 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopAttrib"); … … 416 412 417 413 if (MESA_VERBOSE&VERBOSE_API) 418 414 fprintf(stderr, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr->kind)); 419 415 420 416 switch (attr->kind) { … … 429 425 GLenum oldBlendSrc = ctx->Color.BlendSrcRGB; 430 426 GLenum oldBlendDst = ctx->Color.BlendDstRGB; 431 427 GLenum oldLogicOp = ctx->Color.LogicOp; 432 428 MEMCPY( &ctx->Color, attr->data, 433 429 sizeof(struct gl_colorbuffer_attrib) ); 434 430 if (ctx->Color.DrawBuffer != oldDrawBuffer) { 435 gl_DrawBuffer(ctx, ctx->Color.DrawBuffer); 436 } 437 if ((ctx->Color.AlphaFunc != oldAlphaFunc || 438 ctx->Color.AlphaRef != oldAlphaRef) && 439 ctx->Driver.AlphaFunc) 440 (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc, 441 ctx->Color.AlphaRef / 255.0F); 431 _mesa_DrawBuffer( ctx->Color.DrawBuffer); 432 } 442 433 if ((ctx->Color.BlendSrcRGB != oldBlendSrc || 443 ctx->Color.Blend SrcRGB != oldBlendDst) &&434 ctx->Color.BlendDstRGB != oldBlendDst) && 444 435 ctx->Driver.BlendFunc) 445 436 (*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB, 446 437 ctx->Color.BlendDstRGB); 447 if (ctx->Color.LogicOp != oldLogicOp && 448 ctx->Driver.LogicOpcode) 449 ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp ); 438 if (ctx->Color.LogicOp != oldLogicOp && 439 ctx->Driver.LogicOpcode) { 440 ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp ); 441 } 442 if (ctx->Visual->RGBAflag) { 443 GLubyte r = (GLint) (ctx->Color.ClearColor[0] * 255.0F); 444 GLubyte g = (GLint) (ctx->Color.ClearColor[1] * 255.0F); 445 GLubyte b = (GLint) (ctx->Color.ClearColor[2] * 255.0F); 446 GLubyte a = (GLint) (ctx->Color.ClearColor[3] * 255.0F); 447 (*ctx->Driver.ClearColor)( ctx, r, g, b, a ); 448 if ((ctx->Color.AlphaFunc != oldAlphaFunc || 449 ctx->Color.AlphaRef != oldAlphaRef) && 450 ctx->Driver.AlphaFunc) 451 (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc, 452 ctx->Color.AlphaRef / 255.0F); 453 if (ctx->Driver.ColorMask) { 454 (*ctx->Driver.ColorMask)(ctx, 455 ctx->Color.ColorMask[0], 456 ctx->Color.ColorMask[1], 457 ctx->Color.ColorMask[2], 458 ctx->Color.ColorMask[3]); 459 } 460 } 461 else { 462 (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex); 463 } 450 464 } 451 465 break; 452 466 case GL_CURRENT_BIT: 453 467 MEMCPY( &ctx->Current, attr->data, 454 468 sizeof(struct gl_current_attrib) ); 455 469 break; 456 470 case GL_DEPTH_BUFFER_BIT: … … 474 488 enable = (const struct gl_enable_attrib *) attr->data; 475 489 476 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) 477 if ((VALUE) != (NEWVALUE)) {\478 gl_set_enable( ctx, ENUM, (NEWVALUE) );\479 490 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ 491 if ((VALUE) != (NEWVALUE)) { \ 492 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ 493 } 480 494 481 495 TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); … … 486 500 for (i=0;i<MAX_CLIP_PLANES;i++) { 487 501 if (ctx->Transform.ClipEnabled[i] != enable->ClipPlane[i]) 488 gl_set_enable( ctx, (GLenum) (GL_CLIP_PLANE0 + i), enable->ClipPlane[i] );502 _mesa_set_enable( ctx, (GLenum) (GL_CLIP_PLANE0 + i), enable->ClipPlane[i] ); 489 503 } 490 504 } … … 551 565 ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i]; 552 566 553 567 /* ctx->Enabled recalculated in state change 554 568 processing */ 555 569 556 570 if (ctx->Driver.Enable) { 557 571 if (ctx->Driver.ActiveTexture) … … 601 615 (*ctx->Driver.Fogfv)( ctx, GL_FOG_COLOR, ctx->Fog.Color ); 602 616 } 603 604 617 ctx->Enabled &= ~ENABLE_FOG; 618 if (ctx->Fog.Enabled) ctx->Enabled |= ENABLE_FOG; 605 619 } 606 620 break; … … 635 649 if (ctx->Driver.ShadeModel) 636 650 (*ctx->Driver.ShadeModel)(ctx, ctx->Light.ShadeModel); 637 638 639 651 ctx->Enabled &= ~ENABLE_LIGHT; 652 if (ctx->Light.Enabled && !is_empty_list(&ctx->Light.EnabledList)) 653 ctx->Enabled |= ENABLE_LIGHT; 640 654 break; 641 655 case GL_LINE_BIT: … … 645 659 (*ctx->Driver.Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag ); 646 660 } 661 if (ctx->Driver.LineStipple) 662 (*ctx->Driver.LineStipple)(ctx, ctx->Line.StippleFactor, 663 ctx->Line.StipplePattern); 664 if (ctx->Driver.LineWidth) 665 (*ctx->Driver.LineWidth)(ctx, ctx->Line.Width); 647 666 break; 648 667 case GL_LIST_BIT: … … 669 688 (*ctx->Driver.PolygonMode)( ctx, GL_BACK, ctx->Polygon.BackMode); 670 689 } 671 672 673 674 675 690 if (ctx->Driver.CullFace) 691 ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode ); 692 693 if (ctx->Driver.FrontFace) 694 ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace ); 676 695 677 696 if (ctx->Driver.Enable) … … 679 698 } 680 699 break; 681 case GL_POLYGON_STIPPLE_BIT: 682 MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); 683 break; 700 case GL_POLYGON_STIPPLE_BIT: 701 MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); 702 if (ctx->Driver.PolygonStipple) 703 ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); 704 break; 684 705 case GL_SCISSOR_BIT: 685 706 MEMCPY( &ctx->Scissor, attr->data, 686 707 sizeof(struct gl_scissor_attrib) ); 687 708 if (ctx->Driver.Enable) 688 709 (*ctx->Driver.Enable)( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled ); 689 690 691 710 if (ctx->Driver.Scissor) 711 ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, 712 ctx->Scissor.Width, ctx->Scissor.Height ); 692 713 break; 693 714 case GL_STENCIL_BUFFER_BIT: 694 715 MEMCPY( &ctx->Stencil, attr->data, 695 716 sizeof(struct gl_stencil_attrib) ); 696 717 if (ctx->Driver.StencilFunc) 697 718 (*ctx->Driver.StencilFunc)( ctx, ctx->Stencil.Function, … … 706 727 if (ctx->Driver.Enable) 707 728 (*ctx->Driver.Enable)( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled ); 708 709 710 729 ctx->TriangleCaps &= ~DD_STENCIL; 730 if (ctx->Stencil.Enabled) 731 ctx->TriangleCaps |= DD_STENCIL; 711 732 712 733 break; 713 734 case GL_TRANSFORM_BIT: 714 735 MEMCPY( &ctx->Transform, attr->data, 715 736 sizeof(struct gl_transform_attrib) ); 716 737 if (ctx->Driver.Enable) { 717 738 (*ctx->Driver.Enable)( ctx, GL_NORMALIZE, ctx->Transform.Normalize ); 718 739 (*ctx->Driver.Enable)( ctx, GL_RESCALE_NORMAL_EXT, ctx->Transform.RescaleNormals ); 719 740 } 720 721 722 741 ctx->Enabled &= ~(ENABLE_NORMALIZE|ENABLE_RESCALE); 742 if (ctx->Transform.Normalize) ctx->Enabled |= ENABLE_NORMALIZE; 743 if (ctx->Transform.RescaleNormals) ctx->Enabled |= ENABLE_RESCALE; 723 744 break; 724 745 case GL_TEXTURE_BIT: … … 727 748 GLuint u; 728 749 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 729 730 731 750 ctx->Texture.Unit[u].CurrentD[1]->RefCount--; 751 ctx->Texture.Unit[u].CurrentD[2]->RefCount--; 752 ctx->Texture.Unit[u].CurrentD[3]->RefCount--; 732 753 } 733 754 MEMCPY( &ctx->Texture, attr->data, … … 749 770 break; 750 771 case GL_VIEWPORT_BIT: 751 752 753 754 755 gl_Viewport( ctx,v->X, v->Y, v->Width, v->Height );756 gl_DepthRange( ctx,v->Near, v->Far );757 758 772 { 773 struct gl_viewport_attrib *v = 774 (struct gl_viewport_attrib *)attr->data; 775 776 _mesa_Viewport( v->X, v->Y, v->Width, v->Height ); 777 _mesa_DepthRange( v->Near, v->Far ); 778 break; 779 } 759 780 default: 760 781 gl_problem( ctx, "Bad attrib flag in PopAttrib"); … … 776 797 777 798 778 void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask ) 799 void 800 _mesa_PushClientAttrib(GLbitfield mask) 779 801 { 780 802 struct gl_attrib_node *newnode; 781 803 struct gl_attrib_node *head; 782 804 805 GET_CURRENT_CONTEXT(ctx); 783 806 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushClientAttrib"); 784 807 … … 826 849 827 850 828 void gl_PopClientAttrib( GLcontext *ctx ) 851 void 852 _mesa_PopClientAttrib(void) 829 853 { 830 854 struct gl_attrib_node *attr, *next; 831 855 856 GET_CURRENT_CONTEXT(ctx); 832 857 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopClientAttrib"); 833 858 … … 852 877 case GL_CLIENT_VERTEX_ARRAY_BIT: 853 878 MEMCPY( &ctx->Array, attr->data, 854 879 sizeof(struct gl_array_attrib) ); 855 880 break; 856 881 default: … … 868 893 } 869 894 895 896
Note:
See TracChangeset
for help on using the changeset viewer.