summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-12-19 11:44:16 +0000
committerrodri <rgl@antares-labs.eu>2023-12-19 11:44:16 +0000
commitd60d6cd1d01d25dd4931e8c3d3f2f9476cfe2a4b (patch)
tree4ede0361f88e9af01eda4f1b2f9db7c20e980c03
parentc6b9f1912fd3821f9806f74fa9b81ff9ba4d7b4e (diff)
downloadtinyrend-d60d6cd1d01d25dd4931e8c3d3f2f9476cfe2a4b.tar.gz
tinyrend-d60d6cd1d01d25dd4931e8c3d3f2f9476cfe2a4b.tar.bz2
tinyrend-d60d6cd1d01d25dd4931e8c3d3f2f9476cfe2a4b.zip
put the zbuflk in the Framebuf.
-rw-r--r--main.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/main.c b/main.c
index 67aae9b..b01d2cf 100644
--- a/main.c
+++ b/main.c
@@ -65,6 +65,7 @@ struct Framebuf
Memimage *cb;
Memimage *zb;
double *zbuf;
+ Lock zbuflk;
Memimage *nb; /* XXX DBG */
Rectangle r;
};
@@ -90,7 +91,6 @@ struct Stats
Stats fps;
Framebufctl *fbctl;
Memimage *screenfb;
-Lock zbuflk;
Memimage *red, *green, *blue;
OBJ *model;
Memimage *modeltex;
@@ -588,9 +588,9 @@ rasterize(SUparams *params, Triangle3 st, Triangle2 tt, Memimage *frag)
z = st.p0.z*bc.x + st.p1.z*bc.y + st.p2.z*bc.z;
w = st.p0.w*bc.x + st.p1.w*bc.y + st.p2.w*bc.z;
depth = fclamp(z/w, 0, 1);
- lock(&zbuflk);
+ lock(&params->fb->zbuflk);
if(depth <= params->fb->zbuf[p.x + p.y*Dx(params->fb->r)]){
- unlock(&zbuflk);
+ unlock(&params->fb->zbuflk);
continue;
}
params->fb->zbuf[p.x + p.y*Dx(params->fb->r)] = depth;
@@ -600,7 +600,7 @@ rasterize(SUparams *params, Triangle3 st, Triangle2 tt, Memimage *frag)
cbuf[3] = 0xFF*depth;
memfillcolor(frag, *(ulong*)cbuf);
pixel(params->fb->zb, p, frag);
- unlock(&zbuflk);
+ unlock(&params->fb->zbuflk);
cbuf[0] = 0xFF;
if((tt.p0.w + tt.p1.w + tt.p2.w) != 0){