From: John Tsiombikas Date: Wed, 7 Sep 2022 06:05:58 +0000 (+0300) Subject: foo X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=gbajam22;a=commitdiff_plain;h=f73cd25d63806279fb8c6c085f5aa8dfeab8130d foo --- diff --git a/src/gamescr.c b/src/gamescr.c index dcceb20..840a9e4 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -101,6 +101,7 @@ static void draw(void) xgl_rotate_x(player.phi); xgl_rotate_y(player.theta); xgl_translate(player.x, 0, player.y); + xgl_rotate_y(X_QPI); xgl_draw(XGL_QUADS, tm_floor, sizeof tm_floor / sizeof *tm_floor); } diff --git a/src/xgl.c b/src/xgl.c index 48db220..c76991b 100644 --- a/src/xgl.c +++ b/src/xgl.c @@ -191,12 +191,12 @@ static void xform_norm(struct xvertex *out, const struct xvertex *in, const int3 /* d = 1.0 / tan(fov/2) */ #define PROJ_D 0x20000 /* near Z = 0.5 */ -#define NEAR_Z 0x10000 +#define NEAR_Z 0x30000 void xgl_draw(int prim, const struct xvertex *varr, int vcount) { - int i, cidx; - struct xvertex xv[4]; + int i, cidx, clipnum; + struct xvertex xv[4], xvclip[8]; struct pvertex pv[4]; int32_t ndotl; @@ -233,15 +233,15 @@ void xgl_draw(int prim, const struct xvertex *varr, int vcount) } /* clip against near plane */ + xgl_clip_near(xvclip, &clipnum, xv, prim); - - for(i=0; i> 1) * vp[2]) + (vp[0] << 8); - pv[i].y = (((0x100 - xv[i].y) >> 1) * vp[3]) + (vp[1] << 8); + pv[i].x = (((xvclip[i].x + 0x100) >> 1) * vp[2]) + (vp[0] << 8); + pv[i].y = (((0x100 - xvclip[i].y) >> 1) * vp[3]) + (vp[1] << 8); } - polyfill_flat(pv, prim, cidx); + polyfill_flat(pv, clipnum, cidx); skip_poly: varr += prim; vcount -= prim; diff --git a/src/xgl.h b/src/xgl.h index 9a2308b..979de5f 100644 --- a/src/xgl.h +++ b/src/xgl.h @@ -66,4 +66,6 @@ void xgl_transform(const struct xvertex *vin, int *x, int *y); void xgl_xyzzy(void); +int xgl_clip_near(struct xvertex *vout, int *voutnum, struct xvertex *vin, int vnum); + #endif /* XGL_H_ */