From 3c14ec9b553f88a4cd4be5d8a564b54bbe81d2b4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 30 Oct 1999 08:20:57 +0000 Subject: added a few more scale/bias/lookup functions (for future use) --- src/mesa/main/pixel.c | 107 +++++++++++++++++++++++++++++++++++++++++++++----- src/mesa/main/pixel.h | 15 ++++++- 2 files changed, 111 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 90257b7f3d..0952f8cbe9 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,4 +1,4 @@ -/* $Id: pixel.c,v 1.2 1999/10/08 09:27:11 keithw Exp $ */ +/* $Id: pixel.c,v 1.3 1999/10/30 08:20:57 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -588,6 +588,46 @@ 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] ) +{ + if (ctx->Pixel.RedScale != 1.0 || ctx->Pixel.RedBias != 0.0) { + const GLfloat scale = ctx->Pixel.RedScale; + const GLfloat bias = ctx->Pixel.RedBias; + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = rgba[i][RCOMP] * scale + bias; + } + } + if (ctx->Pixel.GreenScale != 1.0 || ctx->Pixel.GreenBias != 0.0) { + const GLfloat scale = ctx->Pixel.GreenScale; + const GLfloat bias = ctx->Pixel.GreenBias; + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][GCOMP] = rgba[i][GCOMP] * scale + bias; + } + } + if (ctx->Pixel.BlueScale != 1.0 || ctx->Pixel.BlueBias != 0.0) { + const GLfloat scale = ctx->Pixel.BlueScale; + const GLfloat bias = ctx->Pixel.BlueBias; + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][BCOMP] = rgba[i][BCOMP] * scale + bias; + } + } + if (ctx->Pixel.AlphaScale != 1.0 || ctx->Pixel.AlphaBias != 0.0) { + const GLfloat scale = ctx->Pixel.AlphaScale; + const GLfloat bias = ctx->Pixel.AlphaBias; + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = rgba[i][ACOMP] * scale + bias; + } + } +} + + /* * Apply pixel mapping to an array of RGBA pixels. */ @@ -611,6 +651,29 @@ 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] ) +{ + const GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; + const GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; + const GLfloat bscale = ctx->Pixel.MapBtoBsize - 1; + const GLfloat ascale = ctx->Pixel.MapAtoAsize - 1; + const GLfloat *rMap = ctx->Pixel.MapRtoR; + const GLfloat *gMap = ctx->Pixel.MapGtoG; + const GLfloat *bMap = ctx->Pixel.MapBtoB; + const GLfloat *aMap = ctx->Pixel.MapAtoA; + GLuint i; + for (i=0;iPixel.MapRtoRsize-1; - GLfloat gscale = ctx->Pixel.MapGtoGsize-1; - GLfloat bscale = ctx->Pixel.MapBtoBsize-1; - GLfloat ascale = ctx->Pixel.MapAtoAsize-1; + GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; + GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; + GLfloat bscale = ctx->Pixel.MapBtoBsize - 1; + GLfloat ascale = ctx->Pixel.MapAtoAsize - 1; GLuint i; for (i=0;iPixel.MapRtoR[ (GLint) (red[i] * rscale) ]; - green[i] = ctx->Pixel.MapGtoG[ (GLint) (green[i] * gscale) ]; - blue[i] = ctx->Pixel.MapBtoB[ (GLint) (blue[i] * bscale) ]; - alpha[i] = ctx->Pixel.MapAtoA[ (GLint) (alpha[i] * ascale) ]; + red[i] = ctx->Pixel.MapRtoR[ (GLint) (red[i] * rscale + 0.5F) ]; + green[i] = ctx->Pixel.MapGtoG[ (GLint) (green[i] * gscale + 0.5F) ]; + blue[i] = ctx->Pixel.MapBtoB[ (GLint) (blue[i] * bscale + 0.5F) ]; + alpha[i] = ctx->Pixel.MapAtoA[ (GLint) (alpha[i] * ascale + 0.5F) ]; } } @@ -674,7 +737,7 @@ void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) /* - * Map color indexes to rgb values. + * Map color indexes to rgba values. */ void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[], GLubyte rgba[][4] ) @@ -697,6 +760,30 @@ void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[], } +/* + * Map color indexes to float rgba values. + */ +void gl_map_ci_to_rgba_float( const GLcontext *ctx, GLuint n, const GLuint index[], + GLfloat rgba[][4] ) +{ + GLuint rmask = ctx->Pixel.MapItoRsize - 1; + GLuint gmask = ctx->Pixel.MapItoGsize - 1; + GLuint bmask = ctx->Pixel.MapItoBsize - 1; + GLuint amask = ctx->Pixel.MapItoAsize - 1; + const GLfloat *rMap = ctx->Pixel.MapItoR; + const GLfloat *gMap = ctx->Pixel.MapItoG; + const GLfloat *bMap = ctx->Pixel.MapItoB; + const GLfloat *aMap = ctx->Pixel.MapItoA; + GLuint i; + for (i=0;i