]> Dogcows Code - chaz/rasterize/blobdiff - raster.h
add support for 3d scenes, depth testing, lighting
[chaz/rasterize] / raster.h
diff --git a/raster.h b/raster.h
new file mode 100644 (file)
index 0000000..ef358e7
--- /dev/null
+++ b/raster.h
@@ -0,0 +1,101 @@
+
+/*
+ * CS5600 University of Utah
+ * Charles McGarvey
+ * mcgarvey@eng.utah.edu
+ */
+
+#ifndef _RASTER_H_
+#define _RASTER_H_
+
+#include "color.h"
+#include "common.h"
+#include "light.h"
+#include "tri.h"
+
+
+/*
+ * A pixel map for storing and manipulating a 2D grid of color values.
+ */
+typedef struct raster raster_t;
+
+
+/*
+ * Create a new raster on the heap.
+ */
+raster_t* raster_alloc(int width, int height, color_t fill);
+
+/*
+ * Free up the memory associated with the raster.
+ */
+void raster_destroy(raster_t* p);
+
+
+/*
+ * Print some optimization statistics.
+ */
+void raster_printstats(raster_t* p);
+
+
+/*
+ * Set the viewport rectangle.  This effectively sets up a clipping rectangle
+ * where nothing is drawn outside of the rectangle.  The default viewport is
+ * [0, 0, width, height], or the entire raster area.
+ */
+void raster_viewport(raster_t* p, int x, int y, int width, int height);
+
+/*
+ * Set the model matrix.  This positions the model, providing the
+ * transformation for converting to eye coordinates.
+ */
+void raster_model(raster_t* p, const mat_t* transform);
+
+/*
+ * Set the view matrix.  This positions the camera, providing the
+ * transformation for converting to world coordinates.
+ */
+void raster_view(raster_t* p, const mat_t* transform);
+
+/*
+ * Set the projection matrix.  This provides the transformation for converting
+ * to canonical coordinates.
+ */
+void raster_projection(raster_t* p, const mat_t* transform);
+
+
+/*
+ * Set the location of the viewer in world coordinates.  This is used in
+ * specular lighting calculations.
+ */
+void raster_eye(raster_t* p, vec_t eye);
+
+/*
+ * Add a light to the scene.
+ */
+void raster_light(raster_t* p, light_t light);
+
+
+/*
+ * Save the raster to a PPM file.
+ */
+int raster_export_ppm(const raster_t* p, const char* filename);
+
+/*
+ * Save the raster to a BMP file.
+ */
+int raster_export_bmp(const raster_t* p, const char* filename);
+
+
+/*
+ * Fill the entire raster with a solid color and reset the raster statistics.
+ */
+void raster_clear(raster_t* p, color_t fill);
+
+/*
+ * Draw a smooth gradient triangle to the raster.
+ */
+void raster_draw_tri(raster_t* p, const tri_t* triangle);
+
+
+#endif // _RASTER_H_
+
This page took 0.01772 seconds and 4 git commands to generate.