summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_copypix.c
diff options
context:
space:
mode:
authorBrian <brian@i915.localnet.net>2007-06-21 09:15:32 -0600
committerBrian <brian@i915.localnet.net>2007-06-21 09:15:32 -0600
commit171dcdfa27dda30916a7f9bfed89577feee5d350 (patch)
tree88624d960231df741ceaa2e5ed2005ebb97d7e22 /src/mesa/swrast/s_copypix.c
parentfe11b2c04bf206bd50654c31e6789519c6c07563 (diff)
Another round of fixing attribute interpolation for glDraw/CopyPixels.
Need to turn off FRAG_BIT_COL0 in swrast->_ActiveAttribMask when doing glRead/CopyPixels to prevent the user's colors from getting overwritten when a fragment program is active. This was happening in the DRI drivers when MaintainTexEnv program was used (the texenv fragment program was enabled when _swrast_DrawPixels was called). This still isn't an ideal solution, but fixes things for now.
Diffstat (limited to 'src/mesa/swrast/s_copypix.c')
-rw-r--r--src/mesa/swrast/s_copypix.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index 53e584b3b6..2383015000 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -188,6 +188,8 @@ static void
copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLbitfield prevActiveAttribs = swrast->_ActiveAttribMask;
GLfloat *tmpImage, *p;
GLint sy, dy, stepy, row;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
@@ -197,12 +199,15 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (!ctx->ReadBuffer->_ColorReadBuffer) {
/* no readbuffer - OK */
- return;
+ goto end;
}
+ /* don't interpolate COL0 and overwrite the glDrawPixel colors! */
+ swrast->_ActiveAttribMask &= ~FRAG_BIT_COL0;
+
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
- return;
+ goto end;
}
else if (ctx->Pixel.Convolution1DEnabled) {
/* make sure we don't apply 1D convolution */
@@ -239,7 +244,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4);
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
- return;
+ goto end;
}
/* read the source image as RGBA/float */
p = tmpImage;
@@ -294,6 +299,9 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (overlapping)
_mesa_free(tmpImage);
+
+end:
+ swrast->_ActiveAttribMask = prevActiveAttribs;
}