diff options
author | rodri <rgl@antares-labs.eu> | 2024-10-08 13:24:46 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-10-08 13:24:46 +0000 |
commit | 57373e4d56945d7c8b7ce85becf1440e58e3a604 (patch) | |
tree | a3df52f0869e0ea48e8e2346dfe583cc53337037 | |
parent | 6af5bb94f6feedb6c929eb6cafc57da4a1be64bc (diff) | |
download | 3dee-57373e4d56945d7c8b7ce85becf1440e58e3a604.tar.gz 3dee-57373e4d56945d7c8b7ce85becf1440e58e3a604.tar.bz2 3dee-57373e4d56945d7c8b7ce85becf1440e58e3a604.zip |
med: let the user load a model from a file.
-rw-r--r-- | med.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -797,7 +797,7 @@ confproc(void) void usage(void) { - fprint(2, "usage: %s\n", argv0); + fprint(2, "usage: %s [mdlfile]\n", argv0); exits("usage"); } @@ -806,13 +806,18 @@ threadmain(int argc, char *argv[]) { Renderer *rctl; Channel *keyc; + char *mdlpath; + int fd; GEOMfmtinstall(); + mdlpath = nil; ARGBEGIN{ case 'p': doprof++; break; default: usage(); }ARGEND; - if(argc != 0) + if(argc == 1) + mdlpath = argv[0]; + else if(argc > 1) usage(); confproc(); @@ -821,7 +826,16 @@ threadmain(int argc, char *argv[]) sysfatal("couldn't find main shader"); scene = newscene(nil); - model = newmodel(); + if(mdlpath != nil){ + fd = open(mdlpath, OREAD); + if(fd < 0) + sysfatal("open: %r"); + model = readmodel(fd); + if(model == nil) + sysfatal("readmodel: %r"); + close(fd); + }else + model = newmodel(); subject = newentity("main", model); scene->addent(scene, subject); |