summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-08-04 12:43:55 +0000
committerrodri <rgl@antares-labs.eu>2024-08-04 12:43:55 +0000
commitc06379ee3aa51d3adf456c8d126feebd1da9de70 (patch)
tree29ac7900ec359038710a0c031b45dcf373a1920a
parent50f15bac90638da401d27229969dc502c75d1320 (diff)
downloadlibgraphics-c06379ee3aa51d3adf456c8d126feebd1da9de70.tar.gz
libgraphics-c06379ee3aa51d3adf456c8d126feebd1da9de70.tar.bz2
libgraphics-c06379ee3aa51d3adf456c8d126feebd1da9de70.zip
make the depth buffer 32-bit.
-rw-r--r--clip.c2
-rw-r--r--fb.c4
-rw-r--r--graphics.h2
-rw-r--r--internal.h2
-rw-r--r--render.c3
-rw-r--r--util.c4
6 files changed, 9 insertions, 8 deletions
diff --git a/clip.c b/clip.c
index 9988ce1..94f84a6 100644
--- a/clip.c
+++ b/clip.c
@@ -194,7 +194,7 @@ outcode(Point p, Rectangle r)
}
/* lerp vertex attributes to match the new positions */
-void
+static void
adjustverts(Point *p0, Point *p1, Vertex *v0, Vertex *v1)
{
Vertex v[2];
diff --git a/fb.c b/fb.c
index 4806604..6193a3c 100644
--- a/fb.c
+++ b/fb.c
@@ -219,7 +219,7 @@ framebufctl_reset(Framebufctl *ctl)
/* 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 @@ mkfb(Rectangle r)
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;
diff --git a/graphics.h b/graphics.h
index 52becf3..dfc9f39 100644
--- a/graphics.h
+++ b/graphics.h
@@ -249,7 +249,7 @@ struct Renderjob
struct Framebuf
{
ulong *cb; /* color buffer */
- double *zb; /* z/depth buffer */
+ float *zb; /* z/depth buffer */
ulong *nb; /* normals buffer (DBG only) */
Rectangle r;
};
diff --git a/internal.h b/internal.h
index 777ace8..6cd512c 100644
--- a/internal.h
+++ b/internal.h
@@ -60,7 +60,7 @@ int min(int, int);
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 */
diff --git a/render.c b/render.c
index 549ee1a..a28ed1b 100644
--- a/render.c
+++ b/render.c
@@ -101,7 +101,8 @@ rasterize(Rastertask *task)
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;
diff --git a/util.c b/util.c
index 2bf77c2..2ddf21c 100644
--- a/util.c
+++ b/util.c
@@ -65,9 +65,9 @@ modulapt3(Point3 a, Point3 b)
}
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;