aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/image.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-02-28 22:30:58 +0000
committerBrian Paul <[email protected]>2004-02-28 22:30:58 +0000
commit4923e1926ad7b7eb7de017eda8e7db64d357e5c8 (patch)
tree7bd9696c56a62747e9e7c7d57295ca315dba0922 /src/mesa/main/image.c
parent94f9d4c0dd2b62e01032c2b0dd9b8a25466690c2 (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/image.c')
-rw-r--r--src/mesa/main/image.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index ba5b4ff17ad..5c117f6ce6a 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);
}