summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-07-15 21:37:53 +1000
committerquou <quou@disroot.org>2024-07-15 21:37:53 +1000
commit7564b36e12e51b0298234c6856b757ff15402b24 (patch)
treecd393ca7a134473f88bde4e621028aa1b3e14e4b
parent24097f5aacbf46ec1500ab84a60bade28b53a301 (diff)
Dumb near plane clipping.
-rw-r--r--3de.c1
-rw-r--r--render.c11
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++) {