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

📄 texstate.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
}void GLAPIENTRY_mesa_GetTexLevelParameterfv( GLenum target, GLint level,                              GLenum pname, GLfloat *params ){   GLint iparam;   _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );   *params = (GLfloat) iparam;}static GLuinttex_image_dimensions(GLcontext *ctx, GLenum target){   switch (target) {      case GL_TEXTURE_1D:      case GL_PROXY_TEXTURE_1D:         return 1;      case GL_TEXTURE_2D:      case GL_PROXY_TEXTURE_2D:         return 2;      case GL_TEXTURE_3D:      case GL_PROXY_TEXTURE_3D:         return 3;      case GL_TEXTURE_CUBE_MAP:      case GL_PROXY_TEXTURE_CUBE_MAP:      case GL_TEXTURE_CUBE_MAP_POSITIVE_X:      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:         return ctx->Extensions.ARB_texture_cube_map ? 2 : 0;      case GL_TEXTURE_RECTANGLE_NV:      case GL_PROXY_TEXTURE_RECTANGLE_NV:         return ctx->Extensions.NV_texture_rectangle ? 2 : 0;      case GL_TEXTURE_1D_ARRAY_EXT:      case GL_PROXY_TEXTURE_1D_ARRAY_EXT:         return ctx->Extensions.MESA_texture_array ? 2 : 0;      case GL_TEXTURE_2D_ARRAY_EXT:      case GL_PROXY_TEXTURE_2D_ARRAY_EXT:         return ctx->Extensions.MESA_texture_array ? 3 : 0;      default:         _mesa_problem(ctx, "bad target in _mesa_tex_target_dimensions()");         return 0;   }}void GLAPIENTRY_mesa_GetTexLevelParameteriv( GLenum target, GLint level,                              GLenum pname, GLint *params ){   const struct gl_texture_unit *texUnit;   struct gl_texture_object *texObj;   const struct gl_texture_image *img = NULL;   GLuint dimensions;   GLboolean isProxy;   GLint maxLevels;   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END(ctx);   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) {      _mesa_error(ctx, GL_INVALID_OPERATION,                  "glGetTexLevelParameteriv(current unit)");      return;   }   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   /* this will catch bad target values */   dimensions = tex_image_dimensions(ctx, target);  /* 1, 2 or 3 */   if (dimensions == 0) {      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");      return;   }   maxLevels = _mesa_max_texture_levels(ctx, target);   if (maxLevels == 0) {      /* should not happen since <target> was just checked above */      _mesa_problem(ctx, "maxLevels=0 in _mesa_GetTexLevelParameter");      return;   }   if (level < 0 || level >= maxLevels) {      _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );      return;   }   texObj = _mesa_select_tex_object(ctx, texUnit, target);   _mesa_lock_texture(ctx, texObj);   img = _mesa_select_tex_image(ctx, texObj, target, level);   if (!img || !img->TexFormat) {      /* undefined texture image */      if (pname == GL_TEXTURE_COMPONENTS)         *params = 1;      else         *params = 0;      goto out;   }   isProxy = _mesa_is_proxy_texture(target);   switch (pname) {      case GL_TEXTURE_WIDTH:         *params = img->Width;         break;      case GL_TEXTURE_HEIGHT:         *params = img->Height;         break;      case GL_TEXTURE_DEPTH:         *params = img->Depth;         break;      case GL_TEXTURE_INTERNAL_FORMAT:         *params = img->InternalFormat;         break;      case GL_TEXTURE_BORDER:         *params = img->Border;         break;      case GL_TEXTURE_RED_SIZE:         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)            *params = img->TexFormat->RedBits;         else            *params = 0;         break;      case GL_TEXTURE_GREEN_SIZE:         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)            *params = img->TexFormat->GreenBits;         else            *params = 0;         break;      case GL_TEXTURE_BLUE_SIZE:         if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA)            *params = img->TexFormat->BlueBits;         else            *params = 0;         break;      case GL_TEXTURE_ALPHA_SIZE:         if (img->_BaseFormat == GL_ALPHA ||             img->_BaseFormat == GL_LUMINANCE_ALPHA ||             img->_BaseFormat == GL_RGBA)            *params = img->TexFormat->AlphaBits;         else            *params = 0;         break;      case GL_TEXTURE_INTENSITY_SIZE:         if (img->_BaseFormat != GL_INTENSITY)            *params = 0;         else if (img->TexFormat->IntensityBits > 0)            *params = img->TexFormat->IntensityBits;         else /* intensity probably stored as rgb texture */            *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);         break;      case GL_TEXTURE_LUMINANCE_SIZE:         if (img->_BaseFormat != GL_LUMINANCE &&             img->_BaseFormat != GL_LUMINANCE_ALPHA)            *params = 0;         else if (img->TexFormat->LuminanceBits > 0)            *params = img->TexFormat->LuminanceBits;         else /* luminance probably stored as rgb texture */            *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);         break;      case GL_TEXTURE_INDEX_SIZE_EXT:         if (img->_BaseFormat == GL_COLOR_INDEX)            *params = img->TexFormat->IndexBits;         else            *params = 0;         break;      case GL_TEXTURE_DEPTH_SIZE_ARB:         if (ctx->Extensions.SGIX_depth_texture ||             ctx->Extensions.ARB_depth_texture)            *params = img->TexFormat->DepthBits;         else            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         break;      case GL_TEXTURE_STENCIL_SIZE_EXT:         if (ctx->Extensions.EXT_packed_depth_stencil) {            *params = img->TexFormat->StencilBits;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      /* GL_ARB_texture_compression */      case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:         if (ctx->Extensions.ARB_texture_compression) {            if (img->IsCompressed && !isProxy) {               /* Don't use ctx->Driver.CompressedTextureSize() since that                * may returned a padded hardware size.                */               *params = _mesa_compressed_texture_size(ctx, img->Width,                                                   img->Height, img->Depth,                                                   img->TexFormat->MesaFormat);            }            else {               _mesa_error(ctx, GL_INVALID_OPERATION,                           "glGetTexLevelParameter[if]v(pname)");            }         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_COMPRESSED:         if (ctx->Extensions.ARB_texture_compression) {            *params = (GLint) img->IsCompressed;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      /* GL_ARB_texture_float */      case GL_TEXTURE_RED_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->RedBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_GREEN_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->GreenBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_BLUE_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->BlueBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_ALPHA_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->AlphaBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_LUMINANCE_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->LuminanceBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_INTENSITY_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->IntensityBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      case GL_TEXTURE_DEPTH_TYPE_ARB:         if (ctx->Extensions.ARB_texture_float) {            *params = img->TexFormat->DepthBits ? img->TexFormat->DataType : GL_NONE;         }         else {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetTexLevelParameter[if]v(pname)");         }         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM,                     "glGetTexLevelParameter[if]v(pname)");   } out:   _mesa_unlock_texture(ctx, texObj);}void GLAPIENTRY_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ){   struct gl_texture_unit *texUnit;   struct gl_texture_object *obj;   GLboolean error = GL_FALSE;   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END(ctx);   if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureImageUnits) {      _mesa_error(ctx, GL_INVALID_OPERATION,                  "glGetTexParameterfv(current unit)");      return;   }   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   obj = _mesa_select_tex_object(ctx, texUnit, target);   if (!obj) {      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");      return;   }   _mesa_lock_texture(ctx, obj);   switch (pname) {      case GL_TEXTURE_MAG_FILTER:	 *params = ENUM_TO_FLOAT(obj->MagFilter);	 break;      case GL_TEXTURE_MIN_FILTER:         *params = ENUM_TO_FLOAT(obj->MinFilter);         break;      case GL_TEXTURE_WRAP_S:         *params = ENUM_TO_FLOAT(obj->WrapS);         break;      case GL_TEXTURE_WRAP_T:         *params = ENUM_TO_FLOAT(obj->WrapT);         break;      case GL_TEXTURE_WRAP_R:         *params = ENUM_TO_FLOAT(obj->WrapR);         break;      case GL_TEXTURE_BORDER_COLOR:         params[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);         params[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);         params[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);         params[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);         break;      case GL_TEXTURE_RESIDENT:         {            GLboolean resident;            if (ctx->Driver.IsTextureResident)               resident = ctx->Driver.IsTextureResident(ctx, obj);            else               resident = GL_TRUE;            *params = ENUM_TO_FLOAT(resident);         }         break;      case GL_TEXTURE_PRIORITY:         *params = obj->Priority;         break;      case GL_TEXTURE_MIN_LOD:         *params = obj->MinLod;         break;      case GL_TEXTURE_MAX_LOD:         *params = obj->MaxLod;         break;      case GL_TEXTURE_BASE_LEVEL:         *params = (GLfloat) obj->BaseLevel;         break;      case GL_TEXTURE_MAX_LEVEL:         *params = (GLfloat) obj->MaxLevel;         break;      case GL_TEXTURE_MAX_ANISOTROPY_EXT:         if (ctx->Extensions.EXT_texture_filter_anisotropic) {            *params = obj->MaxAnisotropy;         }	 else	    error = 1;         break;      case GL_TEXTURE_COMPARE_SGIX:         if (ctx->Extensions.SGIX_shadow) {            *params = (GLfloat) obj->CompareFlag;         }	 else 	    error = 1;         break;      case GL_TEXTURE_COMPARE_OPERATOR_SGIX:         if (ctx->Extensions.S

⌨️ 快捷键说明

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