mesa: clamp colors to [0,1] for glGetTexImage() when format is GL_LUMINANCE
authorBrian Paul <brianp@vmware.com>
Fri, 3 Apr 2009 23:10:31 +0000 (17:10 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 3 Apr 2009 23:10:31 +0000 (17:10 -0600)
For luminance, we add R+G+B and it seems we should always clamp in case.

src/mesa/main/texstore.c

index c65b9a99d8c7deac258a8c9af30164b186f0faa6..28e9d5c3ecbda43ffa80b624a805eb88a906ac07 100644 (file)
@@ -4115,9 +4115,11 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
                 * Looks like we need clamp though when going from format
                 * containing negative values to unsigned format.
                 */
-               if (!type_with_negative_values(type) &&
-                   (texImage->TexFormat->DataType == GL_FLOAT ||
-                   texImage->TexFormat->DataType == GL_SIGNED_NORMALIZED))
+               if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA)
+                  transferOps |= IMAGE_CLAMP_BIT;
+               else if (!type_with_negative_values(type) &&
+                        (texImage->TexFormat->DataType == GL_FLOAT ||
+                         texImage->TexFormat->DataType == GL_SIGNED_NORMALIZED))
                   transferOps |= IMAGE_CLAMP_BIT;
 
                for (col = 0; col < width; col++) {
@@ -4144,7 +4146,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
                }
                _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
                                           format, type, dest,
-                                          &ctx->Pack, transferOps, GL_TRUE);
+                                          &ctx->Pack, transferOps, GL_FALSE);
             } /* format */
          } /* row */
       } /* img */