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

📄 mgatex.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
      /* FIXME: This will report incorrect component sizes... */      return MGA_IS_G400(mmesa) ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;   case GL_YCBCR_MESA:      if (MGA_IS_G400(mmesa) &&          (type == GL_UNSIGNED_SHORT_8_8_APPLE ||           type == GL_UNSIGNED_BYTE))         return &_mesa_texformat_ycbcr;      else         return &_mesa_texformat_ycbcr_rev;   case GL_COLOR_INDEX:   case GL_COLOR_INDEX1_EXT:   case GL_COLOR_INDEX2_EXT:   case GL_COLOR_INDEX4_EXT:   case GL_COLOR_INDEX8_EXT:   case GL_COLOR_INDEX12_EXT:   case GL_COLOR_INDEX16_EXT:      return &_mesa_texformat_ci8;   default:      _mesa_problem( ctx, "unexpected texture format in %s", __FUNCTION__ );      return NULL;   }   return NULL; /* never get here */}/** * Allocate space for and load the mesa images into the texture memory block. * This will happen before drawing with a new texture, or drawing with a * texture after it was swapped out or teximaged again. */static mgaTextureObjectPtrmgaAllocTexObj( struct gl_texture_object *tObj ){   mgaTextureObjectPtr t;   t = CALLOC( sizeof( *t ) );   tObj->DriverData = t;   if ( t != NULL ) {      /* Initialize non-image-dependent parts of the state:       */      t->base.tObj = tObj;      t->setup.texctl = TMC_takey_1 | TMC_tamask_0;      t->setup.texctl2 = TMC_ckstransdis_enable;      t->setup.texfilter = TF_filteralpha_enable | TF_uvoffset_OGL;      t->border_fallback = GL_FALSE;      t->texenv_fallback = GL_FALSE;      make_empty_list( & t->base );      mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );      mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );      mgaSetTexBorderColor( t, tObj->_BorderChan );   }   return( t );}static void mgaTexEnv( GLcontext *ctx, GLenum target,			 GLenum pname, const GLfloat *param ){   GLuint unit = ctx->Texture.CurrentUnit;   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];   mgaContextPtr mmesa = MGA_CONTEXT(ctx);   switch( pname ) {   case GL_TEXTURE_ENV_COLOR: {      GLubyte c[4];      UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );      mmesa->envcolor[unit] = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );      break;   }   }}static void mgaTexImage2D( GLcontext *ctx, GLenum target, GLint level,			    GLint internalFormat,			    GLint width, GLint height, GLint border,			    GLenum format, GLenum type, const GLvoid *pixels,			    const struct gl_pixelstore_attrib *packing,			    struct gl_texture_object *texObj,			    struct gl_texture_image *texImage ){   driTextureObject * t = (driTextureObject *) texObj->DriverData;   if ( t != NULL ) {      driSwapOutTextureObject( t );   }    else {      t = (driTextureObject *) mgaAllocTexObj( texObj );      if ( t == NULL ) {	 _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" );	 return;      }   }   _mesa_store_teximage2d( ctx, target, level, internalFormat,			   width, height, border, format, type,			   pixels, packing, texObj, texImage );   level -= t->firstLevel;   if (level >= 0)      t->dirty_images[0] |= (1UL << level);}static void mgaTexSubImage2D( GLcontext *ctx, 			       GLenum target,			       GLint level,				       GLint xoffset, GLint yoffset,			       GLsizei width, GLsizei height,			       GLenum format, GLenum type,			       const GLvoid *pixels,			       const struct gl_pixelstore_attrib *packing,			       struct gl_texture_object *texObj,			       struct gl_texture_image *texImage ){   driTextureObject * t = (driTextureObject *) texObj->DriverData;   assert( t ); /* this _should_ be true */   if ( t != NULL ) {      driSwapOutTextureObject( t );   }    else {      t = (driTextureObject *) mgaAllocTexObj( texObj );      if ( t == NULL ) {	 _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" );	 return;      }   }   _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, 			     height, format, type, pixels, packing, texObj,			     texImage);   level -= t->firstLevel;   if (level >= 0)      t->dirty_images[0] |= (1UL << level);}/** * Changes variables and flags for a state update, which will happen at the * next UpdateTextureState */static voidmgaTexParameter( GLcontext *ctx, GLenum target,		   struct gl_texture_object *tObj,		   GLenum pname, const GLfloat *params ){   mgaContextPtr mmesa = MGA_CONTEXT( ctx );   mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;   /* If we don't have a hardware texture, it will be automatically    * created with current state before it is used, so we don't have    * to do anything now     */   if ( (t == NULL) ||        (target != GL_TEXTURE_2D &&         target != GL_TEXTURE_RECTANGLE_NV) ) {      return;   }   switch (pname) {   case GL_TEXTURE_MIN_FILTER:      driSwapOutTextureObject( (driTextureObject *) t );      /* FALLTHROUGH */   case GL_TEXTURE_MAG_FILTER:      FLUSH_BATCH(mmesa);      mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );      break;   case GL_TEXTURE_WRAP_S:   case GL_TEXTURE_WRAP_T:      FLUSH_BATCH(mmesa);      mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT);      break;   case GL_TEXTURE_BORDER_COLOR:      FLUSH_BATCH(mmesa);      mgaSetTexBorderColor(t, tObj->_BorderChan);      break;   case GL_TEXTURE_BASE_LEVEL:   case GL_TEXTURE_MAX_LEVEL:   case GL_TEXTURE_MIN_LOD:   case GL_TEXTURE_MAX_LOD:      /* This isn't the most efficient solution but there doesn't appear to       * be a nice alternative.  Since there's no LOD clamping,       * we just have to rely on loading the right subset of mipmap levels       * to simulate a clamped LOD.       */      driSwapOutTextureObject( (driTextureObject *) t );      break;   default:      return;   }}static voidmgaBindTexture( GLcontext *ctx, GLenum target,		  struct gl_texture_object *tObj ){   assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ||           (tObj->DriverData != NULL) );}static voidmgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ){   mgaContextPtr mmesa = MGA_CONTEXT( ctx );   driTextureObject * t = (driTextureObject *) tObj->DriverData;   if ( t ) {      if ( mmesa ) {	 FLUSH_BATCH( mmesa );      }      driDestroyTextureObject( t );   }   /* Free mipmap images and the texture object itself */   _mesa_delete_texture_object(ctx, tObj);}/** * Allocate a new texture object. * Called via ctx->Driver.NewTextureObject. * Note: this function will be called during context creation to * allocate the default texture objects. * Note: we could use containment here to 'derive' the driver-specific * texture object from the core mesa gl_texture_object.  Not done at this time. */static struct gl_texture_object *mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ){   struct gl_texture_object *obj;   obj = _mesa_new_texture_object(ctx, name, target);   mgaAllocTexObj( obj );   return obj;}voidmgaInitTextureFuncs( struct dd_function_table *functions ){   functions->ChooseTextureFormat	= mgaChooseTextureFormat;   functions->TexImage2D		= mgaTexImage2D;   functions->TexSubImage2D		= mgaTexSubImage2D;   functions->BindTexture		= mgaBindTexture;   functions->NewTextureObject		= mgaNewTextureObject;   functions->DeleteTexture		= mgaDeleteTexture;   functions->IsTextureResident		= driIsTextureResident;   functions->TexEnv			= mgaTexEnv;   functions->TexParameter		= mgaTexParameter;}

⌨️ 快捷键说明

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