summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-08-02 15:25:38 +0000
committerrodri <rgl@antares-labs.eu>2024-08-02 15:25:38 +0000
commit454adaf7a34c6fe91a69229f2f52d563c39521ba (patch)
treedae3eeae98252487ca456218d8a772988995d990
parent8dca0cb97c2750ee2d2f57c01a5ece8dc5752c35 (diff)
download3dee-454adaf7a34c6fe91a69229f2f52d563c39521ba.tar.gz
3dee-454adaf7a34c6fe91a69229f2f52d563c39521ba.tar.bz2
3dee-454adaf7a34c6fe91a69229f2f52d563c39521ba.zip
vis: use the new viewport upscale interface.
-rw-r--r--vis.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/vis.c b/vis.c
index 445142d..6afe468 100644
--- a/vis.c
+++ b/vis.c
@@ -11,6 +11,8 @@
#include "dat.h"
#include "fns.h"
+#define isdigit(c) ((c) >= '0' && (c) <= '9')
+
typedef struct Camcfg Camcfg;
struct Camcfg
{
@@ -860,7 +862,7 @@ confproc(void)
void
usage(void)
{
- fprint(2, "usage: %s [-s] [-t texture] [-g wxh] model...\n", argv0);
+ fprint(2, "usage: %s [-s] [-t texture] [-g wxh[xs]] model...\n", argv0);
exits("usage");
}
@@ -871,23 +873,26 @@ threadmain(int argc, char *argv[])
Channel *keyc;
Entity *subject;
OBJ *obj;
- char *texpath, *mdlpath, *wxh, *s;
- int i, fd, fbw, fbh;
+ char *texpath, *mdlpath, *s;
+ int i, fd, fbw, fbh, scale;
GEOMfmtinstall();
texpath = nil;
fbw = fbh = 0;
+ scale = 1;
ARGBEGIN{
case 's': showskybox++; break;
case 't': texpath = EARGF(usage()); break;
case 'g':
- wxh = EARGF(usage());
- s = strchr(wxh, 'x');
- if(s == nil || *wxh == 'x' || s[1] == 0)
+ s = EARGF(usage());
+ fbw = strtoul(s, &s, 10);
+ if(fbw == 0 || *s++ != 'x')
+ usage();
+ fbh = strtoul(s, &s, 10);
+ if(fbh == 0)
usage();
- *s++ = 0;
- fbw = strtoul(wxh, nil, 10);
- fbh = strtoul(s, nil, 10);
+ if(*s++ == 'x' && isdigit(*s))
+ scale = strtoul(s, nil, 10);
break;
case L'ι': inception++; break;
case 'p': doprof++; break;
@@ -938,16 +943,20 @@ threadmain(int argc, char *argv[])
screenb = eallocimage(display, rectsubpt(screen->r, screen->r.min), XRGB32, 0, 0x888888FF);
for(i = 0; i < nelem(cams); i++){
- /* no downsampling support */
- if(fbw == 0 || fbh == 0 || Dx(screenb->r)/fbw < 1 || Dy(screenb->r)/fbh < 1)
+ if(fbw == 0 || fbh == 0)
cams[i] = Cam(screenb->r, rctl,
camcfgs[i].ptype, camcfgs[i].fov, camcfgs[i].clipn, camcfgs[i].clipf);
else
cams[i] = Cam(Rect(0,0,fbw,fbh), rctl,
camcfgs[i].ptype, camcfgs[i].fov, camcfgs[i].clipn, camcfgs[i].clipf);
+
placecamera(cams[i], scene, camcfgs[i].p, camcfgs[i].lookat, camcfgs[i].up);
- cams[i]->view->bx.x = Dx(screenb->r)/Dx(cams[i]->view->r);
- cams[i]->view->by.y = Dy(screenb->r)/Dy(cams[i]->view->r);
+ cams[i]->view->setscale(cams[i]->view, scale, scale);
+
+ if(scale == 2)
+ cams[i]->view->setscalefilter(cams[i]->view, UFScale2x);
+ else if(scale == 3)
+ cams[i]->view->setscalefilter(cams[i]->view, UFScale3x);
fprint(2, "scalex %g scaley %g\n", cams[i]->view->bx.x, cams[i]->view->by.y);
}
maincam = cams[3];