static void emit_poly( struct draw_stage *stage,
struct vertex_header **inlist,
- unsigned n )
+ unsigned n,
+ const struct prim_header *origPrim)
{
struct prim_header header;
unsigned i;
+ /* later stages may need the determinant, but only the sign matters */
+ header.det = origPrim->det;
+
for (i = 2; i < n; i++) {
header.v[0] = inlist[0];
header.v[1] = inlist[i-1];
if (i != 2) header.v[0]->edgeflag = 0;
if (i != n-1) header.v[2]->edgeflag = 0;
+ header.edgeflags = ((header.v[0]->edgeflag << 0) |
+ (header.v[1]->edgeflag << 1) |
+ (header.v[2]->edgeflag << 2));
+
stage->next->tri( stage->next, &header );
header.v[0]->edgeflag = tmp0;
/* Emit the polygon as triangles to the setup stage:
*/
if (n >= 3)
- emit_poly( stage, inlist, n );
+ emit_poly( stage, inlist, n, header );
}
struct vertex_header *v1 = header->v[1];
struct vertex_header *v2 = header->v[2];
+#if 0
+ assert(((header->edgeflags & 0x1) >> 0) == header->v[0]->edgeflag);
+ assert(((header->edgeflags & 0x2) >> 1) == header->v[1]->edgeflag);
+ assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
+#endif
+
if (header->edgeflags & 0x1) line( stage, v0, v1 );
if (header->edgeflags & 0x2) line( stage, v1, v2 );
if (header->edgeflags & 0x4) line( stage, v2, v0 );