From 7705fa326336feba1a66d5a6ca8a7c27771e4c5f Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Fri, 10 Jul 2020 15:20:23 +0300 Subject: [PATCH] zbuffer done --- src/3dgfx/polyfill.h | 2 +- src/3dgfx/polytmpl.h | 21 ++++++++++++--------- src/glut/main.c | 20 +++++++++++++++++--- src/scr/polytest.c | 32 +++++++++++++++++++++++++------- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/3dgfx/polyfill.h b/src/3dgfx/polyfill.h index fed8eda..6c95667 100644 --- a/src/3dgfx/polyfill.h +++ b/src/3dgfx/polyfill.h @@ -66,7 +66,7 @@ struct pvertex { int32_t x, y; /* 24.8 fixed point */ int32_t u, v; /* 16.16 fixed point */ int32_t r, g, b, a; /* int 0-255 */ - uint16_t z; /* 0-65535 */ + int32_t z; /* 0-65535 */ }; struct pimage { diff --git a/src/3dgfx/polytmpl.h b/src/3dgfx/polytmpl.h index 01bbd01..167d5e1 100644 --- a/src/3dgfx/polytmpl.h +++ b/src/3dgfx/polytmpl.h @@ -13,7 +13,7 @@ static uint32_t SCANEDGE(struct pvertex *v0, struct pvertex *v1, struct pvertex int32_t u, v, du, dv, uslope, vslope; #endif #ifdef ZBUF - int z, dz, zslope; + int32_t z, dz, zslope; #endif int32_t start_idx, end_idx; @@ -115,7 +115,7 @@ void POLYFILL(struct pvertex *pv, int nverts) int32_t u, v, du, dv, uslope, vslope; #endif #ifdef ZBUF - int z, dz, zslope; + int32_t z, dz, zslope; #endif for(i=1; i> 5) & 0x7e0; } }*/ + cs_dputs(fb_pixels, 140, 0, use_zbuf ? "zbuffer" : "zsort"); + /*draw_mesh(&cube);*/ swap_buffers(fb_pixels); } @@ -227,6 +240,11 @@ static void keypress(int key) use_bsp = !use_bsp; printf("drawing with %s\n", use_bsp ? "BSP tree" : "z-sorting"); break; + + case 'z': + use_zbuf = !use_zbuf; + printf("Z-buffer %s\n", use_zbuf ? "on" : "off"); + break; } } -- 1.7.10.4