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

📄 sis6326_state.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
      sis6326UpdateSpecular(ctx);   }}static void sis6326DDShadeModel( GLcontext *ctx, GLenum mode ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */   smesa->hw_primitive = -1;}/* ============================================================= * Window position *//* ============================================================= * Viewport */static void sis6326CalcViewport( GLcontext *ctx ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   const GLfloat *v = ctx->Viewport._WindowMap.m;   GLfloat *m = smesa->hw_viewport;   /* See also sis_translate_vertex.    */   m[MAT_SX] =   v[MAT_SX];   m[MAT_TX] =   v[MAT_TX] + SUBPIXEL_X;   m[MAT_SY] = - v[MAT_SY];   m[MAT_TY] = - v[MAT_TY] + smesa->driDrawable->h + SUBPIXEL_Y;   m[MAT_SZ] =   v[MAT_SZ] * smesa->depth_scale;   m[MAT_TZ] =   v[MAT_TZ] * smesa->depth_scale;}static void sis6326DDViewport( GLcontext *ctx,			   GLint x, GLint y,			   GLsizei width, GLsizei height ){   sis6326CalcViewport( ctx );}static void sis6326DDDepthRange( GLcontext *ctx,			     GLclampd nearval, GLclampd farval ){   sis6326CalcViewport( ctx );}/* ============================================================= * Miscellaneous */static voidsis6326DDLogicOpCode( GLcontext *ctx, GLenum opcode ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   if (!ctx->Color.ColorLogicOpEnabled)      return;   current->hwDstSet &= ~MASK_ROP2;   switch (opcode)   {   case GL_CLEAR:      current->hwDstSet |= LOP_CLEAR;      break;   case GL_SET:      current->hwDstSet |= LOP_SET;      break;   case GL_COPY:      current->hwDstSet |= LOP_COPY;      break;   case GL_COPY_INVERTED:      current->hwDstSet |= LOP_COPY_INVERTED;      break;   case GL_NOOP:      current->hwDstSet |= LOP_NOOP;      break;   case GL_INVERT:      current->hwDstSet |= LOP_INVERT;      break;   case GL_AND:      current->hwDstSet |= LOP_AND;      break;   case GL_NAND:      current->hwDstSet |= LOP_NAND;      break;   case GL_OR:      current->hwDstSet |= LOP_OR;      break;   case GL_NOR:      current->hwDstSet |= LOP_NOR;      break;   case GL_XOR:      current->hwDstSet |= LOP_XOR;      break;   case GL_EQUIV:      current->hwDstSet |= LOP_EQUIV;      break;   case GL_AND_REVERSE:      current->hwDstSet |= LOP_AND_REVERSE;      break;   case GL_AND_INVERTED:      current->hwDstSet |= LOP_AND_INVERTED;      break;   case GL_OR_REVERSE:      current->hwDstSet |= LOP_OR_REVERSE;      break;   case GL_OR_INVERTED:      current->hwDstSet |= LOP_OR_INVERTED;      break;   }   if (current->hwDstSet != prev->hwDstSet) {      prev->hwDstSet = current->hwDstSet;      smesa->GlobalFlag |= GFLAG_DESTSETTING;   }}void sis6326DDDrawBuffer( GLcontext *ctx, GLenum mode ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   if(getenv("SIS_DRAW_FRONT"))      ctx->DrawBuffer->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT;   if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) {      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );      return;   }   current->hwDstSet &= ~MASK_DstBufferPitch;   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {   case BUFFER_FRONT_LEFT:      current->hwOffsetDest = smesa->front.offset;      current->hwDstSet |= smesa->front.pitch;      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );      break;   case BUFFER_BACK_LEFT:      current->hwOffsetDest = smesa->back.offset;      current->hwDstSet |= smesa->back.pitch;      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );      break;   default:      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );      return;   }   if (current->hwDstSet != prev->hwDstSet) {      prev->hwDstSet = current->hwDstSet;      smesa->GlobalFlag |= GFLAG_DESTSETTING;   }   if (current->hwOffsetDest != prev->hwOffsetDest) {      prev->hwOffsetDest = current->hwOffsetDest;      smesa->GlobalFlag |= GFLAG_DESTSETTING;   }}/* ============================================================= * Polygon stipple *//* ============================================================= * Render mode *//* ============================================================= * State enable/disable */static voidsis6326DDEnable( GLcontext *ctx, GLenum cap, GLboolean state ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *current = &smesa->current;   switch (cap)   {   case GL_ALPHA_TEST:      if (state)         current->hwCapEnable |= S_ENABLE_AlphaTest;      else         current->hwCapEnable &= ~S_ENABLE_AlphaTest;      break;   case GL_BLEND:      /* TODO: */      if (state)      /* if (state & !ctx->Color.ColorLogicOpEnabled) */         current->hwCapEnable |= S_ENABLE_Blend;      else         current->hwCapEnable &= ~S_ENABLE_Blend;      break;   case GL_CULL_FACE:      /* XXX culling */      break;   case GL_DEPTH_TEST:      if (state && smesa->depth.offset != 0)         current->hwCapEnable |= S_ENABLE_ZTest;      else         current->hwCapEnable &= ~S_ENABLE_ZTest;      sis6326DDDepthMask( ctx, ctx->Depth.Mask );      break;   case GL_DITHER:      if (state)         current->hwCapEnable |= S_ENABLE_Dither;      else         current->hwCapEnable &= ~S_ENABLE_Dither;      break;   case GL_FOG:      if (state)         current->hwCapEnable |= S_ENABLE_Fog;      else         current->hwCapEnable &= ~S_ENABLE_Fog;      break;   case GL_COLOR_LOGIC_OP:      if (state)         sis6326DDLogicOpCode( ctx, ctx->Color.LogicOp );      else         sis6326DDLogicOpCode( ctx, GL_COPY );      break;   case GL_SCISSOR_TEST:      sis6326UpdateClipping( ctx );      break;   case GL_STENCIL_TEST:      if (state) {         FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1);      } else {         FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0);      }      break;   case GL_LIGHTING:   case GL_COLOR_SUM_EXT:      sis6326UpdateSpecular(ctx);      break;    }}/* ============================================================= * State initialization, management *//* Called before beginning of rendering. */voidsis6326UpdateHWState( GLcontext *ctx ){   sisContextPtr smesa = SIS_CONTEXT(ctx);   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   if (smesa->NewGLState & _NEW_TEXTURE)      sisUpdateTextureState( ctx );   if (current->hwCapEnable ^ prev->hwCapEnable) {      prev->hwCapEnable = current->hwCapEnable;      smesa->GlobalFlag |= GFLAG_ENABLESETTING;   }   if (smesa->GlobalFlag & GFLAG_RENDER_STATES)      sis_update_render_state( smesa );   if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES)      sis_update_texture_state( smesa );}static voidsis6326DDInvalidateState( GLcontext *ctx, GLuint new_state ){	sisContextPtr smesa = SIS_CONTEXT(ctx);	_swrast_InvalidateState( ctx, new_state );	_swsetup_InvalidateState( ctx, new_state );	_vbo_InvalidateState( ctx, new_state );	_tnl_InvalidateState( ctx, new_state );	smesa->NewGLState |= new_state;}/* Initialize the context's hardware state. */void sis6326DDInitState( sisContextPtr smesa ){   __GLSiSHardware *prev = &smesa->prev;   __GLSiSHardware *current = &smesa->current;   GLcontext *ctx = smesa->glCtx;   /* add Texture Perspective Enable */   current->hwCapEnable = S_ENABLE_TextureCache |       S_ENABLE_TexturePerspective | S_ENABLE_Dither;   /* Z test mode is LESS */   current->hwZ = S_ZSET_PASS_LESS | S_ZSET_FORMAT_16;   if (ctx->Visual.depthBits > 0)      current->hwCapEnable |= S_ENABLE_ZWrite;   /* Alpha test mode is ALWAYS, alpha ref value is 0 */   current->hwAlpha = S_ASET_PASS_ALWAYS;   /* ROP2 is COPYPEN */   current->hwDstSet = LOP_COPY;   /* LinePattern is 0, Repeat Factor is 0 */   current->hwLinePattern = 0x00008000;   /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */   current->hwDstSrcBlend = S_SBLEND_ONE | S_DBLEND_ZERO;      switch (smesa->bytesPerPixel)   {   case 2:      current->hwDstSet |= DST_FORMAT_RGB_565;      break;   case 4:      current->hwDstSet |= DST_FORMAT_ARGB_8888;      break;   }   smesa->depth_scale = 1.0 / (GLfloat)0xffff;   smesa->clearTexCache = GL_TRUE;   smesa->clearColorPattern = 0;   sis6326UpdateZPattern(smesa, 1.0);   sis6326UpdateCull(ctx);   /* Set initial fog settings. Start and end are the same case.  */   sis6326DDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );   sis6326DDFogfv( ctx, GL_FOG_END, &ctx->Fog.End );   sis6326DDFogfv( ctx, GL_FOG_MODE, NULL );   memcpy(prev, current, sizeof(__GLSiSHardware));}/* Initialize the driver's state functions. */void sis6326DDInitStateFuncs( GLcontext *ctx ){   ctx->Driver.UpdateState		= sis6326DDInvalidateState;   ctx->Driver.Clear			= sis6326DDClear;   ctx->Driver.ClearColor		= sis6326DDClearColor;   ctx->Driver.ClearDepth		= sis6326DDClearDepth;   ctx->Driver.AlphaFunc		= sis6326DDAlphaFunc;   ctx->Driver.BlendFuncSeparate	= sis6326DDBlendFuncSeparate;   ctx->Driver.ColorMask		= sis6326DDColorMask;   ctx->Driver.CullFace			= sis6326DDCullFace;   ctx->Driver.DepthMask		= sis6326DDDepthMask;   ctx->Driver.DepthFunc		= sis6326DDDepthFunc;   ctx->Driver.DepthRange		= sis6326DDDepthRange;   ctx->Driver.DrawBuffer		= sis6326DDDrawBuffer;   ctx->Driver.Enable			= sis6326DDEnable;   ctx->Driver.FrontFace	 	= sis6326DDFrontFace;   ctx->Driver.Fogfv			= sis6326DDFogfv;   ctx->Driver.LogicOpcode	 	= sis6326DDLogicOpCode;   ctx->Driver.Scissor			= sis6326DDScissor;   ctx->Driver.ShadeModel		= sis6326DDShadeModel;   ctx->Driver.LightModelfv		= sis6326DDLightModelfv;   ctx->Driver.Viewport			= sis6326DDViewport;}

⌨️ 快捷键说明

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