diff options
author | rodri <rgl@antares-labs.eu> | 2020-04-17 11:42:47 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2020-04-17 11:42:47 +0000 |
commit | 91d8cc8d9adfec7e9b5f415ebd7b7f740cde6e2d (patch) | |
tree | 66cdaa79197a65d9151c5952f7d2c803576e556f /graphics.h | |
download | libgraphics-91d8cc8d9adfec7e9b5f415ebd7b7f740cde6e2d.tar.gz libgraphics-91d8cc8d9adfec7e9b5f415ebd7b7f740cde6e2d.tar.bz2 libgraphics-91d8cc8d9adfec7e9b5f415ebd7b7f740cde6e2d.zip |
standalone version release.
Diffstat (limited to 'graphics.h')
-rw-r--r-- | graphics.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/graphics.h b/graphics.h new file mode 100644 index 0000000..b9582f3 --- /dev/null +++ b/graphics.h @@ -0,0 +1,42 @@ +typedef enum { + Portho, /* orthographic */ + Ppersp /* perspective */ +} Projection; + +typedef struct Vertex Vertex; +typedef struct Camera Camera; + +struct Vertex { + Point3 p; /* position */ + Point3 n; /* surface normal */ +}; + +struct Camera { + RFrame3; /* VCS */ + Image *viewport; + double fov; /* vertical FOV */ + struct { + double n, f; + } clip; + Matrix3 proj; /* VCS to NDC xform */ + Projection ptype; +}; + +/* Camera */ +void configcamera(Camera*, Image*, double, double, double, Projection); +void placecamera(Camera*, Point3, Point3, Point3); +void aimcamera(Camera*, Point3); +void reloadcamera(Camera*); + +/* rendering */ +#define FPS2MS(n) (1000/(n)) +#define WORLD2VCS(cp, p) (rframexform3((p), *(cp))) +#define VCS2NDC(cp, p) (xform3((p), (cp)->proj)) +#define WORLD2NDC(cp, p) (VCS2NDC((cp), WORLD2VCS((cp), (p)))) +int isclipping(Point3); +Point toviewport(Camera*, Point3); +Point2 fromviewport(Camera*, Point); +void perspective(Matrix3, double, double, double, double); +void orthographic(Matrix3, double, double, double, double, double, double); +void line3(Camera*, Point3, Point3, int, int, Image*); +Point string3(Camera*, Point3, Image*, Font*, char*); |