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

📄 state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 4 页
字号:
    *   1. OpenGL 2.0/ARB vertex/fragment shaders    *   2. ARB/NV vertex/fragment programs    *   3. Programs derived from fixed-function state.    */   _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);   if (shProg && shProg->LinkStatus) {      /* Use shader programs */      /* XXX this isn't quite right, since we may have either a vertex       * _or_ fragment shader (not always both).       */      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,                               shProg->VertexProgram);      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,                               shProg->FragmentProgram);   }   else {      if (ctx->VertexProgram._Enabled) {         /* use user-defined vertex program */         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,                                  ctx->VertexProgram.Current);      }      else if (ctx->VertexProgram._MaintainTnlProgram) {         /* Use vertex program generated from fixed-function state.          * The _Current pointer will get set in          * _tnl_UpdateFixedFunctionProgram() later if appropriate.          */         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);      }      else {         /* no vertex program */         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);      }      if (ctx->FragmentProgram._Enabled) {         /* use user-defined vertex program */         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,                                  ctx->FragmentProgram.Current);      }      else if (ctx->FragmentProgram._MaintainTexEnvProgram) {         /* Use fragment program generated from fixed-function state.          * The _Current pointer will get set in _mesa_UpdateTexEnvProgram()          * later if appropriate.          */         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);      }      else {         /* no fragment program */         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);      }   }   if (ctx->VertexProgram._Current)      assert(ctx->VertexProgram._Current->Base.Parameters);   if (ctx->FragmentProgram._Current)      assert(ctx->FragmentProgram._Current->Base.Parameters);   ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;   if (ctx->FragmentProgram._MaintainTexEnvProgram &&       !ctx->FragmentProgram._Enabled) {      if (ctx->FragmentProgram._UseTexEnvProgram)	 ctx->FragmentProgram._Active = GL_TRUE;   }}static voidupdate_viewport_matrix(GLcontext *ctx){   const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;   ASSERT(depthMax > 0);   /* Compute scale and bias values. This is really driver-specific    * and should be maintained elsewhere if at all.    * NOTE: RasterPos uses this.    */   _math_matrix_viewport(&ctx->Viewport._WindowMap,                         ctx->Viewport.X, ctx->Viewport.Y,                         ctx->Viewport.Width, ctx->Viewport.Height,                         ctx->Viewport.Near, ctx->Viewport.Far,                         depthMax);}/** * Update derived multisample state. */static voidupdate_multisample(GLcontext *ctx){   ctx->Multisample._Enabled = GL_FALSE;   if (ctx->Multisample.Enabled &&       ctx->DrawBuffer &&       ctx->DrawBuffer->Visual.sampleBuffers)      ctx->Multisample._Enabled = GL_TRUE;}/** * Update derived color/blend/logicop state. */static voidupdate_color(GLcontext *ctx){   /* This is needed to support 1.1's RGB logic ops AND    * 1.0's blending logicops.    */   ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx);}/* * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET * in ctx->_TriangleCaps if needed. */static voidupdate_polygon(GLcontext *ctx){   ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET);   if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)      ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;   if (   ctx->Polygon.OffsetPoint       || ctx->Polygon.OffsetLine       || ctx->Polygon.OffsetFill)      ctx->_TriangleCaps |= DD_TRI_OFFSET;}/** * Update the ctx->_TriangleCaps bitfield. * XXX that bitfield should really go away someday! * This function must be called after other update_*() functions since * there are dependencies on some other derived values. */#if 0static voidupdate_tricaps(GLcontext *ctx, GLbitfield new_state){   ctx->_TriangleCaps = 0;   /*    * Points    */   if (1/*new_state & _NEW_POINT*/) {      if (ctx->Point.SmoothFlag)         ctx->_TriangleCaps |= DD_POINT_SMOOTH;      if (ctx->Point.Size != 1.0F)         ctx->_TriangleCaps |= DD_POINT_SIZE;      if (ctx->Point._Attenuated)         ctx->_TriangleCaps |= DD_POINT_ATTEN;   }   /*    * Lines    */   if (1/*new_state & _NEW_LINE*/) {      if (ctx->Line.SmoothFlag)         ctx->_TriangleCaps |= DD_LINE_SMOOTH;      if (ctx->Line.StippleFlag)         ctx->_TriangleCaps |= DD_LINE_STIPPLE;      if (ctx->Line.Width != 1.0)         ctx->_TriangleCaps |= DD_LINE_WIDTH;   }   /*    * Polygons    */   if (1/*new_state & _NEW_POLYGON*/) {      if (ctx->Polygon.SmoothFlag)         ctx->_TriangleCaps |= DD_TRI_SMOOTH;      if (ctx->Polygon.StippleFlag)         ctx->_TriangleCaps |= DD_TRI_STIPPLE;      if (ctx->Polygon.FrontMode != GL_FILL          || ctx->Polygon.BackMode != GL_FILL)         ctx->_TriangleCaps |= DD_TRI_UNFILLED;      if (ctx->Polygon.CullFlag          && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)         ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;      if (ctx->Polygon.OffsetPoint ||          ctx->Polygon.OffsetLine ||          ctx->Polygon.OffsetFill)         ctx->_TriangleCaps |= DD_TRI_OFFSET;   }   /*    * Lighting and shading    */   if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)      ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;   if (ctx->Light.ShadeModel == GL_FLAT)      ctx->_TriangleCaps |= DD_FLATSHADE;   if (NEED_SECONDARY_COLOR(ctx))      ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;   /*    * Stencil    */   if (ctx->Stencil._TestTwoSide)      ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;}#endif/** * Compute derived GL state. * If __GLcontextRec::NewState is non-zero then this function \b must * be called before rendering anything. * * Calls dd_function_table::UpdateState to perform any internal state * management necessary. *  * \sa _mesa_update_modelview_project(), _mesa_update_texture(), * _mesa_update_buffer_bounds(), * _mesa_update_lighting() and _mesa_update_tnl_spaces(). */void_mesa_update_state_locked( GLcontext *ctx ){   GLbitfield new_state = ctx->NewState;   if (MESA_VERBOSE & VERBOSE_STATE)      _mesa_print_state("_mesa_update_state", new_state);   if (new_state & _NEW_PROGRAM)      update_program( ctx );   if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))      _mesa_update_modelview_project( ctx, new_state );   if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))      _mesa_update_texture( ctx, new_state );   if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))      _mesa_update_framebuffer(ctx);   if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))      _mesa_update_draw_buffer_bounds( ctx );   if (new_state & _NEW_POLYGON)      update_polygon( ctx );   if (new_state & _NEW_LIGHT)      _mesa_update_lighting( ctx );   if (new_state & _NEW_STENCIL)      _mesa_update_stencil( ctx );   if (new_state & _IMAGE_NEW_TRANSFER_STATE)      _mesa_update_pixel( ctx, new_state );   if (new_state & _DD_NEW_SEPARATE_SPECULAR)      update_separate_specular( ctx );   if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))      update_arrays( ctx );   if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT))      update_viewport_matrix(ctx);   if (new_state & _NEW_MULTISAMPLE)      update_multisample( ctx );   if (new_state & _NEW_COLOR)      update_color( ctx );#if 0   if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT                    | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))      update_tricaps( ctx, new_state );#endif   if (ctx->FragmentProgram._MaintainTexEnvProgram) {      if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))	 _mesa_UpdateTexEnvProgram(ctx);   }   /* ctx->_NeedEyeCoords is now up to date.    *    * If the truth value of this variable has changed, update for the    * new lighting space and recompute the positions of lights and the    * normal transform.    *    * If the lighting space hasn't changed, may still need to recompute    * light positions & normal transforms for other reasons.    */   if (new_state & _MESA_NEW_NEED_EYE_COORDS)       _mesa_update_tnl_spaces( ctx, new_state );   /*    * Give the driver a chance to act upon the new_state flags.    * The driver might plug in different span functions, for example.    * Also, this is where the driver can invalidate the state of any    * active modules (such as swrast_setup, swrast, tnl, etc).    *    * Set ctx->NewState to zero to avoid recursion if    * Driver.UpdateState() has to call FLUSH_VERTICES().  (fixed?)    */   new_state = ctx->NewState;   ctx->NewState = 0;   ctx->Driver.UpdateState(ctx, new_state);   ctx->Array.NewState = 0;}/* This is the usual entrypoint for state updates: */void_mesa_update_state( GLcontext *ctx ){   _mesa_lock_context_textures(ctx);   _mesa_update_state_locked(ctx);   _mesa_unlock_context_textures(ctx);}/*@}*/

⌨️ 快捷键说明

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