colortab.c

来自「mesa-6.5-minigui源码」· C语言 代码 · 共 1,446 行 · 第 1/4 页

C
1,446
字号
         }         table = &ctx->Texture.ProxyCubeMap->Palette;         break;      case GL_SHARED_TEXTURE_PALETTE_EXT:         table = &ctx->Texture.Palette;         break;      case GL_COLOR_TABLE:         table = &ctx->ColorTable;         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = ctx->Pixel.ColorTableScale[0];            params[1] = ctx->Pixel.ColorTableScale[1];            params[2] = ctx->Pixel.ColorTableScale[2];            params[3] = ctx->Pixel.ColorTableScale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = ctx->Pixel.ColorTableBias[0];            params[1] = ctx->Pixel.ColorTableBias[1];            params[2] = ctx->Pixel.ColorTableBias[2];            params[3] = ctx->Pixel.ColorTableBias[3];            return;         }         break;      case GL_PROXY_COLOR_TABLE:         table = &ctx->ProxyColorTable;         break;      case GL_TEXTURE_COLOR_TABLE_SGI:         if (!ctx->Extensions.SGI_texture_color_table) {            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");            return;         }         table = &(texUnit->ColorTable);         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = ctx->Pixel.TextureColorTableScale[0];            params[1] = ctx->Pixel.TextureColorTableScale[1];            params[2] = ctx->Pixel.TextureColorTableScale[2];            params[3] = ctx->Pixel.TextureColorTableScale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = ctx->Pixel.TextureColorTableBias[0];            params[1] = ctx->Pixel.TextureColorTableBias[1];            params[2] = ctx->Pixel.TextureColorTableBias[2];            params[3] = ctx->Pixel.TextureColorTableBias[3];            return;         }         break;      case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:         if (!ctx->Extensions.SGI_texture_color_table) {            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");            return;         }         table = &(texUnit->ProxyColorTable);         break;      case GL_POST_CONVOLUTION_COLOR_TABLE:         table = &ctx->PostConvolutionColorTable;         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = ctx->Pixel.PCCTscale[0];            params[1] = ctx->Pixel.PCCTscale[1];            params[2] = ctx->Pixel.PCCTscale[2];            params[3] = ctx->Pixel.PCCTscale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = ctx->Pixel.PCCTbias[0];            params[1] = ctx->Pixel.PCCTbias[1];            params[2] = ctx->Pixel.PCCTbias[2];            params[3] = ctx->Pixel.PCCTbias[3];            return;         }         break;      case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:         table = &ctx->ProxyPostConvolutionColorTable;         break;      case GL_POST_COLOR_MATRIX_COLOR_TABLE:         table = &ctx->PostColorMatrixColorTable;         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = ctx->Pixel.PCMCTscale[0];            params[1] = ctx->Pixel.PCMCTscale[1];            params[2] = ctx->Pixel.PCMCTscale[2];            params[3] = ctx->Pixel.PCMCTscale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = ctx->Pixel.PCMCTbias[0];            params[1] = ctx->Pixel.PCMCTbias[1];            params[2] = ctx->Pixel.PCMCTbias[2];            params[3] = ctx->Pixel.PCMCTbias[3];            return;         }         break;      case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:         table = &ctx->ProxyPostColorMatrixColorTable;         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)");         return;   }   assert(table);   switch (pname) {      case GL_COLOR_TABLE_FORMAT:         *params = (GLfloat) table->InternalFormat;         break;      case GL_COLOR_TABLE_WIDTH:         *params = (GLfloat) table->Size;         break;      case GL_COLOR_TABLE_RED_SIZE:         *params = (GLfloat) table->RedSize;         break;      case GL_COLOR_TABLE_GREEN_SIZE:         *params = (GLfloat) table->GreenSize;         break;      case GL_COLOR_TABLE_BLUE_SIZE:         *params = (GLfloat) table->BlueSize;         break;      case GL_COLOR_TABLE_ALPHA_SIZE:         *params = (GLfloat) table->AlphaSize;         break;      case GL_COLOR_TABLE_LUMINANCE_SIZE:         *params = (GLfloat) table->LuminanceSize;         break;      case GL_COLOR_TABLE_INTENSITY_SIZE:         *params = (GLfloat) table->IntensitySize;         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" );         return;   }}void GLAPIENTRY_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ){   GET_CURRENT_CONTEXT(ctx);   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   struct gl_color_table *table = NULL;   ASSERT_OUTSIDE_BEGIN_END(ctx);   switch (target) {      case GL_TEXTURE_1D:         table = &texUnit->Current1D->Palette;         break;      case GL_TEXTURE_2D:         table = &texUnit->Current2D->Palette;         break;      case GL_TEXTURE_3D:         table = &texUnit->Current3D->Palette;         break;      case GL_TEXTURE_CUBE_MAP_ARB:         if (!ctx->Extensions.ARB_texture_cube_map) {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetColorTableParameteriv(target)");            return;         }         table = &texUnit->CurrentCubeMap->Palette;         break;      case GL_PROXY_TEXTURE_1D:         table = &ctx->Texture.Proxy1D->Palette;         break;      case GL_PROXY_TEXTURE_2D:         table = &ctx->Texture.Proxy2D->Palette;         break;      case GL_PROXY_TEXTURE_3D:         table = &ctx->Texture.Proxy3D->Palette;         break;      case GL_PROXY_TEXTURE_CUBE_MAP_ARB:         if (!ctx->Extensions.ARB_texture_cube_map) {            _mesa_error(ctx, GL_INVALID_ENUM,                        "glGetColorTableParameteriv(target)");            return;         }         table = &ctx->Texture.ProxyCubeMap->Palette;         break;      case GL_SHARED_TEXTURE_PALETTE_EXT:         table = &ctx->Texture.Palette;         break;      case GL_COLOR_TABLE:         table = &ctx->ColorTable;         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = (GLint) ctx->Pixel.ColorTableScale[0];            params[1] = (GLint) ctx->Pixel.ColorTableScale[1];            params[2] = (GLint) ctx->Pixel.ColorTableScale[2];            params[3] = (GLint) ctx->Pixel.ColorTableScale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = (GLint) ctx->Pixel.ColorTableBias[0];            params[1] = (GLint) ctx->Pixel.ColorTableBias[1];            params[2] = (GLint) ctx->Pixel.ColorTableBias[2];            params[3] = (GLint) ctx->Pixel.ColorTableBias[3];            return;         }         break;      case GL_PROXY_COLOR_TABLE:         table = &ctx->ProxyColorTable;         break;      case GL_TEXTURE_COLOR_TABLE_SGI:         if (!ctx->Extensions.SGI_texture_color_table) {            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");            return;         }         table = &(texUnit->ColorTable);         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0];            params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1];            params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2];            params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0];            params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1];            params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2];            params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3];            return;         }         break;      case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:         if (!ctx->Extensions.SGI_texture_color_table) {            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");            return;         }         table = &(texUnit->ProxyColorTable);         break;      case GL_POST_CONVOLUTION_COLOR_TABLE:         table = &ctx->PostConvolutionColorTable;         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = (GLint) ctx->Pixel.PCCTscale[0];            params[1] = (GLint) ctx->Pixel.PCCTscale[1];            params[2] = (GLint) ctx->Pixel.PCCTscale[2];            params[3] = (GLint) ctx->Pixel.PCCTscale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = (GLint) ctx->Pixel.PCCTbias[0];            params[1] = (GLint) ctx->Pixel.PCCTbias[1];            params[2] = (GLint) ctx->Pixel.PCCTbias[2];            params[3] = (GLint) ctx->Pixel.PCCTbias[3];            return;         }         break;      case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:         table = &ctx->ProxyPostConvolutionColorTable;         break;      case GL_POST_COLOR_MATRIX_COLOR_TABLE:         table = &ctx->PostColorMatrixColorTable;         if (pname == GL_COLOR_TABLE_SCALE_SGI) {            params[0] = (GLint) ctx->Pixel.PCMCTscale[0];            params[1] = (GLint) ctx->Pixel.PCMCTscale[1];            params[2] = (GLint) ctx->Pixel.PCMCTscale[2];            params[3] = (GLint) ctx->Pixel.PCMCTscale[3];            return;         }         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {            params[0] = (GLint) ctx->Pixel.PCMCTbias[0];            params[1] = (GLint) ctx->Pixel.PCMCTbias[1];            params[2] = (GLint) ctx->Pixel.PCMCTbias[2];            params[3] = (GLint) ctx->Pixel.PCMCTbias[3];            return;         }         break;      case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:         table = &ctx->ProxyPostColorMatrixColorTable;         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)");         return;   }   assert(table);   switch (pname) {      case GL_COLOR_TABLE_FORMAT:         *params = table->InternalFormat;         break;      case GL_COLOR_TABLE_WIDTH:         *params = table->Size;         break;      case GL_COLOR_TABLE_RED_SIZE:         *params = table->RedSize;         break;      case GL_COLOR_TABLE_GREEN_SIZE:         *params = table->GreenSize;         break;      case GL_COLOR_TABLE_BLUE_SIZE:         *params = table->BlueSize;         break;      case GL_COLOR_TABLE_ALPHA_SIZE:         *params = table->AlphaSize;         break;      case GL_COLOR_TABLE_LUMINANCE_SIZE:         *params = table->LuminanceSize;         break;      case GL_COLOR_TABLE_INTENSITY_SIZE:         *params = table->IntensitySize;         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" );         return;   }}/**********************************************************************//*****                      Initialization                        *****//**********************************************************************/void_mesa_init_colortable( struct gl_color_table *p ){   p->Type = CHAN_TYPE;   p->Table = NULL;   p->Size = 0;   p->InternalFormat = GL_RGBA;}void_mesa_free_colortable_data( struct gl_color_table *p ){   if (p->Table) {      FREE(p->Table);      p->Table = NULL;   }}/* * Initialize all colortables for a context. */void _mesa_init_colortables( GLcontext * ctx ){   /* Color tables */   _mesa_init_colortable(&ctx->ColorTable);   _mesa_init_colortable(&ctx->ProxyColorTable);   _mesa_init_colortable(&ctx->PostConvolutionColorTable);   _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable);   _mesa_init_colortable(&ctx->PostColorMatrixColorTable);   _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable);}/* * Free all colortable data for a context */void _mesa_free_colortables_data( GLcontext *ctx ){   _mesa_free_colortable_data(&ctx->ColorTable);   _mesa_free_colortable_data(&ctx->ProxyColorTable);   _mesa_free_colortable_data(&ctx->PostConvolutionColorTable);   _mesa_free_colortable_data(&ctx->ProxyPostConvolutionColorTable);   _mesa_free_colortable_data(&ctx->PostColorMatrixColorTable);   _mesa_free_colortable_data(&ctx->ProxyPostColorMatrixColorTable);}

⌨️ 快捷键说明

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