ref: 5d9dbc72e1c63b378023a283e53e43dc01a7b98c
parent: 7a595ccba74a821065ef09a8c6ae6c6ad922b0b1
author: rodri <rgl@antares-labs.eu>
date: Tue Apr 28 08:40:33 EDT 2020
changes to fit libgeometry and libgraphics.
--- a/main.c
+++ b/main.c
@@ -52,44 +52,24 @@
2,0,-4,1,
0,0,0,1,
0,1,0,0,
- 90, 0.1, 100, Ppersp,
+ 90*DEG, 0.1, 100, Ppersp,
-2,0,-4,1,
0,0,0,1,
0,1,0,0,
- 120, 0.1, 100, Ppersp,
+ 120*DEG, 0.1, 100, Ppersp,
-2,0,4,1,
0,0,0,1,
0,1,0,0,
- 90, 0.1, 100, Ppersp,
+ 90*DEG, 0.1, 100, Ppersp,
2,0,4,1,
0,0,0,1,
0,1,0,0,
- 120, 0.1, 100, Ppersp
+ 120*DEG, 0.1, 100, Ppersp
};
-#pragma varargck type "v" Point2
-int
-vfmt(Fmt *f)
-{
- Point2 p;
-
- p = va_arg(f->args, Point2);
- return fmtprint(f, "[%g %g %g]", p.x, p.y, p.w);
-}
-
-#pragma varargck type "V" Point3
-int
-Vfmt(Fmt *f)
-{
- Point3 p;
-
- p = va_arg(f->args, Point3);
- return fmtprint(f, "[%g %g %g %g]", p.x, p.y, p.z, p.w);
-}
-
void *
emalloc(ulong n)
{
@@ -176,17 +156,17 @@
// }
// for(i = 0; i < model.ntri; i++){
// /* world to camera */
-// tmp.p0 = WORLD2VCS(maincam, model.tris[i].p0);
-// tmp.p1 = WORLD2VCS(maincam, model.tris[i].p1);
-// tmp.p2 = WORLD2VCS(maincam, model.tris[i].p2);
+// tmp.p0 = world2vcs(maincam, model.tris[i].p0);
+// tmp.p1 = world2vcs(maincam, model.tris[i].p1);
+// tmp.p2 = world2vcs(maincam, model.tris[i].p2);
// /* back-face culling */
// n = normvec3(crossvec3(subpt3(tmp.p1, tmp.p0), subpt3(tmp.p2, tmp.p0)));
// if(dotvec3(n, mulpt3(tmp.p0, -1)) <= 0)
// continue;
// /* camera to projected ndc */
-// tmp.p0 = VCS2NDC(maincam, tmp.p0);
-// tmp.p1 = VCS2NDC(maincam, tmp.p1);
-// tmp.p2 = VCS2NDC(maincam, tmp.p2);
+// tmp.p0 = vcs2ndc(maincam, tmp.p0);
+// tmp.p1 = vcs2ndc(maincam, tmp.p1);
+// tmp.p2 = vcs2ndc(maincam, tmp.p2);
// /* clipping */
// /*
// * no clipping for now, the whole triangle is ignored
@@ -228,7 +208,7 @@
threadsetname("drawproc");
for(;;){
send(drawc, nil);
- sleep(FPS2MS(60));
+ sleep(MS2FR);
}
}
@@ -374,8 +354,7 @@
OBJ *objmesh;
int i;
- fmtinstall('V', Vfmt);
- fmtinstall('v', vfmt);
+ GEOMfmtinstall();
ARGBEGIN{
default: usage();
case 'l':