summaryrefslogtreecommitdiff
path: root/fb.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-06-14 15:01:15 +0000
committerrodri <rgl@antares-labs.eu>2024-06-14 15:01:15 +0000
commitc69735e24f7c5926ed63ff8c5292be282aa8b240 (patch)
tree6c941bfd052eb0b603d591695034543a53b7f43d /fb.c
parentb1335875b19a4db2ae028f8d790784cddcffe8b5 (diff)
downloadlibgraphics-c69735e24f7c5926ed63ff8c5292be282aa8b240.tar.gz
libgraphics-c69735e24f7c5926ed63ff8c5292be282aa8b240.tar.bz2
libgraphics-c69735e24f7c5926ed63ff8c5292be282aa8b240.zip
fix the barycoords routine to avoid reporting false degenerates.
added a normals buffer for debugging.
Diffstat (limited to 'fb.c')
-rw-r--r--fb.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fb.c b/fb.c
index 5077b7d..e0fa2cd 100644
--- a/fb.c
+++ b/fb.c
@@ -31,6 +31,17 @@ framebufctl_memdraw(Framebufctl *ctl, Memimage *dst)
}
static void
+framebufctl_drawnormals(Framebufctl *ctl, Image *dst)
+{
+ Framebuf *fb;
+
+ qlock(ctl);
+ fb = ctl->getfb(ctl);
+ loadimage(dst, rectaddpt(fb->r, dst->r.min), (uchar*)fb->nb, Dx(fb->r)*Dy(fb->r)*4);
+ qunlock(ctl);
+}
+
+static void
framebufctl_swap(Framebufctl *ctl)
{
qlock(ctl);
@@ -45,6 +56,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));
memset(fb->cb, 0, Dx(fb->r)*Dy(fb->r)*4);
}
@@ -71,6 +83,7 @@ mkfb(Rectangle r)
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));
+ fb->nb = emalloc(Dx(r)*Dy(r)*4);
fb->r = r;
return fb;
}
@@ -94,6 +107,7 @@ mkfbctl(Rectangle r)
fc->fb[1] = mkfb(r);
fc->draw = framebufctl_draw;
fc->memdraw = framebufctl_memdraw;
+ fc->drawnormals = framebufctl_drawnormals;
fc->swap = framebufctl_swap;
fc->reset = framebufctl_reset;
fc->getfb = framebufctl_getfb;