X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fpolytmpl.h;h=55096ef61b058a625e304110dd877368be756dfa;hp=12df420c66295c1ec22768087cd52d1be309cead;hb=cbda3c45c9f5d000c06fb36399778189c245dc4b;hpb=1723e332319e7732473814dfc168a13d0bafccb4 diff --git a/src/polytmpl.h b/src/polytmpl.h index 12df420..55096ef 100644 --- a/src/polytmpl.h +++ b/src/polytmpl.h @@ -93,6 +93,12 @@ void POLYFILL(struct pvertex *pv, int nverts) if(pv[i].y > pv[botidx].y) botidx = i; } + int winding = 0; + for(i=0; i> 4) * ((pv[next].y + pv[i].y) >> 4); + } + /* +1 to avoid crashing due to off-by-one rounding errors in the rasterization */ left = alloca((pfill_fb.height + 1) * sizeof *left); right = alloca((pfill_fb.height + 1) * sizeof *right); @@ -133,9 +139,18 @@ void POLYFILL(struct pvertex *pv, int nverts) if(idx < sltop) sltop = idx; /*}*/ } else { - struct pvertex *edge = y0 > y1 ? left : right; - uint32_t res = SCANEDGE(pv + i, pv + next, edge); - uint32_t tmp = (res >> 16) & 0xffff; + struct pvertex *edge; + uint32_t res, tmp; + + if(winding < 0) { + // clockwise + edge = y0 > y1 ? left : right; + } else { + // counter-clockwise + edge = y0 > y1 ? right : left; + } + res = SCANEDGE(pv + i, pv + next, edge); + tmp = (res >> 16) & 0xffff; if(tmp > slbot) slbot = tmp; if((tmp = res & 0xffff) < sltop) { sltop = tmp;