⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attrib.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 4 页
字号:
            break;         case GL_PIXEL_MODE_BIT:            MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );            /* XXX what other pixel state needs to be set by function calls? */            _mesa_ReadBuffer(ctx->Pixel.ReadBuffer);	    ctx->NewState |= _NEW_PIXEL;            break;         case GL_POINT_BIT:            {               const struct gl_point_attrib *point;               point = (const struct gl_point_attrib *) attr->data;               _mesa_PointSize(point->Size);               _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag);               if (ctx->Extensions.EXT_point_parameters) {                  _mesa_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT,                                            point->Params);                  _mesa_PointParameterfEXT(GL_POINT_SIZE_MIN_EXT,                                           point->MinSize);                  _mesa_PointParameterfEXT(GL_POINT_SIZE_MAX_EXT,                                           point->MaxSize);                  _mesa_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT,                                           point->Threshold);               }               if (ctx->Extensions.NV_point_sprite		   || ctx->Extensions.ARB_point_sprite) {                  GLuint u;                  for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {                     _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV,                                   (GLint) point->CoordReplace[u]);                  }                  _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);                  _mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV,                                          ctx->Point.SpriteRMode);                  _mesa_PointParameterfEXT(GL_POINT_SPRITE_COORD_ORIGIN,                                           (GLfloat)ctx->Point.SpriteOrigin);               }            }            break;         case GL_POLYGON_BIT:            {               const struct gl_polygon_attrib *polygon;               polygon = (const struct gl_polygon_attrib *) attr->data;               _mesa_CullFace(polygon->CullFaceMode);               _mesa_FrontFace(polygon->FrontFace);               _mesa_PolygonMode(GL_FRONT, polygon->FrontMode);               _mesa_PolygonMode(GL_BACK, polygon->BackMode);               _mesa_PolygonOffset(polygon->OffsetFactor,                                   polygon->OffsetUnits);               _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag);               _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag);               _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag);               _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT,                                polygon->OffsetPoint);               _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE,                                polygon->OffsetLine);               _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL,                                polygon->OffsetFill);            }            break;	 case GL_POLYGON_STIPPLE_BIT:	    MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );	    ctx->NewState |= _NEW_POLYGONSTIPPLE;	    if (ctx->Driver.PolygonStipple)	       ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data );	    break;         case GL_SCISSOR_BIT:            {               const struct gl_scissor_attrib *scissor;               scissor = (const struct gl_scissor_attrib *) attr->data;               _mesa_Scissor(scissor->X, scissor->Y,                             scissor->Width, scissor->Height);               _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled);            }            break;         case GL_STENCIL_BUFFER_BIT:            {               const struct gl_stencil_attrib *stencil;               stencil = (const struct gl_stencil_attrib *) attr->data;               _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled);               _mesa_ClearStencil(stencil->Clear);               if (ctx->Extensions.EXT_stencil_two_side) {                  _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT,                                   stencil->TestTwoSide);                  _mesa_ActiveStencilFaceEXT(stencil->ActiveFace                                             ? GL_BACK : GL_FRONT);               }               /* front state */               _mesa_StencilFuncSeparate(GL_FRONT,                                         stencil->Function[0],                                         stencil->Ref[0],                                         stencil->ValueMask[0]);               _mesa_StencilMaskSeparate(GL_FRONT, stencil->WriteMask[0]);               _mesa_StencilOpSeparate(GL_FRONT, stencil->FailFunc[0],                                       stencil->ZFailFunc[0],                                       stencil->ZPassFunc[0]);               /* back state */               _mesa_StencilFuncSeparate(GL_BACK,                                         stencil->Function[1],                                         stencil->Ref[1],                                         stencil->ValueMask[1]);               _mesa_StencilMaskSeparate(GL_BACK, stencil->WriteMask[1]);               _mesa_StencilOpSeparate(GL_BACK, stencil->FailFunc[1],                                       stencil->ZFailFunc[1],                                       stencil->ZPassFunc[1]);            }            break;         case GL_TRANSFORM_BIT:            {               GLuint i;               const struct gl_transform_attrib *xform;               xform = (const struct gl_transform_attrib *) attr->data;               _mesa_MatrixMode(xform->MatrixMode);               if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))                  _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );               /* restore clip planes */               for (i = 0; i < MAX_CLIP_PLANES; i++) {                  const GLuint mask = 1 << 1;                  const GLfloat *eyePlane = xform->EyeUserPlane[i];                  COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane);                  if (xform->ClipPlanesEnabled & mask) {                     _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);                  }                  else {                     _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);                  }                  if (ctx->Driver.ClipPlane)                     ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane );               }               /* normalize/rescale */               if (xform->Normalize != ctx->Transform.Normalize)                  _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize);               if (xform->RescaleNormals != ctx->Transform.RescaleNormals)                  _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT,                                   ctx->Transform.RescaleNormals);            }            break;         case GL_TEXTURE_BIT:            /* Take care of texture object reference counters */            {               const struct gl_texture_attrib *texture;               texture = (const struct gl_texture_attrib *) attr->data;               pop_texture_group(ctx, texture);	       ctx->NewState |= _NEW_TEXTURE;            }            break;         case GL_VIEWPORT_BIT:            {               const struct gl_viewport_attrib *vp;               vp = (const struct gl_viewport_attrib *) attr->data;               _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height);               _mesa_DepthRange(vp->Near, vp->Far);            }            break;         case GL_MULTISAMPLE_BIT_ARB:            {               const struct gl_multisample_attrib *ms;               ms = (const struct gl_multisample_attrib *) attr->data;               _mesa_SampleCoverageARB(ms->SampleCoverageValue,                                       ms->SampleCoverageInvert);            }            break;         default:            _mesa_problem( ctx, "Bad attrib flag in PopAttrib");            break;      }      next = attr->next;      FREE( attr->data );      FREE( attr );      attr = next;   }}/** * Helper for incrementing/decrementing vertex buffer object reference * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group. */static voidadjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step){   GLuint i;   array->Vertex.BufferObj->RefCount += step;   array->Normal.BufferObj->RefCount += step;   array->Color.BufferObj->RefCount += step;   array->SecondaryColor.BufferObj->RefCount += step;   array->FogCoord.BufferObj->RefCount += step;   array->Index.BufferObj->RefCount += step;   array->EdgeFlag.BufferObj->RefCount += step;   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)      array->TexCoord[i].BufferObj->RefCount += step;   for (i = 0; i < VERT_ATTRIB_MAX; i++)      array->VertexAttrib[i].BufferObj->RefCount += step;   array->ArrayBufferObj->RefCount += step;   array->ElementArrayBufferObj->RefCount += step;}#define GL_CLIENT_PACK_BIT (1<<20)#define GL_CLIENT_UNPACK_BIT (1<<21)void GLAPIENTRY_mesa_PushClientAttrib(GLbitfield mask){   struct gl_attrib_node *newnode;   struct gl_attrib_node *head;   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END(ctx);   if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) {      _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );      return;   }   /* Build linked list of attribute nodes which save all attribute */   /* groups specified by the mask. */   head = NULL;   if (mask & GL_CLIENT_PIXEL_STORE_BIT) {      struct gl_pixelstore_attrib *attr;#if FEATURE_EXT_pixel_buffer_object      ctx->Pack.BufferObj->RefCount++;      ctx->Unpack.BufferObj->RefCount++;#endif      /* packing attribs */      attr = MALLOC_STRUCT( gl_pixelstore_attrib );      MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );      newnode = new_attrib_node( GL_CLIENT_PACK_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;      /* unpacking attribs */      attr = MALLOC_STRUCT( gl_pixelstore_attrib );      MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );      newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {      struct gl_array_attrib *attr;      attr = MALLOC_STRUCT( gl_array_attrib );      MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );      newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;      /* bump reference counts on buffer objects */      adjust_buffer_object_ref_counts(&ctx->Array, 1);   }   ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;   ctx->ClientAttribStackDepth++;}void GLAPIENTRY_mesa_PopClientAttrib(void){   struct gl_attrib_node *attr, *next;   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);   if (ctx->ClientAttribStackDepth == 0) {      _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" );      return;   }   ctx->ClientAttribStackDepth--;   attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];   while (attr) {      switch (attr->kind) {         case GL_CLIENT_PACK_BIT:#if FEATURE_EXT_pixel_buffer_object            ctx->Pack.BufferObj->RefCount--;            if (ctx->Pack.BufferObj->RefCount <= 0) {               _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj );               (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj );            }#endif            MEMCPY( &ctx->Pack, attr->data,                    sizeof(struct gl_pixelstore_attrib) );	    ctx->NewState |= _NEW_PACKUNPACK;            break;         case GL_CLIENT_UNPACK_BIT:#if FEATURE_EXT_pixel_buffer_object            ctx->Unpack.BufferObj->RefCount--;            if (ctx->Unpack.BufferObj->RefCount <= 0) {               _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj );               (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj );            }#endif            MEMCPY( &ctx->Unpack, attr->data,                    sizeof(struct gl_pixelstore_attrib) );	    ctx->NewState |= _NEW_PACKUNPACK;            break;         case GL_CLIENT_VERTEX_ARRAY_BIT:            adjust_buffer_object_ref_counts(&ctx->Array, -1);            MEMCPY( &ctx->Array, attr->data,		    sizeof(struct gl_array_attrib) );            /* decrement reference counts on buffer objects */	    ctx->NewState |= _NEW_ARRAY;            break;         default:            _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib");            break;      }      next = attr->next;      FREE( attr->data );      FREE( attr );      attr = next;   }}void _mesa_init_attrib( GLcontext *ctx ){   /* Renderer and client attribute stacks */   ctx->AttribStackDepth = 0;   ctx->ClientAttribStackDepth = 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -