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

📄 mgatex.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 2000-2001 VA Linux Systems, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * on the rights to use, copy, modify, merge, publish, distribute, sub * license, and/or sell copies of the Software, and to permit persons to whom * the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: *    Keith Whitwell <keith@tungstengraphics.com> *//* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.c,v 1.14 2002/10/30 12:51:36 alanh Exp $ */#include "glheader.h"#include "mm.h"#include "mgacontext.h"#include "mgatex.h"#include "mgaregs.h"#include "mgatris.h"#include "mgaioctl.h"#include "colormac.h"#include "context.h"#include "enums.h"#include "simple_list.h"#include "imports.h"#include "macros.h"#include "texformat.h"#include "texstore.h"#include "teximage.h"#include "texobj.h"#include "swrast/swrast.h"#include "xmlpool.h"/** * Set the texture wrap modes. * Currently \c GL_REPEAT, \c GL_CLAMP and \c GL_CLAMP_TO_EDGE are supported. *  * \param t Texture object whose wrap modes are to be set * \param swrap Wrap mode for the \a s texture coordinate * \param twrap Wrap mode for the \a t texture coordinate */static void mgaSetTexWrapping( mgaTextureObjectPtr t, GLenum swrap, GLenum twrap ){   GLboolean  is_clamp = GL_FALSE;   GLboolean  is_clamp_to_edge = GL_FALSE;   t->setup.texctl &= (TMC_clampu_MASK & TMC_clampv_MASK);   t->setup.texctl2 &= (TMC_borderen_MASK);   switch( swrap ) {   case GL_REPEAT:      break;   case GL_CLAMP:      t->setup.texctl |= TMC_clampu_enable;      is_clamp = GL_TRUE;      break;   case GL_CLAMP_TO_EDGE:      t->setup.texctl |= TMC_clampu_enable;      is_clamp_to_edge = GL_TRUE;      break;   default:      _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);   }   switch( twrap ) {   case GL_REPEAT:      break;   case GL_CLAMP:      t->setup.texctl |= TMC_clampv_enable;      is_clamp = GL_TRUE;      break;   case GL_CLAMP_TO_EDGE:      t->setup.texctl |= TMC_clampv_enable;      is_clamp_to_edge = GL_TRUE;      break;   default:      _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);   }   if ( is_clamp ) {      t->setup.texctl2 |= TMC_borderen_enable;   }   t->border_fallback = (is_clamp && is_clamp_to_edge);}/** * Set the texture magnification and minification modes. *  * \param t Texture whose filter modes are to be set * \param minf Texture minification mode * \param magf Texture magnification mode */static voidmgaSetTexFilter( mgaTextureObjectPtr t, GLenum minf, GLenum magf ){   GLuint val = 0;   switch (minf) {   case GL_NEAREST: val = TF_minfilter_nrst; break;   case GL_LINEAR: val = TF_minfilter_bilin; break;   case GL_NEAREST_MIPMAP_NEAREST: val = TF_minfilter_mm1s; break;   case GL_LINEAR_MIPMAP_NEAREST: val = TF_minfilter_mm4s; break;   case GL_NEAREST_MIPMAP_LINEAR: val = TF_minfilter_mm2s; break;   case GL_LINEAR_MIPMAP_LINEAR: val = TF_minfilter_mm8s; break;   default: val = TF_minfilter_nrst; break;   }   switch (magf) {   case GL_NEAREST: val |= TF_magfilter_nrst; break;   case GL_LINEAR: val |= TF_magfilter_bilin; break;   default: val |= TF_magfilter_nrst; break;   }   /* See OpenGL 1.2 specification */   if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||			     minf == GL_NEAREST_MIPMAP_LINEAR)) {      val |= MGA_FIELD( TF_fthres, 0x20 ); /* c = 0.5 */   } else {      val |= MGA_FIELD( TF_fthres, 0x10 ); /* c = 0 */   }   /* Mask off the bits for the fields we are setting.  Remember, the MGA mask    * defines have 0s for the bits in the named fields.  This is the opposite    * of most of the other drivers.    */   t->setup.texfilter &= (TF_minfilter_MASK &			  TF_magfilter_MASK &			  TF_fthres_MASK);   t->setup.texfilter |= val;}static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]){   t->setup.texbordercol = PACK_COLOR_8888(color[3], color[0], 					   color[1], color[2] );}static const struct gl_texture_format *mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,		        GLenum format, GLenum type ){   mgaContextPtr mmesa = MGA_CONTEXT(ctx);   const GLboolean do32bpt =       ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );   const GLboolean force16bpt =       ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );   (void) format;   switch ( internalFormat ) {   case 4:   case GL_RGBA:   case GL_COMPRESSED_RGBA:      switch ( type ) {      case GL_UNSIGNED_INT_10_10_10_2:      case GL_UNSIGNED_INT_2_10_10_10_REV:	 return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;      case GL_UNSIGNED_SHORT_4_4_4_4:      case GL_UNSIGNED_SHORT_4_4_4_4_REV:	 return &_mesa_texformat_argb4444;      case GL_UNSIGNED_SHORT_5_5_5_1:      case GL_UNSIGNED_SHORT_1_5_5_5_REV:	 return &_mesa_texformat_argb1555;      default:         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;      }   case 3:   case GL_RGB:   case GL_COMPRESSED_RGB:      switch ( type ) {      case GL_UNSIGNED_SHORT_4_4_4_4:      case GL_UNSIGNED_SHORT_4_4_4_4_REV:	 return &_mesa_texformat_argb4444;      case GL_UNSIGNED_SHORT_5_5_5_1:      case GL_UNSIGNED_SHORT_1_5_5_5_REV:	 return &_mesa_texformat_argb1555;      case GL_UNSIGNED_SHORT_5_6_5:      case GL_UNSIGNED_SHORT_5_6_5_REV:	 return &_mesa_texformat_rgb565;      default:         return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;      }   case GL_RGBA8:   case GL_RGB10_A2:   case GL_RGBA12:   case GL_RGBA16:      return !force16bpt ?	  &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;   case GL_RGBA4:   case GL_RGBA2:      return &_mesa_texformat_argb4444;   case GL_RGB5_A1:      return &_mesa_texformat_argb1555;   case GL_RGB8:   case GL_RGB10:   case GL_RGB12:   case GL_RGB16:      return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;   case GL_RGB5:   case GL_RGB4:   case GL_R3_G3_B2:      return &_mesa_texformat_rgb565;   case GL_ALPHA:   case GL_ALPHA4:   case GL_ALPHA8:   case GL_ALPHA12:   case GL_ALPHA16:   case GL_COMPRESSED_ALPHA:      /* FIXME: This will report incorrect component sizes... */      return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;   case 1:   case GL_LUMINANCE:   case GL_LUMINANCE4:   case GL_LUMINANCE8:   case GL_LUMINANCE12:   case GL_LUMINANCE16:   case GL_COMPRESSED_LUMINANCE:      /* FIXME: This will report incorrect component sizes... */      return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_rgb565;   case 2:   case GL_LUMINANCE_ALPHA:   case GL_LUMINANCE4_ALPHA4:   case GL_LUMINANCE6_ALPHA2:   case GL_LUMINANCE8_ALPHA8:   case GL_LUMINANCE12_ALPHA4:   case GL_LUMINANCE12_ALPHA12:   case GL_LUMINANCE16_ALPHA16:   case GL_COMPRESSED_LUMINANCE_ALPHA:      /* FIXME: This will report incorrect component sizes... */      return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;   case GL_INTENSITY:   case GL_INTENSITY4:   case GL_INTENSITY8:   case GL_INTENSITY12:   case GL_INTENSITY16:   case GL_COMPRESSED_INTENSITY:

⌨️ 快捷键说明

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