From 418ac00e7583bf3136816a43b3357e0d0b0c776d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 21 Jan 2003 21:47:45 +0000 Subject: GL_SGI_texture_color_table extension (Eric Plante) --- src/mesa/main/colortab.c | 143 +++++++++++++++++++++++-- src/mesa/main/context.c | 8 +- src/mesa/main/dlist.c | 8 +- src/mesa/main/enable.c | 9 +- src/mesa/main/extensions.c | 4 +- src/mesa/main/get.c | 25 ++++- src/mesa/main/mtypes.h | 9 +- src/mesa/swrast/s_texture.c | 252 +++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 440 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index fb5c942..04625c6 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -1,10 +1,10 @@ -/* $Id: colortab.c,v 1.46 2002/10/24 23:57:19 brianp Exp $ */ +/* $Id: colortab.c,v 1.47 2003/01/21 21:47:45 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 Brian Paul 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"), @@ -257,6 +257,30 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, table = &ctx->ProxyColorTable; proxy = GL_TRUE; break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); + return; + } + table = &ctx->TextureColorTable; + floatTable = GL_TRUE; + rScale = ctx->Texture.ColorTableScale[0]; + gScale = ctx->Texture.ColorTableScale[1]; + bScale = ctx->Texture.ColorTableScale[2]; + aScale = ctx->Texture.ColorTableScale[3]; + rBias = ctx->Texture.ColorTableBias[0]; + gBias = ctx->Texture.ColorTableBias[1]; + bBias = ctx->Texture.ColorTableBias[2]; + aBias = ctx->Texture.ColorTableBias[3]; + break; + case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); + return; + } + table = &ctx->ProxyTextureColorTable; + proxy = GL_TRUE; + break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->PostConvolutionColorTable; floatTable = GL_TRUE; @@ -486,6 +510,21 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, bBias = ctx->Pixel.ColorTableBias[2]; aBias = ctx->Pixel.ColorTableBias[3]; break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); + return; + } + table = &ctx->TextureColorTable; + rScale = ctx->Texture.ColorTableScale[0]; + gScale = ctx->Texture.ColorTableScale[1]; + bScale = ctx->Texture.ColorTableScale[2]; + aScale = ctx->Texture.ColorTableScale[3]; + rBias = ctx->Texture.ColorTableBias[0]; + gBias = ctx->Texture.ColorTableBias[1]; + bBias = ctx->Texture.ColorTableBias[2]; + aBias = ctx->Texture.ColorTableBias[3]; + break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->PostConvolutionColorTable; rScale = ctx->Pixel.PCCTscale[0]; @@ -683,6 +722,13 @@ _mesa_GetColorTable( GLenum target, GLenum format, case GL_COLOR_TABLE: table = &ctx->ColorTable; break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); + return; + } + table = &ctx->TextureColorTable; + break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->PostConvolutionColorTable; break; @@ -865,6 +911,28 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) return; } break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); + return; + } + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Texture.ColorTableScale[0] = params[0]; + ctx->Texture.ColorTableScale[1] = params[1]; + ctx->Texture.ColorTableScale[2] = params[2]; + ctx->Texture.ColorTableScale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Texture.ColorTableBias[0] = params[0]; + ctx->Texture.ColorTableBias[1] = params[1]; + ctx->Texture.ColorTableBias[2] = params[2]; + ctx->Texture.ColorTableBias[3] = params[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: if (pname == GL_COLOR_TABLE_SCALE_SGI) { ctx->Pixel.PCCTscale[0] = params[0]; @@ -916,6 +984,7 @@ _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) { GLfloat fparams[4]; if (pname == GL_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI || pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { /* four values */ @@ -999,6 +1068,34 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) 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 = &ctx->TextureColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Texture.ColorTableScale[0]; + params[1] = ctx->Texture.ColorTableScale[1]; + params[2] = ctx->Texture.ColorTableScale[2]; + params[3] = ctx->Texture.ColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Texture.ColorTableBias[0]; + params[1] = ctx->Texture.ColorTableBias[1]; + params[2] = ctx->Texture.ColorTableBias[2]; + params[3] = ctx->Texture.ColorTableBias[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 = &ctx->ProxyTextureColorTable; + break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->PostConvolutionColorTable; if (pname == GL_COLOR_TABLE_SCALE_SGI) { @@ -1054,22 +1151,22 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) *params = (GLfloat) table->Size; break; case GL_COLOR_TABLE_RED_SIZE: - *params = table->RedSize; + *params = (GLfloat) table->RedSize; break; case GL_COLOR_TABLE_GREEN_SIZE: - *params = table->GreenSize; + *params = (GLfloat) table->GreenSize; break; case GL_COLOR_TABLE_BLUE_SIZE: - *params = table->BlueSize; + *params = (GLfloat) table->BlueSize; break; case GL_COLOR_TABLE_ALPHA_SIZE: - *params = table->AlphaSize; + *params = (GLfloat) table->AlphaSize; break; case GL_COLOR_TABLE_LUMINANCE_SIZE: - *params = table->LuminanceSize; + *params = (GLfloat) table->LuminanceSize; break; case GL_COLOR_TABLE_INTENSITY_SIZE: - *params = table->IntensitySize; + *params = (GLfloat) table->IntensitySize; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" ); @@ -1145,6 +1242,34 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) 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 = &ctx->TextureColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Texture.ColorTableScale[0]; + params[1] = (GLint) ctx->Texture.ColorTableScale[1]; + params[2] = (GLint) ctx->Texture.ColorTableScale[2]; + params[3] = (GLint) ctx->Texture.ColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Texture.ColorTableBias[0]; + params[1] = (GLint) ctx->Texture.ColorTableBias[1]; + params[2] = (GLint) ctx->Texture.ColorTableBias[2]; + params[3] = (GLint) ctx->Texture.ColorTableBias[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 = &ctx->ProxyTextureColorTable; + break; case GL_POST_CONVOLUTION_COLOR_TABLE: table = &ctx->PostConvolutionColorTable; if (pname == GL_COLOR_TABLE_SCALE_SGI) { diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2d43652..9dac955 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.191 2003/01/14 04:55:45 brianp Exp $ */ +/* $Id: context.c,v 1.192 2003/01/21 21:47:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1323,6 +1323,9 @@ init_attrib_groups( GLcontext *ctx ) init_texture_unit( ctx, i ); ctx->Texture.SharedPalette = GL_FALSE; _mesa_init_colortable(&ctx->Texture.Palette); + ASSIGN_4V(ctx->Texture.ColorTableScale, 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Texture.ColorTableBias, 0.0, 0.0, 0.0, 0.0); + ctx->Texture.ColorTableEnabled = GL_FALSE; /* Transformation group */ ctx->Transform.MatrixMode = GL_MODELVIEW; @@ -1462,6 +1465,8 @@ init_attrib_groups( GLcontext *ctx ) _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable); _mesa_init_colortable(&ctx->PostColorMatrixColorTable); _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable); + _mesa_init_colortable(&ctx->TextureColorTable); + _mesa_init_colortable(&ctx->ProxyTextureColorTable); /* Vertex/fragment programs */ ctx->Program.ErrorPos = -1; @@ -2035,6 +2040,7 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_colortable_data( &ctx->PostConvolutionColorTable ); _mesa_free_colortable_data( &ctx->PostColorMatrixColorTable ); _mesa_free_colortable_data( &ctx->Texture.Palette ); + _mesa_free_colortable_data( &ctx->TextureColorTable ); _math_matrix_dtr(&ctx->Viewport._WindowMap); diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 2fcfb4a..f04bedc 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,4 +1,4 @@ -/* $Id: dlist.c,v 1.101 2003/01/14 04:55:45 brianp Exp $ */ +/* $Id: dlist.c,v 1.102 2003/01/21 21:47:48 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1141,7 +1141,8 @@ save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) n[3].f = params[0]; if (pname == GL_COLOR_TABLE_SGI || pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { + pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { n[4].f = params[1]; n[5].f = params[2]; n[6].f = params[3]; @@ -1169,7 +1170,8 @@ save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) n[3].i = params[0]; if (pname == GL_COLOR_TABLE_SGI || pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { + pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { n[4].i = params[1]; n[5].i = params[2]; n[6].i = params[3]; diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 84d0311..44c1e14 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1,4 +1,4 @@ -/* $Id: enable.c,v 1.72 2003/01/14 04:55:45 brianp Exp $ */ +/* $Id: enable.c,v 1.73 2003/01/21 21:47:49 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -691,6 +691,13 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.PostColorMatrixColorTableEnabled = state; break; + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION(SGI_texture_color_table, cap); + if (ctx->Texture.ColorTableEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + ctx->Texture.ColorTableEnabled = state; + break; /* GL_EXT_convolution */ case GL_CONVOLUTION_1D: diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 296308c..7e1f203 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.87 2003/01/21 15:49:14 brianp Exp $ */ +/* $Id: extensions.c,v 1.88 2003/01/21 21:47:49 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -122,6 +122,7 @@ static struct { { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) }, { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) }, { OFF, "GL_SGI_color_table", F(SGI_color_table) }, + { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) }, { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) }, { OFF, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture) }, { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) }, @@ -199,6 +200,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) #endif "GL_SGI_color_matrix", "GL_SGI_color_table", + "GL_SGI_texture_color_table", "GL_SGIS_generate_mipmap", "GL_SGIS_pixel_texture", "GL_SGIS_texture_edge_clamp", diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 8eac97f..9541ab0 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.102 2003/01/21 15:45:39 brianp Exp $ */ +/* $Id: get.c,v 1.103 2003/01/21 21:47:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1229,6 +1229,12 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = ctx->Pixel.PostColorMatrixColorTableEnabled; break; + /* GL_SGI_texture_color_table */ + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION_B(SGI_texture_color_table, pname); + *params = ctx->Texture.ColorTableEnabled; + break; + /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: CHECK_EXTENSION_B(EXT_secondary_color, pname); @@ -2621,6 +2627,12 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) ctx->Pixel.PostColorMatrixColorTableEnabled; break; + /* GL_SGI_texture_color_table */ + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION_D(SGI_texture_color_table, pname); + *params = (GLdouble) ctx->Texture.ColorTableEnabled; + break; + /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: CHECK_EXTENSION_D(EXT_secondary_color, pname); @@ -3987,6 +3999,12 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) ctx->Pixel.PostColorMatrixColorTableEnabled; break; + /* GL_SGI_texture_color_table */ + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION_F(SGI_texture_color_table, pname); + *params = (GLfloat) ctx->Texture.ColorTableEnabled; + break; + /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: CHECK_EXTENSION_F(EXT_secondary_color, pname); @@ -5391,6 +5409,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = (GLint) ctx->Pixel.PostColorMatrixColorTableEnabled; break; + /* GL_SGI_texture_color_table */ + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION_I(SGI_texture_color_table, pname); + *params = (GLint) ctx->Texture.ColorTableEnabled; + break; /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 353dc0d..37268c2 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.99 2003/01/21 15:49:15 brianp Exp $ */ +/* $Id: mtypes.h,v 1.100 2003/01/21 21:47:50 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -975,6 +975,10 @@ struct gl_texture_attrib { /* GL_EXT_shared_texture_palette */ GLboolean SharedPalette; struct gl_color_table Palette; + /* GL_SGI_texture_color_table */ + GLfloat ColorTableScale[4]; + GLfloat ColorTableBias[4]; + GLboolean ColorTableEnabled; }; @@ -1395,6 +1399,7 @@ struct gl_extensions { GLboolean NV_vertex_program1_1; GLboolean SGI_color_matrix; GLboolean SGI_color_table; + GLboolean SGI_texture_color_table; GLboolean SGIS_generate_mipmap; GLboolean SGIS_pixel_texture; GLboolean SGIS_texture_edge_clamp; @@ -1715,6 +1720,8 @@ struct __GLcontextRec { struct gl_color_table ProxyPostConvolutionColorTable; struct gl_color_table PostColorMatrixColorTable; struct gl_color_table ProxyPostColorMatrixColorTable; + struct gl_color_table TextureColorTable; + struct gl_color_table ProxyTextureColorTable; struct program_state Program; /* for vertex or fragment progs */ struct vertex_program_state VertexProgram; /* GL_NV_vertex_program */ diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index cd86c76..bc1e14d 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -1,4 +1,4 @@ -/* $Id: s_texture.c,v 1.76 2003/01/21 15:49:19 brianp Exp $ */ +/* $Id: s_texture.c,v 1.77 2003/01/21 21:47:53 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -296,6 +296,198 @@ #define K1BIT 32 +static void texture_table_lookup(const struct gl_color_table *table, + GLuint n, GLchan rgba[][4]) +{ + ASSERT(table->FloatTable); + if (!table->Table || table->Size == 0) + return; + + switch (table->Format) { + case GL_INTENSITY: + /* replace RGBA with I */ + if (!table->FloatTable) { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLchan *lut = (const GLchan *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLchan c = lut[CLAMP(j, 0, 1)]; + rgba[i][RCOMP] = rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = c; + } + + } + else { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLchan c; + CLAMPED_FLOAT_TO_CHAN(c, lut[j]); + rgba[i][RCOMP] = rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = c; + } + } + break; + case GL_LUMINANCE: + /* replace RGB with L */ + if (!table->FloatTable) { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLchan *lut = (const GLchan *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLchan c = lut[j]; + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; + } + } + else { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLchan c; + CLAMPED_FLOAT_TO_CHAN(c, lut[j]); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; + } + } + break; + case GL_ALPHA: + /* replace A with A */ + if (!table->FloatTable) { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLchan *lut = (const GLchan *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale; + rgba[i][ACOMP] = lut[j]; + } + } + else { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale; + CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[j]); + } + } + break; + case GL_LUMINANCE_ALPHA: + /* replace RGBA with LLLA */ + if (!table->FloatTable) { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLchan *lut = (const GLchan *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jL = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale; + GLchan luminance, alpha; + luminance = lut[jL * 2 + 0]; + alpha = lut[jA * 2 + 1]; + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + } + else { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jL = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale; + GLchan luminance, alpha; + CLAMPED_FLOAT_TO_CHAN(luminance, lut[jL * 2 + 0]); + CLAMPED_FLOAT_TO_CHAN(alpha, lut[jA * 2 + 1]); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + } + break; + case GL_RGB: + /* replace RGB with RGB */ + if (!table->FloatTable) { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLchan *lut = (const GLchan *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale; + GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale; + rgba[i][RCOMP] = lut[jR * 3 + 0]; + rgba[i][GCOMP] = lut[jG * 3 + 1]; + rgba[i][BCOMP] = lut[jB * 3 + 2]; + } + } + else { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale; + GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale; + CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 3 + 0]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 3 + 1]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 3 + 2]); + } + } + break; + case GL_RGBA: + /* replace RGBA with RGBA */ + if (!table->FloatTable) { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLchan *lut = (const GLchan *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale; + GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale; + GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale; + rgba[i][RCOMP] = lut[jR * 4 + 0]; + rgba[i][GCOMP] = lut[jG * 4 + 1]; + rgba[i][BCOMP] = lut[jB * 4 + 2]; + rgba[i][ACOMP] = lut[jA * 4 + 3]; + } + } + else { + const GLint max = table->Size - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale; + GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale; + GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale; + GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale; + CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]); + } + } + break; + default: + _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba"); + return; + } +} + + /* * Get texture palette entry. @@ -672,6 +864,10 @@ sample_nearest_1d( GLcontext *ctx, GLuint texUnit, for (i=0;iTexture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } + } @@ -688,6 +884,9 @@ sample_linear_1d( GLcontext *ctx, GLuint texUnit, for (i=0;iTexture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -764,6 +963,9 @@ sample_lambda_1d( GLcontext *ctx, GLuint texUnit, return; } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1145,6 +1347,9 @@ sample_nearest_2d( GLcontext *ctx, GLuint texUnit, for (i=0;iTexture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1161,6 +1366,9 @@ sample_linear_2d( GLcontext *ctx, GLuint texUnit, for (i=0;iTexture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1352,6 +1560,9 @@ sample_lambda_2d( GLcontext *ctx, GLuint texUnit, _mesa_problem(ctx, "Bad mag filter in sample_lambda_2d"); } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1690,6 +1901,9 @@ sample_nearest_3d(GLcontext *ctx, GLuint texUnit, for (i=0;iTexture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1706,6 +1920,9 @@ sample_linear_3d( GLcontext *ctx, GLuint texUnit, for (i=0;iTexture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1781,6 +1998,9 @@ sample_lambda_3d( GLcontext *ctx, GLuint texUnit, return; } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1879,6 +2099,9 @@ sample_nearest_cube(GLcontext *ctx, GLuint texUnit, sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel], newCoord, rgba[i]); } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1897,6 +2120,9 @@ sample_linear_cube(GLcontext *ctx, GLuint texUnit, sample_2d_linear(ctx, tObj, images[tObj->BaseLevel], newCoord, rgba[i]); } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1916,6 +2142,9 @@ sample_cube_nearest_mipmap_nearest(GLcontext *ctx, images = choose_cube_face(tObj, texcoord[i], newCoord); sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]); } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1935,6 +2164,9 @@ sample_cube_linear_mipmap_nearest(GLcontext *ctx, images = choose_cube_face(tObj, texcoord[i], newCoord); sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]); } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1967,6 +2199,9 @@ sample_cube_nearest_mipmap_linear(GLcontext *ctx, rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]); } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -1999,6 +2234,9 @@ sample_cube_linear_mipmap_linear(GLcontext *ctx, rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]); } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -2064,6 +2302,9 @@ sample_lambda_cube( GLcontext *ctx, GLuint texUnit, _mesa_problem(ctx, "Bad mag filter in sample_lambda_cube"); } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -2123,6 +2364,9 @@ sample_nearest_rect(GLcontext *ctx, GLuint texUnit, (*img->FetchTexel)(img, col, row, 0, (GLvoid *) rgba[i]); } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -2211,6 +2455,9 @@ sample_linear_rect(GLcontext *ctx, GLuint texUnit, rgba[i][3] = (GLchan) (w00 * t00[3] + w10 * t10[3] + w01 * t01[3] + w11 * t11[3]); } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } @@ -2248,6 +2495,9 @@ sample_lambda_rect( GLcontext *ctx, GLuint texUnit, texcoords + magStart, NULL, rgba + magStart); } } + if (ctx->Texture.ColorTableEnabled) { + texture_table_lookup(&ctx->TextureColorTable, n, rgba); + } } -- cgit v1.1