move a comment
[mesa.git] / src / mesa / swrast / s_pixeltex.c
index 82afab9ae932932f20e9dac90c773174b775f079..776a38c9153532a3317657decb328fd31ba3889e 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id: s_pixeltex.c,v 1.6 2002/01/28 04:25:56 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -35,7 +34,7 @@
 
 #include "glheader.h"
 #include "colormac.h"
-#include "mem.h"
+#include "imports.h"
 
 #include "s_context.h"
 #include "s_pixeltex.h"
@@ -85,42 +84,34 @@ pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
 
 
 /*
- * Used byglDraw/CopyPixels: the incoming image colors are treated
+ * Used by glDraw/CopyPixels: the incoming image colors are treated
  * as texture coordinates.  Use those coords to texture the image.
  * This is for GL_SGIS_pixel_texture / GL_SGIX_pixel_texture.
  */
 void
 _swrast_pixel_texture(GLcontext *ctx, struct sw_span *span)
 {
-   if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
-      /* multitexture! */
-      GLchan primary_rgba[MAX_WIDTH][4];
-      GLuint unit;
-
-      MEMCPY(primary_rgba, span->color.rgba, 4 * span->end * sizeof(GLchan));
-      
-      for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
-         if (ctx->Texture.Unit[unit]._ReallyEnabled) {
-            pixeltexgen(ctx, span->end,
-                        (const GLchan (*)[4]) span->color.rgba,
-                        span->texcoords[unit]);
-            _swrast_texture_fragments(ctx, unit, span->end,
-                                          span->texcoords[unit],
-                                          span->lambda[unit],
-                                          (CONST GLchan (*)[4]) primary_rgba,
-                                          span->color.rgba);
-         }
+   GLuint unit;
+
+   ASSERT(!(span->arrayMask & SPAN_TEXTURE));
+   span->arrayMask |= SPAN_TEXTURE;
+
+   /* convert colors into texture coordinates */
+   pixeltexgen( ctx, span->end,
+                (const GLchan (*)[4]) span->array->rgba,
+                span->array->texcoords[0] );
+
+   /* copy the new texture units for all enabled units */
+   for (unit = 1; unit < ctx->Const.MaxTextureUnits; unit++) {
+      if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+         MEMCPY( span->array->texcoords[unit], span->array->texcoords[0],
+                 span->end * 4 * sizeof(GLfloat) );
       }
    }
-   else {
-      /* single texture, unit 0 */
-      ASSERT(ctx->Texture._ReallyEnabled & TEXTURE0_ANY);
-      pixeltexgen(ctx, span->end,
-                  (const GLchan (*)[4]) span->color.rgba,
-                  span->texcoords[0]);
-      _swrast_texture_fragments(ctx, 0, span->end,
-                                    span->texcoords[0], span->lambda[0],
-                                    (CONST GLchan (*)[4]) span->color.rgba,
-                                    (GLchan (*)[4]) span->color.rgba);
-   }
+
+   /* apply texture mapping */
+   _swrast_texture_span( ctx, span );
+
+   /* this is a work-around to be fixed by initializing again span */
+   span->arrayMask &= ~SPAN_TEXTURE;
 }