summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-10-22 17:18:50 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-10-22 17:18:50 +0000
commit0b26e826bda0da7aeec9a79ee07fe21d54bb1263 (patch)
treecad7fe6571832fc55e6916f024aa1d1365ea410f
parent919cd2c3ba39bf4d8d2ffcea0daec7bab8645d34 (diff)
Color clamping fixes.
-rw-r--r--src/mesa/main/blend.c31
-rw-r--r--src/mesa/main/blend.h9
-rw-r--r--src/mesa/main/light.c1
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/swrast/s_readpix.c16
-rw-r--r--src/mesa/swrast/s_span.c2
6 files changed, 52 insertions, 8 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index bf886af9e8..81bd4c2f32 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -516,6 +516,37 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
}
+extern void GLAPIENTRY
+_mesa_ClampColorARB(GLenum target, GLenum clamp)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (clamp != GL_TRUE && clamp != GL_FALSE && clamp != GL_FIXED_ONLY_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(clamp)");
+ return;
+ }
+
+ switch (target) {
+ case GL_CLAMP_VERTEX_COLOR_ARB:
+ ctx->Light.ClampVertexColor = clamp;
+ break;
+ case GL_CLAMP_FRAGMENT_COLOR_ARB:
+ ctx->Color.ClampFragmentColor = clamp;
+ break;
+ case GL_CLAMP_READ_COLOR_ARB:
+ ctx->Color.ClampReadColor = clamp;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(target)");
+ return;
+ }
+}
+
+
+
+
/**********************************************************************/
/** \name Initialization */
/*@{*/
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index d6c03d903f..5c0f2783a7 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -5,9 +5,9 @@
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 6.5.2
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 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"),
@@ -72,6 +72,11 @@ extern void GLAPIENTRY
_mesa_ColorMask( GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha );
+
+extern void GLAPIENTRY
+_mesa_ClampColorARB(GLenum target, GLenum clamp);
+
+
extern void
_mesa_init_color( GLcontext * ctx );
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 63f88b7229..984f7b2abc 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1340,6 +1340,7 @@ _mesa_init_lighting( GLcontext *ctx )
NULL );
ctx->Light.ColorMaterialEnabled = GL_FALSE;
+ ctx->Light.ClampVertexColor = GL_TRUE;
/* Lighting miscellaneous */
ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bedc860599..5a326ff0dc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -888,6 +888,7 @@ struct gl_light_attrib
GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
GLboolean ColorMaterialEnabled;
+ GLenum ClampVertexColor;
struct gl_light EnabledList; /**< List sentinel */
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 0189b0e797..cbfb7712d8 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -202,7 +202,8 @@ fast_read_rgba_pixels( GLcontext *ctx,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing )
+ const struct gl_pixelstore_attrib *packing,
+ GLbitfield transferOps)
{
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
@@ -213,7 +214,7 @@ fast_read_rgba_pixels( GLcontext *ctx,
ASSERT(y + height <= rb->Height);
/* check for things we can't handle here */
- if (ctx->_ImageTransferState ||
+ if (transferOps ||
packing->SwapBytes ||
packing->LsbFirst) {
return GL_FALSE;
@@ -309,15 +310,20 @@ read_rgba_pixels( GLcontext *ctx,
const struct gl_pixelstore_attrib *packing )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLbitfield transferOps = ctx->_ImageTransferState;
+ GLbitfield transferOps = ctx->_ImageTransferState;
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
ASSERT(rb);
+ if (type == GL_FLOAT && ((ctx->Color.ClampReadColor == GL_TRUE) ||
+ (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB &&
+ rb->DataType != GL_FLOAT)))
+ transferOps |= IMAGE_CLAMP_BIT;
+
/* Try optimized path first */
if (fast_read_rgba_pixels(ctx, x, y, width, height,
- format, type, pixels, packing)) {
+ format, type, pixels, packing, transferOps)) {
return; /* done! */
}
@@ -419,7 +425,7 @@ read_rgba_pixels( GLcontext *ctx,
/* pack the row of RGBA pixels into user's buffer */
_mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
- packing, ctx->_ImageTransferState);
+ packing, transferOps);
dst += dstStride;
}
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index ad55e1b10c..2e20f7a296 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1583,7 +1583,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
}
/* Clamp color/alpha values over the range [0.0, 1.0] before storage */
- if (ctx->Color.ClampFragmentColor &&
+ if (ctx->Color.ClampFragmentColor == GL_TRUE &&
span->array->ChanType == GL_FLOAT) {
clamp_colors(span);
}