diff options
author | rodri <rgl@antares-labs.eu> | 2024-06-14 18:15:52 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-06-14 18:15:52 +0000 |
commit | 093323c36fa083a897dc371b36889296d1069715 (patch) | |
tree | 7331070b8e03fc06b974c77ef204bb9d261e60b5 | |
parent | d5efccfa229a5bc62c8065c0e66ce09f591d9afa (diff) | |
download | 3dee-093323c36fa083a897dc371b36889296d1069715.tar.gz 3dee-093323c36fa083a897dc371b36889296d1069715.tar.bz2 3dee-093323c36fa083a897dc371b36889296d1069715.zip |
vis: add some instrumentation to debug the framebuffers.
-rw-r--r-- | dat.h | 2 | ||||
-rw-r--r-- | vis.c | 38 |
2 files changed, 39 insertions, 1 deletions
@@ -29,5 +29,7 @@ enum { Sfps, Sframes, Sorient, + Spixcol, + Snorcol, Se }; @@ -90,6 +90,7 @@ static int showskybox; static int doprof; static int inception; static int showhud; +static int shownormals; Color (*tsampler)(Memimage*,Point2); static int @@ -479,7 +480,10 @@ redraw(void) bg = eallocimage(display, UR, RGB24, 1, 0x888888FF); lockdisplay(display); - maincam->vp->draw(maincam->vp, screenb); + if(shownormals) + maincam->vp->fbctl->drawnormals(maincam->vp->fbctl, screenb); + else + maincam->vp->draw(maincam->vp, screenb); draw(screen, screen->r, bg, nil, ZP); draw(screen, screen->r, screenb, nil, ZP); if(showhud) @@ -541,6 +545,18 @@ drawproc(void *) } } +static Color +ul2col(ulong l) +{ + Color c; + + c.a = (l & 0xff)/255.0; + c.b = (l>>8 & 0xff)/255.0; + c.g = (l>>16 & 0xff)/255.0; + c.r = (l>>24 & 0xff)/255.0; + return c; +} + void lmb(void) { @@ -557,6 +573,21 @@ lmb(void) e->by = Vecquat(mulq(mulq(Δorient, Quatvec(0, e->by)), invq(Δorient))); e->bz = Vecquat(mulq(mulq(Δorient, Quatvec(0, e->bz)), invq(Δorient))); } + }else{ + Framebuf *fb; + Point p; + Color c, n; + double z; + + p = subpt(mctl->xy, screen->r.min); + qlock(maincam->vp->fbctl); + fb = maincam->vp->getfb(maincam->vp); + c = ul2col(fb->cb[p.y*Dx(fb->r) + p.x]); + n = ul2col(fb->nb[p.y*Dx(fb->r) + p.x]); + z = fb->zb[p.y*Dx(fb->r) + p.x]; + qunlock(maincam->vp->fbctl); + snprint(stats[Spixcol], sizeof(stats[Spixcol]), "c %V z %g", c, z); + snprint(stats[Snorcol], sizeof(stats[Snorcol]), "n %V", n); } } @@ -567,11 +598,13 @@ mmb(void) MOVELIGHT, TSNEAREST, TSBILINEAR, + SHOWNORMALS, }; static char *items[] = { [MOVELIGHT] "move light", [TSNEAREST] "use nearest sampler", [TSBILINEAR] "use bilinear sampler", + [SHOWNORMALS] "show normals", nil, }; static Menu menu = { .item = items }; @@ -597,6 +630,9 @@ mmb(void) case TSBILINEAR: tsampler = bilitexsampler; break; + case SHOWNORMALS: + shownormals ^= 1; + break; } qunlock(&drawlk); nbsend(drawc, nil); |