From: John Tsiombikas Date: Sun, 26 Aug 2018 12:18:44 +0000 (+0300) Subject: reflection X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosrtxon;a=commitdiff_plain;h=584c6161bb6f3f548d5e27bb7d6895a81375881e reflection --- diff --git a/src/3dgfx.c b/src/3dgfx.c index 044ab66..64fd604 100644 --- a/src/3dgfx.c +++ b/src/3dgfx.c @@ -82,6 +82,7 @@ int g3d_init(void) fprintf(stderr, "failed to allocate G3D context\n"); return -1; } + st->opt = G3D_CLIP_FRUSTUM; st->fill_mode = POLYFILL_FLAT; for(i=0; iopt & G3D_CLIP_FRUSTUM) { + for(i=0; i<6; i++) { + memcpy(tmpv, v, vnum * sizeof *v); + + if(clip_frustum(v, &vnum, tmpv, vnum, i) < 0) { + /* polygon completely outside of view volume. discard */ + vnum = 0; + break; + } } - } - if(!vnum) continue; + if(!vnum) continue; + } for(i=0; i pv[botidx].y) botidx = i; } + int winding = 0; + 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;