added missing \'s
[mesa.git] / src / mesa / swrast / s_aaline.c
index 48bb2f61094f4774e0d71b85b4ecfd3e585c1a69..395ad3f9414050de84b17eae2bf3d1293603e844 100644 (file)
@@ -1,21 +1,21 @@
-/* $Id: s_aaline.c,v 1.2 2000/11/13 20:02:57 keithw Exp $ */
+/* $Id: s_aaline.c,v 1.11 2001/05/21 18:13:43 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
  * Version:  3.5
- * 
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
- * 
+ *
+ * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -30,8 +30,8 @@
 #include "swrast/s_pb.h"
 #include "swrast/s_context.h"
 #include "swrast/swrast.h"
-#include "types.h"
-
+#include "mtypes.h"
+#include "mmath.h"
 
 
 #define SUB_PIXEL 4
@@ -120,10 +120,18 @@ compute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
    const GLfloat b = pz * py;
    const GLfloat c = px * px + py * py;
    const GLfloat d = -(a * x0 + b * y0 + c * z0);
-   plane[0] = a;
-   plane[1] = b;
-   plane[2] = c;
-   plane[3] = d;
+   if (a == 0.0 && b == 0.0 && c == 0.0 && d == 0.0) {
+      plane[0] = 0.0;
+      plane[1] = 0.0;
+      plane[2] = 1.0;
+      plane[3] = 0.0;
+   }
+   else {
+      plane[0] = a;
+      plane[1] = b;
+      plane[2] = c;
+      plane[3] = d;
+   }
 #endif
 }
 
@@ -141,7 +149,7 @@ constant_plane(GLfloat value, GLfloat plane[4])
 static INLINE GLfloat
 solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
 {
-   GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+   const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
    return z;
 }
 
@@ -155,8 +163,11 @@ solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
 static INLINE GLfloat
 solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4])
 {
-   GLfloat z = -plane[2] / (plane[3] + plane[0] * x + plane[1] * y);
-   return z;
+   const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y;
+   if (denom == 0.0)
+      return 0.0;
+   else
+      return -plane[2] / denom;
 }
 
 
@@ -170,7 +181,7 @@ solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4])
    if (z < 0.0F)
       return 0;
    else if (z > CHAN_MAXF)
-      return CHAN_MAXF;
+      return (GLchan) CHAN_MAXF;
    return (GLchan) (GLint) z;
 }
 
@@ -190,7 +201,10 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
    GLfloat r2 = dvdx * dvdx + dvdy * dvdy;
    GLfloat rho2 = r1 + r2;
    /* return log base 2 of rho */
-   return log(rho2) * 1.442695 * 0.5;       /* 1.442695 = 1/log(2) */
+   if (rho2 == 0.0F)
+      return 0.0;
+   else
+      return log(rho2) * 1.442695 * 0.5;       /* 1.442695 = 1/log(2) */
 }
 
 
@@ -234,8 +248,8 @@ make_sample_table(GLint xSamples, GLint ySamples, GLfloat samples[][2])
          else {
             j = i++;
          }
-         samples[j][0] = x * dx;
-         samples[j][1] = y * dy;
+         samples[j][0] = x * dx + 0.5 * dx;
+         samples[j][1] = y * dy + 0.5 * dy;
       }
    }
 }
@@ -474,6 +488,13 @@ segment(GLcontext *ctx,
 #define DO_Z
 #define DO_RGBA
 #define DO_MULTITEX
+#include "s_aalinetemp.h"
+
+
+#define NAME(x)  aa_multitex_spec_##x
+#define DO_Z
+#define DO_RGBA
+#define DO_MULTITEX
 #define DO_SPEC
 #include "s_aalinetemp.h"
 
@@ -486,16 +507,20 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
 
    ASSERT(ctx->Line.SmoothFlag);
 
-   if (ctx->Visual.RGBAflag) {
+   if (ctx->Visual.rgbMode) {
       /* RGBA */
       if (ctx->Texture._ReallyEnabled) {
-         if (swrast->_MultiTextureEnabled
-             || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
-             || ctx->Fog.ColorSumEnabled)
+         if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
             /* Multitextured! */
-            swrast->Line = aa_multitex_rgba_line;
-         else
+            if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR || 
+                ctx->Fog.ColorSumEnabled)
+               swrast->Line = aa_multitex_spec_line;
+            else
+               swrast->Line = aa_multitex_rgba_line;
+         }
+         else {
             swrast->Line = aa_tex_rgba_line;
+         }
       }
       else {
          swrast->Line = aa_rgba_line;
@@ -506,4 +531,3 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
       swrast->Line = aa_ci_line;
    }
 }
-