added missing \'s
[mesa.git] / src / mesa / swrast / s_aaline.c
index f0a8a8d06a744af43ff42dbd13da77d0c1fd2a99..395ad3f9414050de84b17eae2bf3d1293603e844 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: s_aaline.c,v 1.6 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: s_aaline.c,v 1.11 2001/05/21 18:13:43 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -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;
 }
 
 
@@ -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"
 
@@ -489,13 +510,17 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
    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;