From a8c789be9ab0fec65004118b7df373e84900cb1a Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 21 Sep 2024 16:15:21 +0000 Subject: camera: add a Camv constructor. --- camera.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'camera.c') diff --git a/camera.c b/camera.c index 12f37eb..439c596 100644 --- a/camera.c +++ b/camera.c @@ -96,21 +96,33 @@ verifycfg(Camera *c) } Camera * -Cam(Rectangle vr, Renderer *r, Projection p, double fov, double n, double f) +Camv(Viewport *v, Renderer *r, Projection p, double fov, double n, double f) { Camera *c; - c = newcamera(); - c->view = mkviewport(vr); - if(c->view == nil){ - werrstr("mkviewport: %r"); + if(v == nil || r == nil) return nil; - } + + c = newcamera(); + c->view = v; c->rctl = r; configcamera(c, p, fov, n, f); return c; } +Camera * +Cam(Rectangle vr, Renderer *r, Projection p, double fov, double n, double f) +{ + Viewport *v; + + v = mkviewport(vr); + if(v == nil){ + werrstr("mkviewport: %r"); + return nil; + } + return Camv(v, r, p, fov, n, f); +} + Camera * newcamera(void) { -- cgit v1.2.3