diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/blend.c | 31 | ||||
-rw-r--r-- | src/mesa/main/blend.h | 9 | ||||
-rw-r--r-- | src/mesa/main/light.c | 1 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 1 | ||||
-rw-r--r-- | src/mesa/swrast/s_readpix.c | 16 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 2 |
6 files changed, 52 insertions, 8 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index bf886af9e81..81bd4c2f320 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 d6c03d903f4..5c0f2783a73 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 63f88b7229f..984f7b2abc4 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 bedc8605992..5a326ff0dc9 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 0189b0e797d..cbfb7712d82 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 ad55e1b10c3..2e20f7a2965 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); } |