diff options
author | rodri <rgl@antares-labs.eu> | 2020-03-06 21:05:07 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2020-03-06 21:05:07 +0000 |
commit | 263444216730830b712a4f8f3a087513c5ac93e9 (patch) | |
tree | 57ddf2764c23a76df14a0acbdd956b97dec37253 /graphics.h | |
parent | a435467f81a1d9d429109f3a34988c642bed6035 (diff) | |
download | 3dee-263444216730830b712a4f8f3a087513c5ac93e9.tar.gz 3dee-263444216730830b712a4f8f3a087513c5ac93e9.tar.bz2 3dee-263444216730830b712a4f8f3a087513c5ac93e9.zip |
redesign of the camera abstraction. general unused/useless data cleaning.
Diffstat (limited to 'graphics.h')
-rw-r--r-- | graphics.h | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -10,35 +10,42 @@ typedef struct Camera Camera; struct Vertex { Point3 p; /* position */ Point3 n; /* surface normal */ - //Image tx; /* (?) */ +}; + +struct Viewport +{ + RFrame; + Memimage *fb; }; struct Camera { RFrame3; /* VCS */ - Image *viewport; + Viewport viewport; double fov; /* vertical FOV */ - struct { - double n, f; /* near and far clipping planes */ - } clip; + double clipn; + double clipf; Matrix3 proj; /* VCS to NDC xform */ Projection ptype; + + void (*updatefb)(Camera*, Rectangle, ulong); }; /* Camera */ -void perspective(Matrix3, double, double, double, double); -void orthographic(Matrix3, double, double, double, double, double, double); +Camera *alloccamera(Rectangle, ulong); 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 FPS2MS(n) (1000/(n)) #define WORLD2VCS(cp, p) (rframexform3((p), *(cp))) -#define VCS2NDC(cp, p) (xform3((p), (cp)->proj)) +#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 line3(Camera *c, Point3 p0, Point3 p1, int end0, int end1, Image *src); -Point string3(Camera *c, Point3 p, Image *src, Font *f, char *s); +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*); |