From 062bc07bde9520d12c3cc051779d67a9543c0ff7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 13 Dec 2000 00:46:21 +0000 Subject: improved precision of glReadPixels for colorbuffers < 24bpp --- src/mesa/swrast/s_readpix.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/mesa/swrast/s_readpix.c') diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 4c5e154b8f..4cc3dbd618 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); + } } } -- cgit v1.2.3