summaryrefslogtreecommitdiff
path: root/src/mesa/main/pixel.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-04-08 18:57:45 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-04-08 18:57:45 +0000
commit250069dbb443f26f4dcc409c9c873019a5f50f9d (patch)
tree605c5ed78350822c85fef87230b5a3999d02b208 /src/mesa/main/pixel.c
parenta518b47e5bcff6e3feaeb378ccb06fd1ea1da760 (diff)
added GL_SGI_color_matrix extension
Diffstat (limited to 'src/mesa/main/pixel.c')
-rw-r--r--src/mesa/main/pixel.c77
1 files changed, 74 insertions, 3 deletions
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 1651fe1190..213aa2c894 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.5 1999/11/11 01:22:27 brianp Exp $ */
+/* $Id: pixel.c,v 1.6 2000/04/08 18:57:45 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -562,6 +562,30 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param )
case GL_DEPTH_BIAS:
ctx->Pixel.DepthBias = param;
break;
+ case GL_POST_COLOR_MATRIX_RED_SCALE:
+ ctx->Pixel.PostColorMatrixRedScale = param;
+ break;
+ case GL_POST_COLOR_MATRIX_RED_BIAS:
+ ctx->Pixel.PostColorMatrixRedBias = param;
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_SCALE:
+ ctx->Pixel.PostColorMatrixGreenScale = param;
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_BIAS:
+ ctx->Pixel.PostColorMatrixGreenBias = param;
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_SCALE:
+ ctx->Pixel.PostColorMatrixBlueScale = param;
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_BIAS:
+ ctx->Pixel.PostColorMatrixBlueBias = param;
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_SCALE:
+ ctx->Pixel.PostColorMatrixAlphaScale = param;
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_BIAS:
+ ctx->Pixel.PostColorMatrixAlphaBias = param;
+ break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" );
return;
@@ -576,6 +600,20 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param )
else {
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) {
+ ctx->Pixel.ScaleOrBiasRGBApcm = GL_TRUE;
+ }
+ else {
+ ctx->Pixel.ScaleOrBiasRGBApcm = GL_FALSE;
+ }
}
@@ -640,7 +678,9 @@ void gl_scale_and_bias_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] )
/*
* Apply scale and bias factors to an array of RGBA pixels.
*/
-void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
+void
+_mesa_scale_and_bias_rgba_float(const GLcontext *ctx, GLuint n,
+ GLfloat rgba[][4])
{
if (ctx->Pixel.RedScale != 1.0 || ctx->Pixel.RedBias != 0.0) {
const GLfloat scale = ctx->Pixel.RedScale;
@@ -703,7 +743,8 @@ void gl_map_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] )
/*
* Apply pixel mapping to an array of floating point RGBA pixels.
*/
-void gl_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
+void
+_mesa_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
{
const GLfloat rscale = ctx->Pixel.MapRtoRsize - 1;
const GLfloat gscale = ctx->Pixel.MapGtoGsize - 1;
@@ -724,6 +765,36 @@ void gl_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
/*
+ * Apply the color matrix and post color matrix scaling and biasing.
+ */
+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 *m = ctx->ColorMatrix.m;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLfloat r = rgba[i][RCOMP];
+ const GLfloat g = rgba[i][GCOMP];
+ const GLfloat b = rgba[i][BCOMP];
+ const GLfloat a = rgba[i][ACOMP];
+ rgba[i][RCOMP] = (m[0] * r + m[4] * g + m[ 8] * b + m[12] * a) * rs + rb;
+ rgba[i][GCOMP] = (m[1] * r + m[5] * g + m[ 9] * b + m[13] * a) * gs + gb;
+ rgba[i][BCOMP] = (m[2] * r + m[6] * g + m[10] * b + m[14] * a) * bs + bb;
+ rgba[i][ACOMP] = (m[3] * r + m[7] * g + m[11] * b + m[15] * a) * as + ab;
+ }
+}
+
+
+
+/*
* Apply pixel mapping to an array of RGBA pixels.
*/
void gl_map_color( const GLcontext *ctx, GLuint n,