diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/config.h | 5 | ||||
-rw-r--r-- | src/mesa/main/context.c | 17 | ||||
-rw-r--r-- | src/mesa/main/drawpix.c | 17 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 41 | ||||
-rw-r--r-- | src/mesa/main/get.c | 150 | ||||
-rw-r--r-- | src/mesa/main/image.c | 16 | ||||
-rw-r--r-- | src/mesa/main/matrix.c | 23 | ||||
-rw-r--r-- | src/mesa/main/pixel.c | 77 | ||||
-rw-r--r-- | src/mesa/main/pixel.h | 15 | ||||
-rw-r--r-- | src/mesa/main/state.c | 7 |
10 files changed, 321 insertions, 47 deletions
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index ffafd3e78d6..a27af641a35 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -1,4 +1,4 @@ -/* $Id: config.h,v 1.9 2000/04/07 00:19:41 brianp Exp $ */ +/* $Id: config.h,v 1.10 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -52,6 +52,9 @@ /* Maximum texture matrix stack depth: */ #define MAX_TEXTURE_STACK_DEPTH 10 +/* Maximum color matrix stack depth: */ +#define MAX_COLOR_STACK_DEPTH 4 + /* Maximum attribute stack depth: */ #define MAX_ATTRIB_STACK_DEPTH 16 diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 8c2be5d497e..dfcff91cc29 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.55 2000/04/07 16:27:26 brianp Exp $ */ +/* $Id: context.c,v 1.56 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -853,6 +853,13 @@ static void init_attrib_groups( GLcontext *ctx ) } } + /* Color matrix */ + gl_matrix_ctr(&ctx->ColorMatrix); + ctx->ColorStackDepth = 0; + for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) { + gl_matrix_ctr(&ctx->ColorStack[j]); + } + /* Accumulate buffer group */ ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); @@ -1120,6 +1127,14 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Pixel.PixelTextureEnabled = GL_FALSE; ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS; ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS; + ctx->Pixel.PostColorMatrixRedBias = 0.0; + ctx->Pixel.PostColorMatrixRedScale = 1.0; + ctx->Pixel.PostColorMatrixGreenBias = 0.0; + ctx->Pixel.PostColorMatrixGreenScale = 1.0; + ctx->Pixel.PostColorMatrixBlueBias = 0.0; + ctx->Pixel.PostColorMatrixBlueScale = 1.0; + ctx->Pixel.PostColorMatrixAlphaBias = 0.0; + ctx->Pixel.PostColorMatrixAlphaScale = 1.0; /* Point group */ ctx->Point.SmoothFlag = GL_FALSE; diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index 23479bf321f..ad9ce929f10 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -1,4 +1,4 @@ -/* $Id: drawpix.c,v 1.17 2000/04/07 16:27:26 brianp Exp $ */ +/* $Id: drawpix.c,v 1.18 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -116,15 +116,10 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, return GL_TRUE; } - if (ctx->NewState) { - gl_update_state(ctx); - } - if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0 - && ctx->Pixel.RedBias==0.0 && ctx->Pixel.RedScale==1.0 - && ctx->Pixel.GreenBias==0.0 && ctx->Pixel.GreenScale==1.0 - && ctx->Pixel.BlueBias==0.0 && ctx->Pixel.BlueScale==1.0 - && ctx->Pixel.AlphaBias==0.0 && ctx->Pixel.AlphaScale==1.0 + && !ctx->Pixel.ScaleOrBiasRGBA + && !ctx->Pixel.ScaleOrBiasRGBApcm + && ctx->ColorMatrix.type == MATRIX_IDENTITY && ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0 && ctx->Pixel.MapColorFlag==0 && ctx->Texture.ReallyEnabled == 0 @@ -692,6 +687,10 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, return; } + if (ctx->NewState) { + gl_update_state(ctx); + } + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index d0a30eed370..b2085246f76 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.22 2000/04/07 16:27:26 brianp Exp $ */ +/* $Id: extensions.c,v 1.23 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -49,37 +49,38 @@ struct extension { static struct { int enabled; const char *name; } default_extensions[] = { + { DEFAULT_OFF, "GL_ARB_imaging" }, + { DEFAULT_ON, "GL_ARB_multitexture" }, + { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" }, + { ALWAYS_ENABLED, "GL_EXT_abgr" }, { DEFAULT_ON, "GL_EXT_blend_color" }, - { DEFAULT_OFF, "ARB_imaging" }, - { DEFAULT_ON, "GL_EXT_blend_minmax" }, { DEFAULT_ON, "GL_EXT_blend_logic_op" }, + { DEFAULT_ON, "GL_EXT_blend_minmax" }, { DEFAULT_ON, "GL_EXT_blend_subtract" }, + { DEFAULT_ON, "GL_EXT_clip_volume_hint" }, + { DEFAULT_ON, "GL_EXT_compiled_vertex_array" }, { DEFAULT_ON, "GL_EXT_paletted_texture" }, { DEFAULT_ON, "GL_EXT_point_parameters" }, { ALWAYS_ENABLED, "GL_EXT_polygon_offset" }, - { ALWAYS_ENABLED, "GL_EXT_vertex_array" }, - { ALWAYS_ENABLED, "GL_EXT_texture_object" }, - { DEFAULT_ON, "GL_EXT_texture3D" }, - { ALWAYS_ENABLED, "GL_MESA_window_pos" }, - { ALWAYS_ENABLED, "GL_MESA_resize_buffers" }, - { DEFAULT_ON, "GL_EXT_shared_texture_palette" }, { ALWAYS_ENABLED, "GL_EXT_rescale_normal" }, - { ALWAYS_ENABLED, "GL_EXT_abgr" }, - { ALWAYS_ENABLED, "GL_SGIS_texture_edge_clamp" }, + { DEFAULT_ON, "GL_EXT_shared_texture_palette" }, { ALWAYS_ENABLED, "GL_EXT_stencil_wrap" }, - { DEFAULT_ON, "GL_INGR_blend_func_separate" }, - { DEFAULT_ON, "GL_ARB_multitexture" }, - { ALWAYS_ENABLED, "GL_NV_texgen_reflection" }, - { DEFAULT_ON, "GL_PGI_misc_hints" }, - { DEFAULT_ON, "GL_EXT_compiled_vertex_array" }, - { DEFAULT_ON, "GL_EXT_clip_volume_hint" }, - { DEFAULT_ON, "GL_EXT_texture_env_add" }, - { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" }, - { DEFAULT_OFF, "GL_EXT_vertex_array_set" }, + { DEFAULT_ON, "GL_EXT_texture3D" }, { DEFAULT_OFF, "GL_EXT_texture_env" }, + { DEFAULT_ON, "GL_EXT_texture_env_add" }, + { ALWAYS_ENABLED, "GL_EXT_texture_object" }, { DEFAULT_ON, "GL_EXT_texture_lod_bias" }, + { ALWAYS_ENABLED, "GL_EXT_vertex_array" }, + { DEFAULT_OFF, "GL_EXT_vertex_array_set" }, { DEFAULT_OFF, "GL_HP_occlusion_test" }, + { DEFAULT_ON, "GL_INGR_blend_func_separate" }, + { ALWAYS_ENABLED, "GL_MESA_window_pos" }, + { ALWAYS_ENABLED, "GL_MESA_resize_buffers" }, + { ALWAYS_ENABLED, "GL_NV_texgen_reflection" }, + { DEFAULT_ON, "GL_PGI_misc_hints" }, + { DEFAULT_ON, "GL_SGI_color_matrix" }, { DEFAULT_ON, "GL_SGIS_pixel_texture" }, + { DEFAULT_ON, "GL_SGIS_texture_edge_clamp" }, { DEFAULT_ON, "GL_SGIX_pixel_texture" } }; diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index de7b108df84..ec4f39fe2aa 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.18 2000/04/07 16:27:26 brianp Exp $ */ +/* $Id: get.c,v 1.19 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1077,6 +1077,43 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = (GLboolean) pixel_texgen_mode(ctx); break; + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(ctx->ColorMatrix.m[i]); + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = INT_TO_BOOL(ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = FLOAT_TO_BOOL(MAX_COLOR_STACK_DEPTH); + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixRedScale); + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixGreenScale); + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBlueScale); + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixAlphaScale); + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixRedBias); + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixGreenBias); + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBlueBias); + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixAlphaBias); + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); } @@ -2082,6 +2119,43 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) pixel_texgen_mode(ctx); break; + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = (GLdouble) ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLdouble) (ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLdouble) MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixRedScale; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixGreenScale; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBlueScale; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixAlphaScale; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixRedBias; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixGreenBias; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBlueBias; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixAlphaBias; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); } @@ -3064,6 +3138,43 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) pixel_texgen_mode(ctx); break; + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLfloat) (ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLfloat) MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixRedScale; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixGreenScale; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixBlueScale; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixAlphaScale; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixRedBias; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixGreenBias; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixBlueBias; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixAlphaBias; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); } @@ -4069,6 +4180,43 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = (GLint) pixel_texgen_mode(ctx); break; + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = (GLint) ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = ctx->ColorStackDepth + 1; + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixRedScale; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixGreenScale; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBlueScale; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixAlphaScale; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixRedBias; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixGreenBias; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBlueBias; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixAlphaBias; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); } diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index e0879be5e3e..28720be9f65 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.24 2000/03/29 15:56:53 brianp Exp $ */ +/* $Id: image.c,v 1.25 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2154,12 +2154,13 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, srcType == GL_UNSIGNED_INT_10_10_10_2 || srcType == GL_UNSIGNED_INT_2_10_10_10_REV); - /* this is intended for RGBA mode */ + /* this is intended for RGBA mode only */ assert(ctx->Visual->RGBAflag); applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag || - ctx->Pixel.MapColorFlag); + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm); /* Try simple cases first */ if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) { @@ -2265,11 +2266,16 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, if (applyTransferOps) { /* scale and bias colors */ - gl_scale_and_bias_rgba_float(ctx, n, rgba); + _mesa_scale_and_bias_rgba_float(ctx, n, rgba); /* color table lookup */ if (ctx->Pixel.MapColorFlag) { - gl_map_rgba_float(ctx, n, rgba); + _mesa_map_rgba_float(ctx, n, rgba); + } + + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); } } } diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index c8f25c0cd5a..5eb5bb43f0c 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,4 +1,4 @@ -/* $Id: matrix.c,v 1.16 2000/03/03 17:47:39 brianp Exp $ */ +/* $Id: matrix.c,v 1.17 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -931,6 +931,10 @@ do { \ mat = &ctx->TextureMatrix[ctx->Texture.CurrentTransformUnit]; \ flags |= NEW_TEXTURE_MATRIX; \ break; \ + case GL_COLOR: \ + mat = &ctx->ColorMatrix; \ + flags |= NEW_COLOR_MATRIX; \ + break; \ default: \ gl_problem(ctx, where); \ } \ @@ -1037,6 +1041,7 @@ _mesa_MatrixMode( GLenum mode ) case GL_MODELVIEW: case GL_PROJECTION: case GL_TEXTURE: + case GL_COLOR: ctx->Transform.MatrixMode = mode; break; default: @@ -1090,6 +1095,14 @@ _mesa_PushMatrix( void ) &ctx->TextureMatrix[t] ); } break; + case GL_COLOR: + if (ctx->ColorStackDepth >= MAX_COLOR_STACK_DEPTH - 1) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); + return; + } + gl_matrix_copy( &ctx->ColorStack[ctx->ColorStackDepth++], + &ctx->ColorMatrix ); + break; default: gl_problem(ctx, "Bad matrix mode in gl_PushMatrix"); } @@ -1147,6 +1160,14 @@ _mesa_PopMatrix( void ) &ctx->TextureStack[t][--ctx->TextureStackDepth[t]]); } break; + case GL_COLOR: + if (ctx->ColorStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix"); + return; + } + gl_matrix_copy(&ctx->ColorMatrix, + &ctx->ColorStack[--ctx->ColorStackDepth]); + break; default: gl_problem(ctx, "Bad matrix mode in gl_PopMatrix"); } diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 1651fe1190c..213aa2c8944 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, diff --git a/src/mesa/main/pixel.h b/src/mesa/main/pixel.h index 841c98258f0..b40af4929f6 100644 --- a/src/mesa/main/pixel.h +++ b/src/mesa/main/pixel.h @@ -1,4 +1,4 @@ -/* $Id: pixel.h,v 1.3 1999/11/11 01:22:27 brianp Exp $ */ +/* $Id: pixel.h,v 1.4 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -85,15 +85,20 @@ extern void gl_scale_and_bias_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ); -extern void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, - GLfloat rgba[][4] ); +extern void +_mesa_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, + GLfloat rgba[][4] ); extern void gl_map_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ); -extern void gl_map_rgba_float( const GLcontext *ctx, GLuint n, - GLfloat rgba[][4] ); +extern void +_mesa_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ); + + +extern void +_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); extern void gl_map_color( const GLcontext *ctx, GLuint n, diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 990cd4d31c4..4f59d3d1095 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $Id: state.c,v 1.7 2000/04/07 16:27:26 brianp Exp $ */ +/* $Id: state.c,v 1.8 2000/04/08 18:57:45 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1148,6 +1148,11 @@ void gl_update_state( GLcontext *ctx ) ctx->ModelProjectWinMatrixUptodate = 0; } + if (ctx->NewState & NEW_COLOR_MATRIX) { + gl_matrix_analyze( &ctx->ColorMatrix ); + printf("analyze color matrix %x %x\n", ctx->ColorMatrix.flags, ctx->ColorMatrix.type); + } + /* Figure out whether we can light in object space or not. If we * can, find the current positions of the lights in object space */ |