-/* $Id: colortab.c,v 1.13 2000/04/12 00:27:37 brianp Exp $ */
+/* $Id: colortab.c,v 1.14 2000/04/17 15:13:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLint baseFormat;
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
+ GLboolean floatTable = GL_FALSE;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable");
break;
case GL_COLOR_TABLE:
table = &ctx->ColorTable;
+ floatTable = GL_TRUE;
rScale = ctx->Pixel.ColorTableScale[0];
gScale = ctx->Pixel.ColorTableScale[1];
bScale = ctx->Pixel.ColorTableScale[2];
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
+ floatTable = GL_TRUE;
rScale = ctx->Pixel.PCCTscale[0];
gScale = ctx->Pixel.PCCTscale[1];
bScale = ctx->Pixel.PCCTscale[2];
break;
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
table = &ctx->PostColorMatrixColorTable;
+ floatTable = GL_TRUE;
rScale = ctx->Pixel.PCMCTscale[0];
gScale = ctx->Pixel.PCMCTscale[1];
bScale = ctx->Pixel.PCMCTscale[2];
table->Table, /* dest */
format, type, data,
&ctx->Unpack, GL_TRUE);
- if (rScale != 1.0 || gScale != 1.0 || bScale != 1.0 || aScale != 1.0 ||
- rBias != 0.0 || gBias != 0.0 || bBias != 0.0 || aBias != 0.0) {
- /* XXX apply scale and bias */
+ if (floatTable) {
+ /* Apply scale and bias and convert GLubyte values to GLfloats
+ * in [0, 1]. Store results in the tableF[].
+ */
+ GLuint i;
+ rScale /= 255.0;
+ gScale /= 255.0;
+ bScale /= 255.0;
+ aScale /= 255.0;
+ switch (table->Format) {
+ case GL_INTENSITY:
+ for (i = 0; i < width; i++) {
+ table->TableF[i] = table->Table[i] * rScale + rBias;
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i = 0; i < width; i++) {
+ table->TableF[i] = table->Table[i] * rScale + rBias;
+ }
+ break;
+ case GL_ALPHA:
+ for (i = 0; i < width; i++) {
+ table->TableF[i] = table->Table[i] * aScale + aBias;
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i = 0; i < width; i++) {
+ table->TableF[i*2+0] = table->Table[i*2+0] * rScale + rBias;
+ table->TableF[i*2+1] = table->Table[i*2+1] * aScale + aBias;
+ }
+ break;
+ case GL_RGB:
+ for (i = 0; i < width; i++) {
+ table->TableF[i*3+0] = table->Table[i*3+0] * rScale + rBias;
+ table->TableF[i*3+1] = table->Table[i*3+1] * gScale + gBias;
+ table->TableF[i*3+2] = table->Table[i*3+2] * bScale + bBias;
+ }
+ break;
+ case GL_RGBA:
+ for (i = 0; i < width; i++) {
+ table->TableF[i*4+0] = table->Table[i*4+0] * rScale + rBias;
+ table->TableF[i*4+1] = table->Table[i*4+1] * gScale + gBias;
+ table->TableF[i*4+2] = table->Table[i*4+2] * bScale + bBias;
+ table->TableF[i*4+3] = table->Table[i*4+3] * aScale + aBias;
+ }
+ break;
+ default:
+ gl_problem(ctx, "Bad format in _mesa_ColorTable");
+ return;
+ }
}
}
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
struct gl_color_table *table = NULL;
GLubyte rgba[MAX_COLOR_TABLE_SIZE][4];
+ GLboolean floatTable = GL_FALSE;
GLint i;
ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTable");
break;
case GL_COLOR_TABLE:
table = &ctx->ColorTable;
+ floatTable = GL_TRUE;
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
+ floatTable = GL_TRUE;
break;
case GL_POST_COLOR_MATRIX_COLOR_TABLE:
table = &ctx->PostColorMatrixColorTable;
+ floatTable = GL_TRUE;
break;
default:
gl_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
switch (table->Format) {
case GL_ALPHA:
- for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = 0;
- rgba[i][GCOMP] = 0;
- rgba[i][BCOMP] = 0;
- rgba[i][ACOMP] = table->Table[i];
+ if (floatTable) {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = 0;
+ rgba[i][GCOMP] = 0;
+ rgba[i][BCOMP] = 0;
+ rgba[i][ACOMP] = (GLint) (table->TableF[i] * 255.0F);
+ }
+ }
+ else {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = 0;
+ rgba[i][GCOMP] = 0;
+ rgba[i][BCOMP] = 0;
+ rgba[i][ACOMP] = table->Table[i];
+ }
}
break;
case GL_LUMINANCE:
- for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = table->Table[i];
- rgba[i][GCOMP] = table->Table[i];
- rgba[i][BCOMP] = table->Table[i];
- rgba[i][ACOMP] = 255;
+ if (floatTable) {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = (GLint) (table->Table[i] * 255.0F);
+ rgba[i][GCOMP] = (GLint) (table->Table[i] * 255.0F);
+ rgba[i][BCOMP] = (GLint) (table->Table[i] * 255.0F);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ else {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = table->Table[i];
+ rgba[i][GCOMP] = table->Table[i];
+ rgba[i][BCOMP] = table->Table[i];
+ rgba[i][ACOMP] = 255;
+ }
}
break;
case GL_LUMINANCE_ALPHA:
- for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = table->Table[i*2+0];
- rgba[i][GCOMP] = table->Table[i*2+0];
- rgba[i][BCOMP] = table->Table[i*2+0];
- rgba[i][ACOMP] = table->Table[i*2+1];
+ if (floatTable) {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = (GLint) (table->Table[i*2+0] * 255.0F);
+ rgba[i][GCOMP] = (GLint) (table->Table[i*2+0] * 255.0F);
+ rgba[i][BCOMP] = (GLint) (table->Table[i*2+0] * 255.0F);
+ rgba[i][ACOMP] = (GLint) (table->Table[i*2+1] * 255.0F);
+ }
+ }
+ else {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = table->Table[i*2+0];
+ rgba[i][GCOMP] = table->Table[i*2+0];
+ rgba[i][BCOMP] = table->Table[i*2+0];
+ rgba[i][ACOMP] = table->Table[i*2+1];
+ }
}
break;
case GL_INTENSITY:
- for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = table->Table[i];
- rgba[i][GCOMP] = table->Table[i];
- rgba[i][BCOMP] = table->Table[i];
- rgba[i][ACOMP] = 255;
+ if (floatTable) {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = (GLint) (table->Table[i] * 255.0F);
+ rgba[i][GCOMP] = (GLint) (table->Table[i] * 255.0F);
+ rgba[i][BCOMP] = (GLint) (table->Table[i] * 255.0F);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ else {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = table->Table[i];
+ rgba[i][GCOMP] = table->Table[i];
+ rgba[i][BCOMP] = table->Table[i];
+ rgba[i][ACOMP] = 255;
+ }
}
break;
case GL_RGB:
- for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = table->Table[i*3+0];
- rgba[i][GCOMP] = table->Table[i*3+1];
- rgba[i][BCOMP] = table->Table[i*3+2];
- rgba[i][ACOMP] = 255;
+ if (floatTable) {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = (GLint) (table->Table[i*3+0] * 255.0F);
+ rgba[i][GCOMP] = (GLint) (table->Table[i*3+1] * 255.0F);
+ rgba[i][BCOMP] = (GLint) (table->Table[i*3+2] * 255.0F);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ else {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = table->Table[i*3+0];
+ rgba[i][GCOMP] = table->Table[i*3+1];
+ rgba[i][BCOMP] = table->Table[i*3+2];
+ rgba[i][ACOMP] = 255;
+ }
}
break;
case GL_RGBA:
- for (i = 0; i < table->Size; i++) {
- rgba[i][RCOMP] = table->Table[i*4+0];
- rgba[i][GCOMP] = table->Table[i*4+1];
- rgba[i][BCOMP] = table->Table[i*4+2];
- rgba[i][ACOMP] = table->Table[i*4+3];
+ if (floatTable) {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = (GLint) (table->Table[i*4+0] * 255.0F);
+ rgba[i][GCOMP] = (GLint) (table->Table[i*4+1] * 255.0F);
+ rgba[i][BCOMP] = (GLint) (table->Table[i*4+2] * 255.0F);
+ rgba[i][ACOMP] = (GLint) (table->Table[i*4+3] * 255.0F);
+ }
+ }
+ else {
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = table->Table[i*4+0];
+ rgba[i][GCOMP] = table->Table[i*4+1];
+ rgba[i][BCOMP] = table->Table[i*4+2];
+ rgba[i][ACOMP] = table->Table[i*4+3];
+ }
}
break;
default:
-/* $Id: image.c,v 1.27 2000/04/15 23:05:39 brianp Exp $ */
+/* $Id: image.c,v 1.28 2000/04/17 15:13:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Pixel.MapColorFlag ||
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm ||
- ctx->Pixel.ColorTableEnabled);
+ ctx->Pixel.ColorTableEnabled ||
+ ctx->Pixel.PostColorMatrixColorTableEnabled);
/* Test for optimized case first */
if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
if (ctx->Pixel.ScaleOrBiasRGBA) {
_mesa_scale_and_bias_rgba( ctx, n, rgba );
}
- /* color table lookup */
+ /* color map lookup */
if (ctx->Pixel.MapColorFlag) {
_mesa_map_rgba( ctx, n, rgba );
}
+ /* GL_COLOR_TABLE lookup */
+ if (ctx->Pixel.ColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ }
+ /* XXX convolution here */
+ /* XXX post-convolution color table look-up here */
/* color matrix */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
_mesa_transform_rgba(ctx, n, rgba);
}
- /* GL_SGI_color_table lookup */
- if (ctx->Pixel.ColorTableEnabled) {
- _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
}
+ /* XXX histogram here */
+ /* XXX min/max here */
}
if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) {
ctx->Pixel.MapColorFlag ||
ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm ||
- ctx->Pixel.ColorTableEnabled);
+ ctx->Pixel.ColorTableEnabled ||
+ ctx->Pixel.PostColorMatrixColorTableEnabled);
/* Try simple cases first */
if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) {
if (applyTransferOps) {
/* scale and bias colors */
_mesa_scale_and_bias_rgba(ctx, n, rgba);
- /* color table lookup */
+ /* color map lookup */
if (ctx->Pixel.MapColorFlag) {
_mesa_map_rgba(ctx, n, rgba);
}
+ /* GL_COLOR_TABLE lookup */
+ if (ctx->Pixel.ColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ }
+ /* XXX convolution here */
+ /* XXX post-convolution color table look-up here */
/* color matrix transform */
if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
ctx->Pixel.ScaleOrBiasRGBApcm) {
_mesa_transform_rgba(ctx, n, rgba);
}
- /* GL_SGI_color_table lookup */
- if (ctx->Pixel.ColorTableEnabled) {
- _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
}
+ /* XXX histogram here */
+ /* XXX min/max here */
}
}
-/* $Id: pixel.c,v 1.7 2000/04/12 18:54:48 brianp Exp $ */
+/* $Id: pixel.c,v 1.8 2000/04/17 15:13:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
case GL_INTENSITY:
{
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = table->Table;
+ const GLfloat *lut = table->TableF;
GLuint i;
/* replace RGBA with I */
for (i = 0; i < n; i++) {
case GL_LUMINANCE:
{
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = table->Table;
+ const GLfloat *lut = table->TableF;
GLuint i;
/* replace RGB with L */
for (i = 0; i < n; i++) {
case GL_ALPHA:
{
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = table->Table;
+ const GLfloat *lut = table->TableF;
GLuint i;
/* replace A with A */
for (i = 0; i < n; i++) {
case GL_LUMINANCE_ALPHA:
{
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = table->Table;
+ const GLfloat *lut = table->TableF;
GLuint i;
/* replace RGBA with LLLA */
for (i = 0; i < n; i++) {
case GL_RGB:
{
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = table->Table;
+ const GLfloat *lut = table->TableF;
GLuint i;
/* replace RGB with RGB */
for (i = 0; i < n; i++) {
case GL_RGBA:
{
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLubyte *lut = table->Table;
+ const GLfloat *lut = table->TableF;
GLuint i;
/* replace RGBA with RGBA */
for (i = 0; i < n; i++) {