fix GL_BACK color material bug
[mesa.git] / src / mesa / main / image.c
index 23c5b776d81aefa4e9d51326d6cfdb072af363f0..627ab1510e7b35fdc53b38c840272f43d56deeed 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.30 2000/05/04 13:48:49 brianp Exp $ */
+/* $Id: image.c,v 1.32 2000/05/19 22:35:44 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -519,16 +519,19 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
    else {
       /* Non-BITMAP data */
       const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
+      GLint bytesPerRow, remainder;
       if (bytesPerPixel <= 0)
          return -1;  /* error */
       if (packing->RowLength == 0) {
-         GLint bytes = bytesPerPixel * width;
-         return bytes;
+         bytesPerRow = bytesPerPixel * width;
       }
       else {
-         GLint bytes = bytesPerPixel * packing->RowLength;
-         return bytes;
+         bytesPerRow = bytesPerPixel * packing->RowLength;
       }
+      remainder = bytesPerRow % packing->Alignment;
+      if (remainder > 0)
+         bytesPerRow += (packing->Alignment - remainder);
+      return bytesPerRow;
    }
 }
 
@@ -2459,7 +2462,7 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
                                GLenum srcFormat, GLenum srcType,
                                const GLvoid *source,
                                const struct gl_pixelstore_attrib *unpacking,
-                               GLboolean applyTransferOps )
+                               GLboolean applyTransferOps, GLboolean clamp )
 {
    ASSERT(dstFormat == GL_ALPHA ||
           dstFormat == GL_LUMINANCE || 
@@ -2601,7 +2604,7 @@ _mesa_unpack_float_color_span( GLcontext *ctx,
       }
 
       /* clamp to [0,1] */
-      {
+      if (clamp) {
          GLuint i;
          for (i = 0; i < n; i++) {
             rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F);