From 7564b36e12e51b0298234c6856b757ff15402b24 Mon Sep 17 00:00:00 2001 From: quou Date: Mon, 15 Jul 2024 21:37:53 +1000 Subject: Dumb near plane clipping. --- 3de.c | 1 + render.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/3de.c b/3de.c index 98ae884..5b5bcc3 100644 --- a/3de.c +++ b/3de.c @@ -86,6 +86,7 @@ int entrypoint(int argc, const char** argv, Arena* a) { sprintf(buf, "MOUSE: %d, %d", app->mx, app->my); ren_texts(&r, blue, 3, 13, buf); draw_monkey(&r); + draw_tri(&r, app->mx, app->my); ren_end(&r); app_end(app); fps_update(&f); diff --git a/render.c b/render.c index e225bb6..14aa6a1 100644 --- a/render.c +++ b/render.c @@ -161,7 +161,7 @@ void ren_begin(Renderer* r, Colour* t, int* d, int w, int h) { r->vp[2] = w; r->vp[3] = h; r->asp = (w << fbits) / h; - r->n = 8; + r->n = 256; } void ren_end(Renderer* r) { @@ -512,12 +512,19 @@ void ren_tri3( const Bitmap* tex ) { #define ec 8 -#define ec2 (ec * 2) +#define ec2 (ec) int tri[ec2 * 3]; int tc = 1, i; vec_cpy(&tri[0], iv0, ec); vec_cpy(&tri[8], iv1, ec); vec_cpy(&tri[16], iv2, ec); + if (tri[2] < r->n) tri[2] = r->n; + if (tri[10] < r->n) tri[10] = r->n; + if (tri[18] < r->n) tri[18] = r->n; + if ( + tri[2] == tri[10] && + tri[2] == tri[18] + ) return; for (i = 0; i < tc; i++) { int ti = i * ec, j; for (j = 0; j < 3; j++) { -- cgit v1.2.3-54-g00ecf