added missing \'s
[mesa.git] / src / mesa / swrast / s_drawpix.c
index e914eb70136e89c8d5749f3e860a1916134fef27..e618dc0a233b0c4fe4581fbfbc876eb5e63075a0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.18 2001/05/15 21:30:27 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.22 2001/06/26 21:15:36 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -37,6 +37,7 @@
 
 #include "s_context.h"
 #include "s_drawpix.h"
+#include "s_fog.h"
 #include "s_pixeltex.h"
 #include "s_span.h"
 #include "s_stencil.h"
@@ -490,15 +491,24 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
    const GLint desty = y;
    GLint row, drawWidth;
    GLdepth zspan[MAX_WIDTH];
+   GLfloat fogSpan[MAX_WIDTH];
 
    drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
 
    /* Fragment depth values */
    if (ctx->Depth.Test || ctx->Fog.Enabled) {
       GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMaxF);
+      GLfloat fog;
       GLint i;
+
+      if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+         fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+      else
+         fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
       for (i = 0; i < drawWidth; i++) {
         zspan[i] = zval;
+         fogSpan[i] = fog;
       }
    }
 
@@ -513,11 +523,11 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
                               type, source, &ctx->Unpack,
                               ctx->_ImageTransferState);
       if (zoom) {
-         _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, 0,
+         _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, fogSpan,
                                        indexes, desty);
       }
       else {
-         _mesa_write_index_span(ctx, drawWidth, x, y, zspan, 0, indexes,
+         _mesa_write_index_span(ctx, drawWidth, x, y, zspan, fogSpan, indexes,
                                 NULL, GL_BITMAP);
       }
    }
@@ -714,6 +724,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
    const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
    const GLint desty = y;
    GLdepth zspan[MAX_WIDTH];
+   GLfloat fogSpan[MAX_WIDTH];
    GLboolean quickDraw;
    GLfloat *convImage = NULL;
    GLuint transferOps = ctx->_ImageTransferState;
@@ -731,9 +742,17 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
    if (ctx->Depth.Test || ctx->Fog.Enabled) {
       /* fill in array of z values */
       GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMaxF);
+      GLfloat fog;
       GLint i;
+
+      if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+         fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterFogCoord);
+      else
+         fog = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
       for (i=0;i<width;i++) {
         zspan[i] = z;
+         fogSpan[i] = fog;
       }
    }
 
@@ -818,11 +837,18 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
             continue;
 
          if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
-            GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
             GLchan primary_rgba[MAX_WIDTH][4];
             GLuint unit;
-            /* XXX not sure how multitexture is supposed to work here */
+            DEFARRAY(GLfloat, s, MAX_WIDTH);  /* mac 32k limitation */
+            DEFARRAY(GLfloat, t, MAX_WIDTH);
+            DEFARRAY(GLfloat, r, MAX_WIDTH);
+            DEFARRAY(GLfloat, q, MAX_WIDTH);
+            CHECKARRAY(s, return);  /* mac 32k limitation */
+            CHECKARRAY(t, return);
+            CHECKARRAY(r, return);
+            CHECKARRAY(q, return);
 
+            /* XXX not sure how multitexture is supposed to work here */
             MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
 
             for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
@@ -834,6 +860,10 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
                                             rgba);
                }
             }
+            UNDEFARRAY(s);  /* mac 32k limitation */
+            UNDEFARRAY(t);
+            UNDEFARRAY(r);
+            UNDEFARRAY(q);
          }
 
          if (quickDraw) {
@@ -841,11 +871,11 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
                                             (CONST GLchan (*)[4]) rgba, NULL);
          }
          else if (zoom) {
-            _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0,
+            _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, fogSpan,
                                          (CONST GLchan (*)[4]) rgba, desty);
          }
          else {
-            _mesa_write_rgba_span(ctx, (GLuint) width, x, y, zspan, 0,
+            _mesa_write_rgba_span(ctx, (GLuint) width, x, y, zspan, fogSpan,
                                   rgba, NULL, GL_BITMAP);
          }
       }