summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/draw
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-10-23 11:38:17 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-10-23 11:38:17 -0600
commitbe049999829d21a1c9ec9a2c616e99186208266b (patch)
treea761821a3942f735dfb2881116479acd72b6d9c1 /src/mesa/pipe/draw
parent112a1580f658948e553fe04399a20958dca67c16 (diff)
adjust coords in wide_line() to be conformant
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r--src/mesa/pipe/draw/draw_wide_prims.c55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c
index e61cc2e025..76b8a5319b 100644
--- a/src/mesa/pipe/draw/draw_wide_prims.c
+++ b/src/mesa/pipe/draw/draw_wide_prims.c
@@ -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 */