shithub: libgraphics

Download patch

ref: a8c789be9ab0fec65004118b7df373e84900cb1a
parent: d8f71404ffd54af08bc84dbb04e60cb07e83a021
author: rodri <rgl@antares-labs.eu>
date: Sat Sep 21 12:15:21 EDT 2024

camera: add a Camv constructor.

--- a/camera.c
+++ b/camera.c
@@ -96,19 +96,31 @@
 }
 
 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 *
--- a/graphics.h
+++ b/graphics.h
@@ -368,6 +368,7 @@
 };
 
 /* 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 @@
 Point3 modulapt3(Point3, Point3);
 Point3 minpt3(Point3, Point3);
 Point3 maxpt3(Point3, Point3);
-Memimage *rgb(ulong);
+Memimage *rgba(ulong);
 Memimage *dupmemimage(Memimage*);
 
 /* color */
--- a/util.c
+++ b/util.c
@@ -101,7 +101,7 @@
 }
 
 Memimage *
-rgb(ulong c)
+rgba(ulong c)
 {
 	Memimage *i;