ref: c06379ee3aa51d3adf456c8d126feebd1da9de70
parent: 50f15bac90638da401d27229969dc502c75d1320
author: rodri <rgl@antares-labs.eu>
date: Sun Aug 4 08:43:55 EDT 2024
make the depth buffer 32-bit.
--- a/clip.c
+++ b/clip.c
@@ -194,7 +194,7 @@
}
/* lerp vertex attributes to match the new positions */
-void
+static void
adjustverts(Point *p0, Point *p1, Vertex *v0, Vertex *v1)
{
Vertex v[2];
--- a/fb.c
+++ b/fb.c
@@ -219,7 +219,7 @@
/* address the back buffer—resetting the front buffer is VERBOTEN */
fb = ctl->getbb(ctl);
memset(fb->nb, 0, Dx(fb->r)*Dy(fb->r)*4);
- memsetd(fb->zb, Inf(-1), Dx(fb->r)*Dy(fb->r));
+ memsetf(fb->zb, Inf(-1), Dx(fb->r)*Dy(fb->r));
memset(fb->cb, 0, Dx(fb->r)*Dy(fb->r)*4);
}
@@ -244,7 +244,7 @@
memset(fb, 0, sizeof *fb);
fb->cb = emalloc(Dx(r)*Dy(r)*4);
fb->zb = emalloc(Dx(r)*Dy(r)*sizeof(*fb->zb));
- memsetd(fb->zb, Inf(-1), Dx(r)*Dy(r));
+ memsetf(fb->zb, Inf(-1), Dx(r)*Dy(r));
fb->nb = emalloc(Dx(r)*Dy(r)*4);
fb->r = r;
return fb;
--- a/graphics.h
+++ b/graphics.h
@@ -249,7 +249,7 @@
struct Framebuf
{
ulong *cb; /* color buffer */
- double *zb; /* z/depth buffer */
+ float *zb; /* z/depth buffer */
ulong *nb; /* normals buffer (DBG only) */
Rectangle r;
};
--- a/internal.h
+++ b/internal.h
@@ -60,7 +60,7 @@
int max(int, int);
void swapi(int*, int*);
void swappt(Point*, Point*);
-void memsetd(void*, double, usize);
+void memsetf(void*, float, usize);
void memsetl(void*, ulong, usize);
/* nanosec */
--- a/render.c
+++ b/render.c
@@ -101,7 +101,8 @@
Point p, dp, Δp, p0, p1;
Point3 bc;
Color c;
- double z, dplen, perc;
+ double dplen, perc;
+ float z;
int steep = 0, Δe, e, Δy;
params = task->params;
--- a/util.c
+++ b/util.c
@@ -65,9 +65,9 @@
}
void
-memsetd(void *dp, double v, usize len)
+memsetf(void *dp, float v, usize len)
{
- double *p, *ep;
+ float *p, *ep;
for(p = dp, ep = p+len; p < ep; p++)
*p = v;