summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-09-21 16:15:21 +0000
committerrodri <rgl@antares-labs.eu>2024-09-21 16:15:21 +0000
commita8c789be9ab0fec65004118b7df373e84900cb1a (patch)
treeec50773d05e4cd15f22dfc7ec19c4ddc8ec77a88
parentd8f71404ffd54af08bc84dbb04e60cb07e83a021 (diff)
downloadlibgraphics-a8c789be9ab0fec65004118b7df373e84900cb1a.tar.gz
libgraphics-a8c789be9ab0fec65004118b7df373e84900cb1a.tar.bz2
libgraphics-a8c789be9ab0fec65004118b7df373e84900cb1a.zip
camera: add a Camv constructor.
-rw-r--r--camera.c24
-rw-r--r--graphics.h3
-rw-r--r--util.c2
3 files changed, 21 insertions, 8 deletions
diff --git a/camera.c b/camera.c
index 12f37eb..439c596 100644
--- a/camera.c
+++ b/camera.c
@@ -96,22 +96,34 @@ 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)
{
Camera *c;
diff --git a/graphics.h b/graphics.h
index 089156a..2fd516e 100644
--- a/graphics.h
+++ b/graphics.h
@@ -368,6 +368,7 @@ struct Camera
};
/* camera */
+Camera *Camv(Viewport*, Renderer*, Projection, double, double, double);
Camera *Cam(Rectangle, Renderer*, Projection, double, double, double);
Camera *newcamera(void);
void delcamera(Camera*);
@@ -443,7 +444,7 @@ Point2 maxpt2(Point2, Point2);
Point3 modulapt3(Point3, Point3);
Point3 minpt3(Point3, Point3);
Point3 maxpt3(Point3, Point3);
-Memimage *rgb(ulong);
+Memimage *rgba(ulong);
Memimage *dupmemimage(Memimage*);
/* color */
diff --git a/util.c b/util.c
index babaaf4..3ff7323 100644
--- a/util.c
+++ b/util.c
@@ -101,7 +101,7 @@ memsetl(void *dp, ulong v, usize len)
}
Memimage *
-rgb(ulong c)
+rgba(ulong c)
{
Memimage *i;