When the fill mode is PIPE_POLYGON_MODE_LINE we were basically
converting the polygon into triangles, then drawing the outline of all
the triangles. But we really only want to draw the lines around the
perimeter of the polygon, not the interior lines.
NOTE: This is a candidate for the 7.10 branch.
def polygon(intype, outtype):
preamble(intype, outtype, prim='polygon')
- print ' for (j = i = 0; j < nr; j+=6, i++) { '
- do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' );
+ print ' for (j = i = 0; j < nr; j+=2, i++) { '
+ line( intype, outtype, 'out+j', 'i', '(i+1)%(nr/2)' )
print ' }'
postamble()
}
+/**
+ * Given a primitive type and number of vertices, return the number of vertices
+ * needed to draw the primitive with fill mode = PIPE_POLYGON_MODE_LINE using
+ * separate lines (PIPE_PRIM_LINES).
+ */
static unsigned nr_lines( unsigned prim,
unsigned nr )
{
case PIPE_PRIM_QUAD_STRIP:
return (nr - 2) / 2 * 8;
case PIPE_PRIM_POLYGON:
- return (nr - 2) * 6;
+ return 2 * nr; /* a line (two verts) for each polygon edge */
default:
assert(0);
return 0;