summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2000-12-13 00:46:21 +0000
committerBrian Paul <[email protected]>2000-12-13 00:46:21 +0000
commit062bc07bde9520d12c3cc051779d67a9543c0ff7 (patch)
tree56136cced70d284b7f14b57b3be752b80375bc43 /src/mesa/swrast
parent75639547e70f45b7782cf528b118a39b82b06ba3 (diff)
improved precision of glReadPixels for colorbuffers < 24bpp
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_readpix.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 4c5e154b8fd..4cc3dbd6181 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_readpix.c,v 1.4 2000/11/28 00:04:39 brianp Exp $ */
+/* $Id: s_readpix.c,v 1.5 2000/12/13 00:46:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -716,9 +716,27 @@ static void read_rgba_pixels( GLcontext *ctx,
}
dst = _mesa_image_address(packing, pixels, width, height,
format, type, 0, row, 0);
- _mesa_pack_rgba_span(ctx, readWidth, (const GLchan (*)[4]) rgba,
- format, type, dst, packing,
- ctx->_ImageTransferState);
+ if (ctx->Visual.RedBits < CHAN_BITS ||
+ ctx->Visual.GreenBits < CHAN_BITS ||
+ ctx->Visual.BlueBits < CHAN_BITS) {
+ /* Requantize the color values into floating point and go from
+ * there. This fixes conformance failures with 16-bit color
+ * buffers, for example.
+ */
+ GLfloat rgbaf[MAX_WIDTH][4];
+ _mesa_chan_to_float_span(ctx, readWidth,
+ (CONST GLchan (*)[4]) rgba, rgbaf);
+ _mesa_pack_float_rgba_span(ctx, readWidth,
+ (CONST GLfloat (*)[4]) rgbaf,
+ format, type, dst, packing,
+ ctx->_ImageTransferState);
+ }
+ else {
+ /* GLubytes are fine */
+ _mesa_pack_rgba_span(ctx, readWidth, (CONST GLchan (*)[4]) rgba,
+ format, type, dst, packing,
+ ctx->_ImageTransferState);
+ }
}
}