summaryrefslogtreecommitdiff
path: root/graphics.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2020-06-29 18:28:02 +0000
committerrodri <rgl@antares-labs.eu>2020-06-29 18:28:02 +0000
commit6477319da461ad78a120a3c777228eaa8194c9f8 (patch)
treec009fc9bc5a868532d38d3518385e441529b0b2c /graphics.h
parent3857a7ad606f4f050411d27fc94116731fddb1b3 (diff)
downloadlibgraphics-6477319da461ad78a120a3c777228eaa8194c9f8.tar.gz
libgraphics-6477319da461ad78a120a3c777228eaa8194c9f8.tar.bz2
libgraphics-6477319da461ad78a120a3c777228eaa8194c9f8.zip
bring flat triangle rasterization back, with some goodies for future shading work. add uv coordinates to the vertex.
Diffstat (limited to 'graphics.h')
-rw-r--r--graphics.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/graphics.h b/graphics.h
index 44f213d..8e63b67 100644
--- a/graphics.h
+++ b/graphics.h
@@ -8,6 +8,7 @@ typedef struct Vertex Vertex;
typedef struct Framebuffer Framebuffer;
typedef struct Viewport Viewport;
typedef struct Camera Camera;
+typedef struct Triangle Triangle;
struct Color
{
@@ -19,6 +20,7 @@ struct Vertex
Point3 p; /* position */
Point3 n; /* surface normal */
Color c; /* shading color */
+ Point2 uv; /* texture coordinate */
};
struct Framebuffer
@@ -47,6 +49,11 @@ struct Camera
Projection ptype;
};
+struct Triangle
+{
+ Point p0, p1, p2;
+};
+
/* Camera */
void configcamera(Camera*, Image*, double, double, double, Projection);
void placecamera(Camera*, Point3, Point3, Point3);
@@ -64,5 +71,12 @@ Point toviewport(Camera*, Point3);
Point2 fromviewport(Camera*, Point);
void perspective(Matrix3, double, double, double, double);
void orthographic(Matrix3, double, double, double, double, double, double);
+/* temporary debug helpers */
void line3(Camera*, Point3, Point3, int, int, Image*);
Point string3(Camera*, Point3, Image*, Font*, char*);
+
+/* triangle */
+Triangle Trian(int, int, int, int, int, int);
+Triangle Trianpt(Point, Point, Point);
+void triangle(Image*, Triangle, int, Image*, Point);
+void filltriangle(Image*, Triangle, Image*, Point);