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

📄 texformat_tmp.h

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 H
📖 第 1 页 / 共 4 页
字号:
/* MESA_FORMAT_RGB888 ********************************************************//* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */static void FETCH(rgb888)( const struct gl_texture_image *texImage,			   GLint i, GLint j, GLint k, GLchan *texel ){   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);   texel[RCOMP] = UBYTE_TO_CHAN( src[2] );   texel[GCOMP] = UBYTE_TO_CHAN( src[1] );   texel[BCOMP] = UBYTE_TO_CHAN( src[0] );   texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_rgb888(struct gl_texture_image *texImage,                               GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);   dst[0] = rgba[RCOMP];   dst[1] = rgba[GCOMP];   dst[2] = rgba[BCOMP];}#endif/* MESA_FORMAT_BGR888 ********************************************************//* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */static void FETCH(bgr888)( const struct gl_texture_image *texImage,			   GLint i, GLint j, GLint k, GLchan *texel ){   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);   texel[RCOMP] = UBYTE_TO_CHAN( src[0] );   texel[GCOMP] = UBYTE_TO_CHAN( src[1] );   texel[BCOMP] = UBYTE_TO_CHAN( src[2] );   texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_bgr888(struct gl_texture_image *texImage,                               GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);   dst[0] = rgba[BCOMP];   dst[1] = rgba[GCOMP];   dst[2] = rgba[RCOMP];}#endif/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)   instead of slow (g << 2) * 255 / 252 (always rounds down) *//* MESA_FORMAT_RGB565 ********************************************************//* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */static void FETCH(rgb565)( const struct gl_texture_image *texImage,			   GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   const GLushort s = *src;   texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );   texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >>  9) & 0x3) );   texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >>  2) & 0x7) );   texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_rgb565(struct gl_texture_image *texImage,                               GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);}#endif/* MESA_FORMAT_RGB565_REV ****************************************************//* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */static void FETCH(rgb565_rev)( const struct gl_texture_image *texImage,                               GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */   texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );   texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >>  9) & 0x3) );   texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >>  2) & 0x7) );   texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_rgb565_rev(struct gl_texture_image *texImage,                                  GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);}#endif/* MESA_FORMAT_ARGB4444 ******************************************************//* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */static void FETCH(argb4444)( const struct gl_texture_image *texImage,			     GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   const GLushort s = *src;   texel[RCOMP] = UBYTE_TO_CHAN( ((s >>  8) & 0xf) | ((s >> 4) & 0xf0) );   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  4) & 0xf) | ((s     ) & 0xf0) );   texel[BCOMP] = UBYTE_TO_CHAN( ((s      ) & 0xf) | ((s << 4) & 0xf0) );   texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) );}#if DIM == 3static void store_texel_argb4444(struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);}#endif/* MESA_FORMAT_ARGB4444_REV **************************************************//* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */static void FETCH(argb4444_rev)( const struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   texel[RCOMP] = UBYTE_TO_CHAN( ((s      ) & 0xf) | ((s << 4) & 0xf0) );   texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) );   texel[BCOMP] = UBYTE_TO_CHAN( ((s >>  8) & 0xf) | ((s >> 4) & 0xf0) );   texel[ACOMP] = UBYTE_TO_CHAN( ((s >>  4) & 0xf) | ((s     ) & 0xf0) );}#if DIM == 3static void store_texel_argb4444_rev(struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);}#endif/* MESA_FORMAT_ARGB1555 ******************************************************//* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */static void FETCH(argb1555)( const struct gl_texture_image *texImage,			     GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   const GLushort s = *src;   texel[RCOMP] = UBYTE_TO_CHAN( ((s >>  7) & 0xf8) | ((s >> 12) & 0x7) );   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  2) & 0xf8) | ((s >>  7) & 0x7) );   texel[BCOMP] = UBYTE_TO_CHAN( ((s <<  3) & 0xf8) | ((s >>  2) & 0x7) );   texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );}#if DIM == 3static void store_texel_argb1555(struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);}#endif/* MESA_FORMAT_ARGB1555_REV **************************************************//* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */static void FETCH(argb1555_rev)( const struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */   texel[RCOMP] = UBYTE_TO_CHAN( ((s >>  7) & 0xf8) | ((s >> 12) & 0x7) );   texel[GCOMP] = UBYTE_TO_CHAN( ((s >>  2) & 0xf8) | ((s >>  7) & 0x7) );   texel[BCOMP] = UBYTE_TO_CHAN( ((s <<  3) & 0xf8) | ((s >>  2) & 0x7) );   texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );}#if DIM == 3static void store_texel_argb1555_rev(struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);}#endif/* MESA_FORMAT_AL88 **********************************************************//* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */static void FETCH(al88)( const struct gl_texture_image *texImage,			 GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   texel[RCOMP] =    texel[GCOMP] =    texel[BCOMP] = UBYTE_TO_CHAN( s & 0xff );   texel[ACOMP] = UBYTE_TO_CHAN( s >> 8 );}#if DIM == 3static void store_texel_al88(struct gl_texture_image *texImage,                             GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);}#endif/* MESA_FORMAT_AL88_REV ******************************************************//* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */static void FETCH(al88_rev)( const struct gl_texture_image *texImage,                             GLint i, GLint j, GLint k, GLchan *texel ){   const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   texel[RCOMP] =    texel[GCOMP] =    texel[BCOMP] = UBYTE_TO_CHAN( s >> 8 );   texel[ACOMP] = UBYTE_TO_CHAN( s & 0xff );}#if DIM == 3static void store_texel_al88_rev(struct gl_texture_image *texImage,                                 GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);   *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);}#endif/* MESA_FORMAT_RGB332 ********************************************************//* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */static void FETCH(rgb332)( const struct gl_texture_image *texImage,			   GLint i, GLint j, GLint k, GLchan *texel ){   static const GLubyte lut2to8[4] = {0, 85, 170, 255};   static const GLubyte lut3to8[8] = {0, 36, 73, 109, 146, 182, 219, 255};   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   const GLubyte s = *src;   texel[RCOMP] = UBYTE_TO_CHAN( lut3to8[(s >> 5) & 0x7] );   texel[GCOMP] = UBYTE_TO_CHAN( lut3to8[(s >> 2) & 0x7] );   texel[BCOMP] = UBYTE_TO_CHAN( lut2to8[(s     ) & 0x3] );   texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_rgb332(struct gl_texture_image *texImage,                               GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);}#endif/* MESA_FORMAT_A8 ************************************************************//* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */static void FETCH(a8)( const struct gl_texture_image *texImage,		       GLint i, GLint j, GLint k, GLchan *texel ){   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   texel[RCOMP] =   texel[GCOMP] =   texel[BCOMP] = 0;   texel[ACOMP] = UBYTE_TO_CHAN( src[0] );}#if DIM == 3static void store_texel_a8(struct gl_texture_image *texImage,                           GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   *dst = rgba[ACOMP];}#endif/* MESA_FORMAT_L8 ************************************************************//* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */static void FETCH(l8)( const struct gl_texture_image *texImage,		       GLint i, GLint j, GLint k, GLchan *texel ){   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   texel[RCOMP] =   texel[GCOMP] =   texel[BCOMP] = UBYTE_TO_CHAN( src[0] );   texel[ACOMP] = CHAN_MAX;}#if DIM == 3static void store_texel_l8(struct gl_texture_image *texImage,                           GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   *dst = rgba[RCOMP];}#endif/* MESA_FORMAT_I8 ************************************************************//* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */static void FETCH(i8)( const struct gl_texture_image *texImage,		       GLint i, GLint j, GLint k, GLchan *texel ){   const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   texel[RCOMP] =   texel[GCOMP] =   texel[BCOMP] =   texel[ACOMP] = UBYTE_TO_CHAN( src[0] );}#if DIM == 3static void store_texel_i8(struct gl_texture_image *texImage,                           GLint i, GLint j, GLint k, const void *texel){   const GLubyte *rgba = (const GLubyte *) texel;   GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);   *dst = rgba[RCOMP];}#endif

⌨️ 快捷键说明

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