X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Frasterize;a=blobdiff_plain;f=raster.h;fp=raster.h;h=ef358e71855b96d05eaef150f6a526e0d12dac12;hp=0000000000000000000000000000000000000000;hb=c875478cdd823c7df8fdc859941bd9e5948c9315;hpb=82087d9bb9e28c2375008bde4453f6c019419697 diff --git a/raster.h b/raster.h new file mode 100644 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_ +