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

📄 attrib.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
                   * since GL_FRONT (for example) is illegal for the former                   * function, but legal for the later.                   */                  GLboolean multipleBuffers = GL_FALSE;                  if (ctx->Extensions.ARB_draw_buffers) {                     GLuint i;                     for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) {                        if (color->DrawBuffer[i] != GL_NONE) {                           multipleBuffers = GL_TRUE;                           break;                        }                     }                  }                  /* Call the API_level functions, not _mesa_drawbuffers()                   * since we need to do error checking on the pop'd                   * GL_DRAW_BUFFER.                   * Ex: if GL_FRONT were pushed, but we're popping with a                   * user FBO bound, GL_FRONT will be illegal and we'll need                   * to record that error.  Per OpenGL ARB decision.                   */                  if (multipleBuffers)                     _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers,                                          color->DrawBuffer);                  else                     _mesa_DrawBuffer(color->DrawBuffer[0]);               }               _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);               _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);               _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);               _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB,                                          color->BlendDstRGB,                                          color->BlendSrcA,                                          color->BlendDstA);	       /* This special case is because glBlendEquationSeparateEXT		* cannot take GL_LOGIC_OP as a parameter.		*/	       if ( color->BlendEquationRGB == color->BlendEquationA ) {		  _mesa_BlendEquation(color->BlendEquationRGB);	       }	       else {		  _mesa_BlendEquationSeparateEXT(color->BlendEquationRGB,						 color->BlendEquationA);	       }               _mesa_BlendColor(color->BlendColor[0],                                color->BlendColor[1],                                color->BlendColor[2],                                color->BlendColor[3]);               _mesa_LogicOp(color->LogicOp);               _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP,                                color->ColorLogicOpEnabled);               _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP,                                color->IndexLogicOpEnabled);               _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag);            }            break;         case GL_CURRENT_BIT:	    FLUSH_CURRENT( ctx, 0 );            MEMCPY( &ctx->Current, attr->data,		    sizeof(struct gl_current_attrib) );            break;         case GL_DEPTH_BUFFER_BIT:            {               const struct gl_depthbuffer_attrib *depth;               depth = (const struct gl_depthbuffer_attrib *) attr->data;               _mesa_DepthFunc(depth->Func);               _mesa_ClearDepth(depth->Clear);               _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test);               _mesa_DepthMask(depth->Mask);            }            break;         case GL_ENABLE_BIT:            {               const struct gl_enable_attrib *enable;               enable = (const struct gl_enable_attrib *) attr->data;               pop_enable_group(ctx, enable);	       ctx->NewState |= _NEW_ALL;            }            break;         case GL_EVAL_BIT:            MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );	    ctx->NewState |= _NEW_EVAL;            break;         case GL_FOG_BIT:            {               const struct gl_fog_attrib *fog;               fog = (const struct gl_fog_attrib *) attr->data;               _mesa_set_enable(ctx, GL_FOG, fog->Enabled);               _mesa_Fogfv(GL_FOG_COLOR, fog->Color);               _mesa_Fogf(GL_FOG_DENSITY, fog->Density);               _mesa_Fogf(GL_FOG_START, fog->Start);               _mesa_Fogf(GL_FOG_END, fog->End);               _mesa_Fogf(GL_FOG_INDEX, fog->Index);               _mesa_Fogi(GL_FOG_MODE, fog->Mode);            }            break;         case GL_HINT_BIT:            {               const struct gl_hint_attrib *hint;               hint = (const struct gl_hint_attrib *) attr->data;               _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT,                          hint->PerspectiveCorrection );               _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth);               _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth);               _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth);               _mesa_Hint(GL_FOG_HINT, hint->Fog);               _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT,                          hint->ClipVolumeClipping);               if (ctx->Extensions.ARB_texture_compression)                  _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB,                             hint->TextureCompression);            }            break;         case GL_LIGHTING_BIT:            {               GLuint i;               const struct gl_light_attrib *light;               light = (const struct gl_light_attrib *) attr->data;               /* lighting enable */               _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled);               /* per-light state */               if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))                  _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );	                      for (i = 0; i < ctx->Const.MaxLights; i++) {		  const struct gl_light *l = &light->Light[i];                  _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled);		  _mesa_light(ctx, i, GL_AMBIENT, l->Ambient);		  _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse);		  _mesa_light(ctx, i, GL_SPECULAR, l->Specular );		  _mesa_light(ctx, i, GL_POSITION, l->EyePosition);		  _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->EyeDirection);		  _mesa_light(ctx, i, GL_SPOT_EXPONENT, &l->SpotExponent);		  _mesa_light(ctx, i, GL_SPOT_CUTOFF, &l->SpotCutoff);		  _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION,                              &l->ConstantAttenuation);		  _mesa_light(ctx, i, GL_LINEAR_ATTENUATION,                              &l->LinearAttenuation);		  _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION,                              &l->QuadraticAttenuation);               }               /* light model */               _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT,                                  light->Model.Ambient);               _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER,                                 (GLfloat) light->Model.LocalViewer);               _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE,                                 (GLfloat) light->Model.TwoSide);               _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL,                                 (GLfloat) light->Model.ColorControl);               /* shade model */               _mesa_ShadeModel(light->ShadeModel);               /* color material */               _mesa_ColorMaterial(light->ColorMaterialFace,                                   light->ColorMaterialMode);               _mesa_set_enable(ctx, GL_COLOR_MATERIAL,                                light->ColorMaterialEnabled);               /* materials */               MEMCPY(&ctx->Light.Material, &light->Material,                      sizeof(struct gl_material));            }            break;         case GL_LINE_BIT:            {               const struct gl_line_attrib *line;               line = (const struct gl_line_attrib *) attr->data;               _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag);               _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag);               _mesa_LineStipple(line->StippleFactor, line->StipplePattern);               _mesa_LineWidth(line->Width);            }            break;         case GL_LIST_BIT:            MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );            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);                  if (ctx->Extensions.NV_point_sprite)                     _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);                  }

⌨️ 快捷键说明

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