Ignore:
Timestamp:
May 23, 2000, 10:41:28 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

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 sandervl Exp $ */
     1/* $Id: attrib.c,v 1.2 2000-05-23 20:40:22 jeroen Exp $ */
    22
    33/*
     
    2626
    2727
    28 
    29 #include <stdlib.h>
    30 
    3128#ifdef PC_HEADER
    3229#include "all.h"
    3330#else
    34 #ifndef XFree86Server
    35 #include <stdio.h>
    36 #else
    37 #include "GL/xf86glx.h"
    38 #endif
     31#include "glheader.h"
    3932#include "attrib.h"
    4033#include "context.h"
    41 #include "glmisc.h"
    4234#include "enable.h"
    4335#include "enums.h"
     36#include "mem.h"
     37#include "buffers.h"
    4438#include "macros.h"
    4539#include "simple_list.h"
     
    5549 * "kind" value and a pointer to a struct of state data.
    5650 */
    57 static struct gl_attrib_node *new_attrib_node( GLbitfield kind )
     51static struct gl_attrib_node *
     52new_attrib_node( GLbitfield kind )
    5853{
    5954   struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node);
     
    6964 * Copy texture object state from one texture object to another.
    7065 */
    71 static void copy_texobj_state( struct gl_texture_object *dest,
    72                                const struct gl_texture_object *src )
     66static void
     67copy_texobj_state( struct gl_texture_object *dest,
     68                   const struct gl_texture_object *src )
    7369{
    7470   /*
     
    9389   dest->M = src->M;
    9490   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;
    10092   dest->Complete = src->Complete;
    10193   dest->SampleFunc = src->SampleFunc;
     
    10496
    10597
    106 void gl_PushAttrib( GLcontext* ctx, GLbitfield mask )
     98void
     99_mesa_PushAttrib(GLbitfield mask)
    107100{
    108101   struct gl_attrib_node *newnode;
    109102   struct gl_attrib_node *head;
    110103
     104   GET_CURRENT_CONTEXT(ctx);
    111105   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushAttrib");
    112106
    113107   if (MESA_VERBOSE&VERBOSE_API)
    114       fprintf(stderr, "glPushAttrib %x\n", mask);
     108      fprintf(stderr, "glPushAttrib %x\n", (int)mask);
    115109
    116110   if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) {
     
    350344      /* Take care of texture object reference counters */
    351345      for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
    352         ctx->Texture.Unit[u].CurrentD[1]->RefCount++;
    353         ctx->Texture.Unit[u].CurrentD[2]->RefCount++;
    354         ctx->Texture.Unit[u].CurrentD[3]->RefCount++;
     346        ctx->Texture.Unit[u].CurrentD[1]->RefCount++;
     347        ctx->Texture.Unit[u].CurrentD[2]->RefCount++;
     348        ctx->Texture.Unit[u].CurrentD[3]->RefCount++;
    355349      }
    356350      attr = MALLOC_STRUCT( gl_texture_attrib );
     
    398392 * of device driver functions to update device driver state.
    399393 */
    400 void gl_PopAttrib( GLcontext* ctx )
     394void
     395_mesa_PopAttrib(void)
    401396{
    402397   struct gl_attrib_node *attr, *next;
     398   GET_CURRENT_CONTEXT(ctx);
    403399
    404400   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopAttrib");
     
    416412
    417413      if (MESA_VERBOSE&VERBOSE_API)
    418         fprintf(stderr, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr->kind));
     414        fprintf(stderr, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr->kind));
    419415
    420416      switch (attr->kind) {
     
    429425               GLenum oldBlendSrc = ctx->Color.BlendSrcRGB;
    430426               GLenum oldBlendDst = ctx->Color.BlendDstRGB;
    431                GLenum oldLogicOp = ctx->Color.LogicOp;
     427               GLenum oldLogicOp = ctx->Color.LogicOp;
    432428               MEMCPY( &ctx->Color, attr->data,
    433429                       sizeof(struct gl_colorbuffer_attrib) );
    434430               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               }
    442433               if ((ctx->Color.BlendSrcRGB != oldBlendSrc ||
    443                     ctx->Color.BlendSrcRGB != oldBlendDst) &&
     434                    ctx->Color.BlendDstRGB != oldBlendDst) &&
    444435                   ctx->Driver.BlendFunc)
    445436                  (*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB,
    446437                                            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               }
    450464            }
    451465            break;
    452466         case GL_CURRENT_BIT:
    453467            MEMCPY( &ctx->Current, attr->data,
    454                     sizeof(struct gl_current_attrib) );
     468                    sizeof(struct gl_current_attrib) );
    455469            break;
    456470         case GL_DEPTH_BUFFER_BIT:
     
    474488               enable = (const struct gl_enable_attrib *) attr->data;
    475489
    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        }
    480494
    481495               TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST);
     
    486500                  for (i=0;i<MAX_CLIP_PLANES;i++) {
    487501                     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] );
    489503                  }
    490504               }
     
    551565                        ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i];
    552566
    553                         /* ctx->Enabled recalculated in state change
     567                        /* ctx->Enabled recalculated in state change
    554568                           processing */
    555                        
     569
    556570                        if (ctx->Driver.Enable) {
    557571                           if (ctx->Driver.ActiveTexture)
     
    601615                  (*ctx->Driver.Fogfv)( ctx, GL_FOG_COLOR, ctx->Fog.Color );
    602616               }
    603                ctx->Enabled &= ~ENABLE_FOG;
    604                if (ctx->Fog.Enabled) ctx->Enabled |= ENABLE_FOG;
     617               ctx->Enabled &= ~ENABLE_FOG;
     618               if (ctx->Fog.Enabled) ctx->Enabled |= ENABLE_FOG;
    605619            }
    606620            break;
     
    635649            if (ctx->Driver.ShadeModel)
    636650               (*ctx->Driver.ShadeModel)(ctx, ctx->Light.ShadeModel);
    637             ctx->Enabled &= ~ENABLE_LIGHT;
    638             if (ctx->Light.Enabled && !is_empty_list(&ctx->Light.EnabledList))
    639                ctx->Enabled |= ENABLE_LIGHT;
     651            ctx->Enabled &= ~ENABLE_LIGHT;
     652            if (ctx->Light.Enabled && !is_empty_list(&ctx->Light.EnabledList))
     653               ctx->Enabled |= ENABLE_LIGHT;
    640654            break;
    641655         case GL_LINE_BIT:
     
    645659               (*ctx->Driver.Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag );
    646660            }
     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);
    647666            break;
    648667         case GL_LIST_BIT:
     
    669688                  (*ctx->Driver.PolygonMode)( ctx, GL_BACK, ctx->Polygon.BackMode);
    670689               }
    671                if (ctx->Driver.CullFace)
    672                   ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
    673 
    674                if (ctx->Driver.FrontFace)
    675                   ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
     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 );
    676695
    677696               if (ctx->Driver.Enable)
     
    679698            }
    680699            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;
    684705         case GL_SCISSOR_BIT:
    685706            MEMCPY( &ctx->Scissor, attr->data,
    686                     sizeof(struct gl_scissor_attrib) );
     707                    sizeof(struct gl_scissor_attrib) );
    687708            if (ctx->Driver.Enable)
    688709               (*ctx->Driver.Enable)( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
    689             if (ctx->Driver.Scissor)
    690                ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
    691                                     ctx->Scissor.Width, ctx->Scissor.Height );
     710            if (ctx->Driver.Scissor)
     711               ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
     712                                    ctx->Scissor.Width, ctx->Scissor.Height );
    692713            break;
    693714         case GL_STENCIL_BUFFER_BIT:
    694715            MEMCPY( &ctx->Stencil, attr->data,
    695                     sizeof(struct gl_stencil_attrib) );
     716                    sizeof(struct gl_stencil_attrib) );
    696717            if (ctx->Driver.StencilFunc)
    697718               (*ctx->Driver.StencilFunc)( ctx, ctx->Stencil.Function,
     
    706727            if (ctx->Driver.Enable)
    707728               (*ctx->Driver.Enable)( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
    708             ctx->TriangleCaps &= ~DD_STENCIL;
    709             if (ctx->Stencil.Enabled)
    710                ctx->TriangleCaps |= DD_STENCIL;
     729            ctx->TriangleCaps &= ~DD_STENCIL;
     730            if (ctx->Stencil.Enabled)
     731               ctx->TriangleCaps |= DD_STENCIL;
    711732
    712733            break;
    713734         case GL_TRANSFORM_BIT:
    714735            MEMCPY( &ctx->Transform, attr->data,
    715                     sizeof(struct gl_transform_attrib) );
     736                    sizeof(struct gl_transform_attrib) );
    716737            if (ctx->Driver.Enable) {
    717738               (*ctx->Driver.Enable)( ctx, GL_NORMALIZE, ctx->Transform.Normalize );
    718739               (*ctx->Driver.Enable)( ctx, GL_RESCALE_NORMAL_EXT, ctx->Transform.RescaleNormals );
    719740            }
    720             ctx->Enabled &= ~(ENABLE_NORMALIZE|ENABLE_RESCALE);
    721             if (ctx->Transform.Normalize) ctx->Enabled |= ENABLE_NORMALIZE;
    722             if (ctx->Transform.RescaleNormals) ctx->Enabled |= ENABLE_RESCALE;
     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;
    723744            break;
    724745         case GL_TEXTURE_BIT:
     
    727748               GLuint u;
    728749               for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
    729                   ctx->Texture.Unit[u].CurrentD[1]->RefCount--;
    730                   ctx->Texture.Unit[u].CurrentD[2]->RefCount--;
    731                   ctx->Texture.Unit[u].CurrentD[3]->RefCount--;
     750                  ctx->Texture.Unit[u].CurrentD[1]->RefCount--;
     751                  ctx->Texture.Unit[u].CurrentD[2]->RefCount--;
     752                  ctx->Texture.Unit[u].CurrentD[3]->RefCount--;
    732753               }
    733754               MEMCPY( &ctx->Texture, attr->data,
     
    749770            break;
    750771         case GL_VIEWPORT_BIT:
    751         {
    752             struct gl_viewport_attrib *v =
    753                (struct gl_viewport_attrib *)attr->data;
    754        
    755             gl_Viewport( ctx, v->X, v->Y, v->Width, v->Height );
    756             gl_DepthRange( ctx, v->Near, v->Far );
    757             break;
    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        }
    759780         default:
    760781            gl_problem( ctx, "Bad attrib flag in PopAttrib");
     
    776797
    777798
    778 void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask )
     799void
     800_mesa_PushClientAttrib(GLbitfield mask)
    779801{
    780802   struct gl_attrib_node *newnode;
    781803   struct gl_attrib_node *head;
    782804
     805   GET_CURRENT_CONTEXT(ctx);
    783806   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushClientAttrib");
    784807
     
    826849
    827850
    828 void gl_PopClientAttrib( GLcontext *ctx )
     851void
     852_mesa_PopClientAttrib(void)
    829853{
    830854   struct gl_attrib_node *attr, *next;
    831855
     856   GET_CURRENT_CONTEXT(ctx);
    832857   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopClientAttrib");
    833858
     
    852877         case GL_CLIENT_VERTEX_ARRAY_BIT:
    853878            MEMCPY( &ctx->Array, attr->data,
    854                     sizeof(struct gl_array_attrib) );
     879                    sizeof(struct gl_array_attrib) );
    855880            break;
    856881         default:
     
    868893}
    869894
     895
     896
Note: See TracChangeset for help on using the changeset viewer.