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

📄 attrib.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
      /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */      attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer;      newnode = new_attrib_node( GL_PIXEL_MODE_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_POINT_BIT) {      struct gl_point_attrib *attr;      attr = MALLOC_STRUCT( gl_point_attrib );      MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) );      newnode = new_attrib_node( GL_POINT_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_POLYGON_BIT) {      struct gl_polygon_attrib *attr;      attr = MALLOC_STRUCT( gl_polygon_attrib );      MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) );      newnode = new_attrib_node( GL_POLYGON_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_POLYGON_STIPPLE_BIT) {      GLuint *stipple;      stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) );      MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );      newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT );      newnode->data = stipple;      newnode->next = head;      head = newnode;   }   if (mask & GL_SCISSOR_BIT) {      struct gl_scissor_attrib *attr;      attr = MALLOC_STRUCT( gl_scissor_attrib );      MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) );      newnode = new_attrib_node( GL_SCISSOR_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_STENCIL_BUFFER_BIT) {      struct gl_stencil_attrib *attr;      attr = MALLOC_STRUCT( gl_stencil_attrib );      MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) );      newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_TEXTURE_BIT) {      struct texture_state *texstate = CALLOC_STRUCT(texture_state);      GLuint u;      if (!texstate) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)");         goto end;      }      _mesa_lock_context_textures(ctx);      /* copy/save the bulk of texture state here */      _mesa_memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture));      /* Save references to the currently bound texture objects so they don't       * accidentally get deleted while referenced in the attribute stack.       */      for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_INDEX],                                ctx->Texture.Unit[u].Current1D);         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_INDEX],                                ctx->Texture.Unit[u].Current2D);         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_3D_INDEX],                                ctx->Texture.Unit[u].Current3D);         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_CUBE_INDEX],                                ctx->Texture.Unit[u].CurrentCubeMap);         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_RECT_INDEX],                                ctx->Texture.Unit[u].CurrentRect);         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_ARRAY_INDEX],                                ctx->Texture.Unit[u].Current1DArray);         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_ARRAY_INDEX],                                ctx->Texture.Unit[u].Current2DArray);      }      /* copy state/contents of the currently bound texture objects */      for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_INDEX],                                   ctx->Texture.Unit[u].Current1D);         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_INDEX],                                   ctx->Texture.Unit[u].Current2D);         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_3D_INDEX],                                   ctx->Texture.Unit[u].Current3D);         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_CUBE_INDEX],                                   ctx->Texture.Unit[u].CurrentCubeMap);         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_RECT_INDEX],                                   ctx->Texture.Unit[u].CurrentRect);         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_ARRAY_INDEX],                                   ctx->Texture.Unit[u].Current1DArray);         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_ARRAY_INDEX],                                   ctx->Texture.Unit[u].Current2DArray);      }      _mesa_unlock_context_textures(ctx);      newnode = new_attrib_node( GL_TEXTURE_BIT );      newnode->data = texstate;      newnode->next = head;      head = newnode;   }   if (mask & GL_TRANSFORM_BIT) {      struct gl_transform_attrib *attr;      attr = MALLOC_STRUCT( gl_transform_attrib );      MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );      newnode = new_attrib_node( GL_TRANSFORM_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   if (mask & GL_VIEWPORT_BIT) {      struct gl_viewport_attrib *attr;      attr = MALLOC_STRUCT( gl_viewport_attrib );      MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );      newnode = new_attrib_node( GL_VIEWPORT_BIT );      newnode->data = attr;      newnode->next = head;      head = newnode;   }   /* GL_ARB_multisample */   if (mask & GL_MULTISAMPLE_BIT_ARB) {      struct gl_multisample_attrib *attr;      attr = MALLOC_STRUCT( gl_multisample_attrib );      MEMCPY( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) );      newnode = new_attrib_node( GL_MULTISAMPLE_BIT_ARB );      newnode->data = attr;      newnode->next = head;      head = newnode;   }end:   ctx->AttribStack[ctx->AttribStackDepth] = head;   ctx->AttribStackDepth++;}static voidpop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable){   GLuint i;#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM)		\	if ((VALUE) != (NEWVALUE)) {			\	   _mesa_set_enable( ctx, ENUM, (NEWVALUE) );	\	}   TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST);   TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND);   for (i=0;i<MAX_CLIP_PLANES;i++) {      const GLuint mask = 1 << i;      if ((ctx->Transform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask))	  _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i),			   (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE));   }   TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,                   GL_COLOR_MATERIAL);   TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION],                   enable->ColorTable[COLORTABLE_PRECONVOLUTION],                   GL_COLOR_TABLE);   TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION],                   enable->ColorTable[COLORTABLE_POSTCONVOLUTION],                   GL_POST_CONVOLUTION_COLOR_TABLE);   TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX],                   enable->ColorTable[COLORTABLE_POSTCOLORMATRIX],                   GL_POST_COLOR_MATRIX_COLOR_TABLE);   TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE);   TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST);   TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER);   TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D,                   GL_CONVOLUTION_1D);   TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D,                   GL_CONVOLUTION_2D);   TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D,                   GL_SEPARABLE_2D);   TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG);   TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING);   TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH);   TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple,                   GL_LINE_STIPPLE);   TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp,                   GL_INDEX_LOGIC_OP);   TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp,                   GL_COLOR_LOGIC_OP);   TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4);   TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX);   TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL);   TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1,                   GL_MAP1_TEXTURE_COORD_1);   TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2,                   GL_MAP1_TEXTURE_COORD_2);   TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3,                   GL_MAP1_TEXTURE_COORD_3);   TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4,                   GL_MAP1_TEXTURE_COORD_4);   TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3,                   GL_MAP1_VERTEX_3);   TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4,                   GL_MAP1_VERTEX_4);   for (i = 0; i < 16; i++) {      TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i],                      GL_MAP1_VERTEX_ATTRIB0_4_NV + i);   }   TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4);   TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX);   TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL);   TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1,                   GL_MAP2_TEXTURE_COORD_1);   TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2,                   GL_MAP2_TEXTURE_COORD_2);   TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3,                   GL_MAP2_TEXTURE_COORD_3);   TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4,                   GL_MAP2_TEXTURE_COORD_4);   TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3,                   GL_MAP2_VERTEX_3);   TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4,                   GL_MAP2_VERTEX_4);   for (i = 0; i < 16; i++) {      TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i],                      GL_MAP2_VERTEX_ATTRIB0_4_NV + i);   }   TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL);   TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE);   TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals,                   GL_RESCALE_NORMAL_EXT);   TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped,                   enable->RasterPositionUnclipped,                   GL_RASTER_POSITION_UNCLIPPED_IBM);   TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth,                   GL_POINT_SMOOTH);   if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) {      TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite,                      GL_POINT_SPRITE_NV);   }   TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint,                   GL_POLYGON_OFFSET_POINT);   TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine,                   GL_POLYGON_OFFSET_LINE);   TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill,                   GL_POLYGON_OFFSET_FILL);   TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth,                   GL_POLYGON_SMOOTH);   TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple,                   GL_POLYGON_STIPPLE);   TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);   TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);   if (ctx->Extensions.EXT_stencil_two_side) {      TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT);   }   TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled,                   GL_MULTISAMPLE_ARB);   TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage,                   enable->SampleAlphaToCoverage,                   GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);   TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne,                   enable->SampleAlphaToOne,                   GL_SAMPLE_ALPHA_TO_ONE_ARB);   TEST_AND_UPDATE(ctx->Multisample.SampleCoverage,                   enable->SampleCoverage,                   GL_SAMPLE_COVERAGE_ARB);   TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert,                   enable->SampleCoverageInvert,                   GL_SAMPLE_COVERAGE_INVERT_ARB);   /* GL_ARB_vertex_program, GL_NV_vertex_program */   TEST_AND_UPDATE(ctx->VertexProgram.Enabled,                   enable->VertexProgram,                   GL_VERTEX_PROGRAM_ARB);   TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled,                   enable->VertexProgramPointSize,                   GL_VERTEX_PROGRAM_POINT_SIZE_ARB);   TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled,                   enable->VertexProgramTwoSide,                   GL_VERTEX_PROGRAM_TWO_SIDE_ARB);#undef TEST_AND_UPDATE

⌨️ 快捷键说明

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