X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fpolytmpl.h;h=2147666938fbc7eadce60a753c7dc57e48621ea7;hp=db5997a2774f64180bb74c8966dedd533fb467bf;hb=e0a94da7c7b657cebbb9e07c861054540706d5da;hpb=1bd8af3c3c9ec41903590d6ad24ff6313a5cc19b diff --git a/src/polytmpl.h b/src/polytmpl.h index db5997a..2147666 100644 --- a/src/polytmpl.h +++ b/src/polytmpl.h @@ -93,8 +93,15 @@ void POLYFILL(struct pvertex *pv, int nverts) if(pv[i].y > pv[botidx].y) botidx = i; } - left = alloca(pfill_fb.height * sizeof *left); - right = alloca(pfill_fb.height * sizeof *right); + 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); for(i=0; i 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;