-/* $Id: pixel.c,v 1.8 2000/04/17 15:13:53 brianp Exp $ */
+/* $Id: pixel.c,v 1.11 2000/05/07 20:41:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Pixel.DepthBias = param;
break;
case GL_POST_COLOR_MATRIX_RED_SCALE:
- ctx->Pixel.PostColorMatrixRedScale = param;
+ ctx->Pixel.PostColorMatrixScale[0] = param;
break;
case GL_POST_COLOR_MATRIX_RED_BIAS:
- ctx->Pixel.PostColorMatrixRedBias = param;
+ ctx->Pixel.PostColorMatrixBias[0] = param;
break;
case GL_POST_COLOR_MATRIX_GREEN_SCALE:
- ctx->Pixel.PostColorMatrixGreenScale = param;
+ ctx->Pixel.PostColorMatrixScale[1] = param;
break;
case GL_POST_COLOR_MATRIX_GREEN_BIAS:
- ctx->Pixel.PostColorMatrixGreenBias = param;
+ ctx->Pixel.PostColorMatrixBias[1] = param;
break;
case GL_POST_COLOR_MATRIX_BLUE_SCALE:
- ctx->Pixel.PostColorMatrixBlueScale = param;
+ ctx->Pixel.PostColorMatrixScale[2] = param;
break;
case GL_POST_COLOR_MATRIX_BLUE_BIAS:
- ctx->Pixel.PostColorMatrixBlueBias = param;
+ ctx->Pixel.PostColorMatrixBias[2] = param;
break;
case GL_POST_COLOR_MATRIX_ALPHA_SCALE:
- ctx->Pixel.PostColorMatrixAlphaScale = param;
+ ctx->Pixel.PostColorMatrixScale[3] = param;
break;
case GL_POST_COLOR_MATRIX_ALPHA_BIAS:
- ctx->Pixel.PostColorMatrixAlphaBias = param;
+ ctx->Pixel.PostColorMatrixBias[3] = param;
+ break;
+ case GL_POST_CONVOLUTION_RED_SCALE:
+ ctx->Pixel.PostConvolutionScale[0] = param;
+ break;
+ case GL_POST_CONVOLUTION_RED_BIAS:
+ ctx->Pixel.PostConvolutionBias[0] = param;
+ break;
+ case GL_POST_CONVOLUTION_GREEN_SCALE:
+ ctx->Pixel.PostConvolutionScale[1] = param;
+ break;
+ case GL_POST_CONVOLUTION_GREEN_BIAS:
+ ctx->Pixel.PostConvolutionBias[1] = param;
+ break;
+ case GL_POST_CONVOLUTION_BLUE_SCALE:
+ ctx->Pixel.PostConvolutionScale[2] = param;
+ break;
+ case GL_POST_CONVOLUTION_BLUE_BIAS:
+ ctx->Pixel.PostConvolutionBias[2] = param;
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_SCALE:
+ ctx->Pixel.PostConvolutionScale[2] = param;
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_BIAS:
+ ctx->Pixel.PostConvolutionBias[2] = param;
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" );
ctx->Pixel.ScaleOrBiasRGBA = GL_FALSE;
}
- if (ctx->Pixel.PostColorMatrixRedScale!=1.0F ||
- ctx->Pixel.PostColorMatrixRedBias!=0.0F ||
- ctx->Pixel.PostColorMatrixGreenScale!=1.0F ||
- ctx->Pixel.PostColorMatrixGreenBias!=0.0F ||
- ctx->Pixel.PostColorMatrixBlueScale!=1.0F ||
- ctx->Pixel.PostColorMatrixBlueBias!=0.0F ||
- ctx->Pixel.PostColorMatrixAlphaScale!=1.0F ||
- ctx->Pixel.PostColorMatrixAlphaBias!=0.0F) {
+ if (ctx->Pixel.PostColorMatrixScale[0] != 1.0F ||
+ ctx->Pixel.PostColorMatrixBias[0] != 0.0F ||
+ ctx->Pixel.PostColorMatrixScale[1] != 1.0F ||
+ ctx->Pixel.PostColorMatrixBias[1] != 0.0F ||
+ ctx->Pixel.PostColorMatrixScale[2] != 1.0F ||
+ ctx->Pixel.PostColorMatrixBias[2] != 0.0F ||
+ ctx->Pixel.PostColorMatrixScale[3] != 1.0F ||
+ ctx->Pixel.PostColorMatrixBias[3] != 0.0F) {
ctx->Pixel.ScaleOrBiasRGBApcm = GL_TRUE;
}
else {
void
_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4])
{
- const GLfloat rs = ctx->Pixel.PostColorMatrixRedScale;
- const GLfloat rb = ctx->Pixel.PostColorMatrixRedBias;
- const GLfloat gs = ctx->Pixel.PostColorMatrixGreenScale;
- const GLfloat gb = ctx->Pixel.PostColorMatrixGreenBias;
- const GLfloat bs = ctx->Pixel.PostColorMatrixBlueScale;
- const GLfloat bb = ctx->Pixel.PostColorMatrixBlueBias;
- const GLfloat as = ctx->Pixel.PostColorMatrixAlphaScale;
- const GLfloat ab = ctx->Pixel.PostColorMatrixAlphaBias;
+ const GLfloat rs = ctx->Pixel.PostColorMatrixScale[0];
+ const GLfloat rb = ctx->Pixel.PostColorMatrixBias[0];
+ const GLfloat gs = ctx->Pixel.PostColorMatrixScale[1];
+ const GLfloat gb = ctx->Pixel.PostColorMatrixBias[1];
+ const GLfloat bs = ctx->Pixel.PostColorMatrixScale[2];
+ const GLfloat bb = ctx->Pixel.PostColorMatrixBias[2];
+ const GLfloat as = ctx->Pixel.PostColorMatrixScale[3];
+ const GLfloat ab = ctx->Pixel.PostColorMatrixBias[3];
const GLfloat *m = ctx->ColorMatrix.m;
GLuint i;
for (i = 0; i < n; i++) {
_mesa_lookup_rgba(const struct gl_color_table *table,
GLuint n, GLfloat rgba[][4])
{
+ ASSERT(table->TableType == GL_FLOAT);
+ if (!table->Table)
+ return;
+
switch (table->Format) {
case GL_INTENSITY:
- {
+ /* replace RGBA with I */
+ if (table->TableType == GL_UNSIGNED_BYTE) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLfloat *lut = table->TableF;
+ const GLubyte *lut = (const GLubyte *) table->Table;
GLuint i;
- /* replace RGBA with I */
for (i = 0; i < n; i++) {
GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLubyte c = lut[j];
+ GLfloat c = lut[j] * (1.0F / 255.0F);
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLfloat 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->TableType == GL_UNSIGNED_BYTE) {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = (const GLubyte *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLfloat c = lut[j] * (1.0F / 255.0F);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ else {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLfloat *lut = table->TableF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
- /* replace RGB with L */
for (i = 0; i < n; i++) {
GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
- GLubyte c = lut[j];
+ GLfloat c = lut[j];
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
break;
case GL_ALPHA:
- {
+ /* replace A with A */
+ if (table->TableType == GL_UNSIGNED_BYTE) {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = (const GLubyte *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ rgba[i][ACOMP] = lut[j] * (1.0F / 255.0F);
+ }
+ }
+ else {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLfloat *lut = table->TableF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
- /* replace A with A */
for (i = 0; i < n; i++) {
GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
rgba[i][ACOMP] = lut[j];
}
break;
case GL_LUMINANCE_ALPHA:
- {
+ /* replace RGBA with LLLA */
+ if (table->TableType == GL_UNSIGNED_BYTE) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLfloat *lut = table->TableF;
+ const GLubyte *lut = (const GLubyte *) table->Table;
GLuint i;
- /* replace RGBA with LLLA */
for (i = 0; i < n; i++) {
GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
- GLubyte luminance = lut[jL * 2 + 0];
- GLubyte alpha = lut[jA * 2 + 1];
+ GLfloat luminance = lut[jL * 2 + 0] * (1.0F / 255.0F);
+ GLfloat alpha = lut[jA * 2 + 1] * (1.0F / 255.0F);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
+ rgba[i][ACOMP] = alpha;;
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ GLfloat luminance = lut[jL * 2 + 0];
+ GLfloat 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->TableType == GL_UNSIGNED_BYTE) {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLfloat *lut = table->TableF;
+ const GLubyte *lut = (const GLubyte *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
+ GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ rgba[i][RCOMP] = lut[jR * 3 + 0] * (1.0F / 255.0F);
+ rgba[i][GCOMP] = lut[jG * 3 + 1] * (1.0F / 255.0F);
+ rgba[i][BCOMP] = lut[jB * 3 + 2] * (1.0F / 255.0F);
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
- /* replace RGB with RGB */
for (i = 0; i < n; i++) {
GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
}
break;
case GL_RGBA:
- {
+ /* replace RGBA with RGBA */
+ if (table->TableType == GL_UNSIGNED_BYTE) {
+ const GLfloat scale = (GLfloat) (table->Size - 1);
+ const GLubyte *lut = (const GLubyte *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
+ GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
+ GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+ GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+ rgba[i][RCOMP] = lut[jR * 4 + 0] * (1.0F / 255.0F);
+ rgba[i][GCOMP] = lut[jG * 4 + 1] * (1.0F / 255.0F);
+ rgba[i][BCOMP] = lut[jB * 4 + 2] * (1.0F / 255.0F);
+ rgba[i][ACOMP] = lut[jA * 4 + 3] * (1.0F / 255.0F);
+ }
+ }
+ else {
const GLfloat scale = (GLfloat) (table->Size - 1);
- const GLfloat *lut = table->TableF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
- /* replace RGBA with RGBA */
for (i = 0; i < n; i++) {
GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);