X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fpolytmpl.h;h=2147666938fbc7eadce60a753c7dc57e48621ea7;hp=12df420c66295c1ec22768087cd52d1be309cead;hb=e0a94da7c7b657cebbb9e07c861054540706d5da;hpb=1723e332319e7732473814dfc168a13d0bafccb4 diff --git a/src/polytmpl.h b/src/polytmpl.h index 12df420..2147666 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> 8) * ((pv[next].y + pv[i].y) >> 8); + } + /* +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,16 @@ 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) { + edge = y0 > y1 ? left : right; + } else { + 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;