X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fxgl.c;h=515919e29f7649b4e43afb960a537adbb723b2ab;hb=f376a88158f9f99d738a51e306d137de62124569;hp=376d792bf7a62f8adb4ca211d09b3dd5a15cf727;hpb=5b98299a1aa716cc17cb5f70498c8e23cac945cb;p=gba_blender diff --git a/src/xgl.c b/src/xgl.c index 376d792..515919e 100644 --- a/src/xgl.c +++ b/src/xgl.c @@ -157,23 +157,31 @@ static void xform(struct xvertex *out, const struct xvertex *in, const int32_t * out->z = XMUL(m[2], in->x) + XMUL(m[6], in->y) + XMUL(m[10], in->z) + m[14]; } +/* d = 1.0 / tan(fov/2) */ +#define PROJ_D 2.0f + void xgl_draw(int prim, const struct xvertex *varr, int vcount) { - int i; + int i, cidx; struct xvertex xv[4]; struct pvertex pv[4]; while(vcount >= prim) { + cidx = varr->cidx; for(i=0; i> 8); /* assume aspect: ~2 */ + xv[i].y = (xv[i].y << 1) / (xv[i].z >> 8); + /* projection result is 24.8 */ + /* viewport */ - pv[i].x = ((((xv[i].x + 0x10000) >> 1) * vp[2]) >> 8) + (vp[0] << 8); - pv[i].y = ((((xv[i].y + 0x10000) >> 1) * vp[3]) >> 8) + (vp[1] << 8); + pv[i].x = (((xv[i].x + 0x100) >> 1) * vp[2]) + (vp[0] << 8); + pv[i].y = (((0x100 - xv[i].y) >> 1) * vp[3]) + (vp[1] << 8); } vcount -= prim; - polyfill_flat(pv, prim, 0xff); + polyfill_flat(pv, prim, cidx); } }