diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2004-02-28 22:30:58 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2004-02-28 22:30:58 +0000 |
commit | 4923e1926ad7b7eb7de017eda8e7db64d357e5c8 (patch) | |
tree | 7bd9696c56a62747e9e7c7d57295ca315dba0922 /src/mesa/main | |
parent | 94f9d4c0dd2b62e01032c2b0dd9b8a25466690c2 (diff) |
Remove clamp parameter from _mesa_unpack_color_span_float(). Pass the
IMAGE_CLAMP_BIT if needed.
Added ClampVertexColors and ClampFragmentColors to GLcontext in anticipation
of upcoming extensions (not fully used yet).
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/colortab.c | 3 | ||||
-rw-r--r-- | src/mesa/main/context.c | 6 | ||||
-rw-r--r-- | src/mesa/main/convolve.c | 12 | ||||
-rw-r--r-- | src/mesa/main/image.c | 32 | ||||
-rw-r--r-- | src/mesa/main/image.h | 10 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 6 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 5 |
7 files changed, 39 insertions, 35 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index af7aa00512..862f210bb9 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -204,8 +204,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, tempTab, /* dest address */ format, type, data, /* src data */ &ctx->Unpack, - 0, /* transfer ops */ - GL_FALSE); /* clamping */ + IMAGE_CLAMP_BIT); /* transfer ops */ tableF = (GLfloat *) table->Table; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 7de8115ad1..951763642b 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1133,6 +1133,12 @@ init_attrib_groups( GLcontext *ctx ) ctx->ErrorValue = (GLenum) GL_NO_ERROR; ctx->CatchSignals = GL_TRUE; ctx->_Facing = 0; +#if CHAN_TYPE == GL_FLOAT + ctx->ClampFragmentColors = GL_FALSE; /* XXX temporary */ +#else + ctx->ClampFragmentColors = GL_TRUE; +#endif + ctx->ClampVertexColors = GL_TRUE; return GL_TRUE; } diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index edb02482b3..c1965c5feb 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -146,7 +146,7 @@ _mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, G _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Convolution1D.Filter, format, type, image, &ctx->Unpack, - 0, GL_FALSE); + 0); /* transferOps */ /* apply scale and bias */ { @@ -229,7 +229,7 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4; _mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst, format, type, src, &ctx->Unpack, - 0, GL_FALSE); + 0); /* transferOps */ } /* apply scale and bias */ @@ -810,7 +810,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs _mesa_unpack_color_span_float(ctx, width, GL_RGBA, ctx->Separable2D.Filter, format, type, row, &ctx->Unpack, - 0, GL_FALSE); + 0); /* transferOps */ /* apply scale and bias */ { @@ -837,7 +837,7 @@ _mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLs _mesa_unpack_color_span_float(ctx, width, GL_RGBA, &ctx->Separable2D.Filter[colStart], format, type, column, &ctx->Unpack, - 0, GL_FALSE); + 0); /* transferOps */ /* apply scale and bias */ { diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ba5b4ff17a..5c117f6ce6 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -972,8 +972,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps, if (transferOps & IMAGE_MIN_MAX_BIT) { _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba); } - -#if CHAN_TYPE != GL_FLOAT + /* clamping to [0,1] */ if (transferOps & IMAGE_CLAMP_BIT) { GLuint i; for (i = 0; i < n; i++) { @@ -983,7 +982,6 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps, rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); } } -#endif } @@ -1026,17 +1024,18 @@ _mesa_pack_rgba_span_float( GLcontext *ctx, rgba = (const GLfloat (*)[4]) rgbaIn; } - /* XXX clamp rgba to [0,1]? */ - if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { /* compute luminance values */ - for (i = 0; i < n; i++) { - GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; -#if CHAN_TYPE == GL_FLOAT - luminance[i] = sum; -#else - luminance[i] = CLAMP(sum, 0.0F, 1.0F); -#endif + if (ctx->ClampFragmentColors) { + for (i = 0; i < n; i++) { + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + luminance[i] = CLAMP(sum, 0.0F, 1.0F); + } + } + else { + for (i = 0; i < n; i++) { + luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + } } } @@ -2942,6 +2941,7 @@ _mesa_unpack_color_span_chan( GLcontext *ctx, srcPacking->SwapBytes); } + /* Need to clamp if returning GLubytes or GLushorts */ #if CHAN_TYPE != GL_FLOAT transferOps |= IMAGE_CLAMP_BIT; #endif @@ -3069,7 +3069,7 @@ _mesa_unpack_color_span_float( GLcontext *ctx, GLenum srcFormat, GLenum srcType, const GLvoid *source, const struct gl_pixelstore_attrib *srcPacking, - GLuint transferOps, GLboolean clamp ) + GLuint transferOps ) { ASSERT(dstFormat == GL_ALPHA || dstFormat == GL_LUMINANCE || @@ -3169,12 +3169,6 @@ _mesa_unpack_color_span_float( GLcontext *ctx, srcPacking->SwapBytes); } -#if CHAN_TYPE != GL_FLOAT - if (clamp) { - transferOps |= IMAGE_CLAMP_BIT; - } -#endif - if (transferOps) { _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); } diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index cd79d5f223..b3757a30fd 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -110,10 +110,10 @@ _mesa_pack_rgba_span_float( GLcontext *ctx, extern void _mesa_pack_rgba_span_chan( GLcontext *ctx, - GLuint n, CONST GLchan rgba[][4], - GLenum dstFormat, GLenum dstType, GLvoid *dstAddr, - const struct gl_pixelstore_attrib *dstPacking, - GLuint transferOps ); + GLuint n, CONST GLchan rgba[][4], + GLenum dstFormat, GLenum dstType, GLvoid *dstAddr, + const struct gl_pixelstore_attrib *dstPacking, + GLuint transferOps ); extern void @@ -131,7 +131,7 @@ _mesa_unpack_color_span_float( GLcontext *ctx, GLenum srcFormat, GLenum srcType, const GLvoid *source, const struct gl_pixelstore_attrib *srcPacking, - GLuint transferOps, GLboolean clamp ); + GLuint transferOps ); extern void diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d1cfa4597b..1c03a05606 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2319,6 +2319,12 @@ struct __GLcontextRec { GLfloat MRD; /**< minimum resolvable difference in Z values */ /*@}*/ + /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */ + /*@{*/ + GLboolean ClampFragmentColors; + GLboolean ClampVertexColors; + /*@}*/ + /** Should 3Dfx Glide driver catch signals? */ GLboolean CatchSignals; diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 61bbc10bf6..315cd6ca2d 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -360,9 +360,8 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions, srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dstf, - srcFormat, srcType, src, srcPacking, - transferOps & IMAGE_PRE_CONVOLUTION_BITS, - GL_TRUE); + srcFormat, srcType, src, srcPacking, + (transferOps & IMAGE_PRE_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT); dstf += srcWidth * 4; } |