New IMAGE_RED_TO_LUMINANCE flag passed to _mesa_pack_rgba_span_float() to fix glGetTe...
authorBrian <brian@yutani.localnet.net>
Fri, 9 Mar 2007 16:08:41 +0000 (09:08 -0700)
committerBrian <brian@yutani.localnet.net>
Fri, 9 Mar 2007 16:13:49 +0000 (09:13 -0700)
src/mesa/main/image.c
src/mesa/main/mtypes.h
src/mesa/main/texstore.c

index fc8e1f0f574e6b80698672f4bc1620165dbe0069..eb91ebb61106d3d6749da7ab7ab3338c99f52ea2 100644 (file)
@@ -1182,15 +1182,24 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
 
    if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
       /* compute luminance values */
-      if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) {
+      if (transferOps & IMAGE_RED_TO_LUMINANCE) {
+         /* Luminance = Red (glGetTexImage) */
          for (i = 0; i < n; i++) {
-            GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
-            luminance[i] = CLAMP(sum, 0.0F, 1.0F);
+            luminance[i] = rgba[i][RCOMP];
          }
       }
       else {
-         for (i = 0; i < n; i++) {
-            luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+         /* Luminance = Red + Green + Blue (glReadPixels) */
+         if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) {
+            for (i = 0; i < n; i++) {
+               GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+               luminance[i] = CLAMP(sum, 0.0F, 1.0F);
+            }
+         }
+         else {
+            for (i = 0; i < n; i++) {
+               luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+            }
          }
       }
    }
index 422d176c25abc56dcd9969fb5ed943f0575a8c94..7caa1f8d7ff3c90b7aa239fffc2180046a447417 100644 (file)
@@ -2540,6 +2540,7 @@ struct matrix_stack
 #define IMAGE_HISTOGRAM_BIT                       0x200
 #define IMAGE_MIN_MAX_BIT                         0x400
 #define IMAGE_CLAMP_BIT                           0x800 /* extra */
+#define IMAGE_RED_TO_LUMINANCE                    0x1000
 
 
 /** Pixel Transfer ops up to convolution */
index 87f8fa7a0d457ce0f6b19ccd79fb3a4b15f0a07a..994fb1673064370d9628a182d073be26726b4348 100644 (file)
@@ -3611,7 +3611,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, 0x0 /*image xfer ops*/);
+                                          &ctx->Pack, IMAGE_RED_TO_LUMINANCE);
             } /* format */
          } /* row */
       } /* img */