adjust coords in wide_line() to be conformant
authorBrian <brian.paul@tungstengraphics.com>
Tue, 23 Oct 2007 17:38:17 +0000 (11:38 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 23 Oct 2007 17:38:17 +0000 (11:38 -0600)
src/mesa/pipe/draw/draw_wide_prims.c

index e61cc2e025d8e33b7dd29069446e8320c2b56507..76b8a5319bbf4726ffaff6ee3ac881d3d69c7f2c 100644 (file)
@@ -100,17 +100,56 @@ static void wide_line( struct draw_stage *stage,
    const float dx = FABSF(pos0[0] - pos2[0]);
    const float dy = FABSF(pos0[1] - pos2[1]);
    
+   /*
+    * Draw wide line as a quad (two tris) by "stretching" the line along
+    * X or Y.
+    * XXX For AA lines, the quad corners have to be computed in a
+    * more sophisticated way.
+    */
+
+   /* need to tweak coords in several ways to be conformant here */
+
    if (dx > dy) {
-      pos0[1] -= half_width;
-      pos1[1] += half_width;
-      pos2[1] -= half_width;
-      pos3[1] += half_width;
+      /* x-major line */
+      pos0[1] = pos0[1] - half_width - 0.25;
+      pos1[1] = pos1[1] + half_width - 0.25;
+      pos2[1] = pos2[1] - half_width - 0.25;
+      pos3[1] = pos3[1] + half_width - 0.25;
+      if (pos0[0] < pos2[0]) {
+         /* left to right line */
+         pos0[0] -= 0.5;
+         pos1[0] -= 0.5;
+         pos2[0] -= 0.5;
+         pos3[0] -= 0.5;
+      }
+      else {
+         /* right to left line */
+         pos0[0] += 0.5;
+         pos1[0] += 0.5;
+         pos2[0] += 0.5;
+         pos3[0] += 0.5;
+      }
    }
    else {
-      pos0[0] -= half_width;
-      pos1[0] += half_width;
-      pos2[0] -= half_width;
-      pos3[0] += half_width;
+      /* y-major line */
+      pos0[0] = pos0[0] - half_width + 0.25;
+      pos1[0] = pos1[0] + half_width + 0.25;
+      pos2[0] = pos2[0] - half_width + 0.25;
+      pos3[0] = pos3[0] + half_width + 0.25;
+      if (pos0[1] < pos2[1]) {
+         /* top to bottom line */
+         pos0[1] -= 0.5;
+         pos1[1] -= 0.5;
+         pos2[1] -= 0.5;
+         pos3[1] -= 0.5;
+      }
+      else {
+         /* bottom to top line */
+         pos0[1] += 0.5;
+         pos1[1] += 0.5;
+         pos2[1] += 0.5;
+         pos3[1] += 0.5;
+      }
    }
 
    tri.det = header->det;  /* only the sign matters */