/* * CS5600 University of Utah * Charles McGarvey * mcgarvey@eng.utah.edu */ #ifndef __PIXMAP_H__ #define __PIXMAP_H__ #include "color.h" #include "common.h" #include "tri.h" /* * A pixel map for storing and manipulating a 2D grid of color values. */ typedef struct pixmap pixmap_t; /* * Create a new pixmap on the heap. */ pixmap_t* pixmap_alloc(int width, int height, color_t fill); /* * Free up the memory associated with the pixmap. */ void pixmap_destroy(pixmap_t* p); /* * Fill the entire pixmap with a solid color. */ void pixmap_clear(pixmap_t* p, color_t fill); /* * 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 pixmap area. */ void pixmap_viewport(pixmap_t* p, int x, int y, int width, int height); /* * Set the modelview matrix. This positions the model or camera. */ void pixmap_modelview(pixmap_t* p, const mat_t* transform); /* * Set the projection matrix. This provides the transformation matrix for * converting to screen space. */ void pixmap_projection(pixmap_t* p, const mat_t* transform); /* * Save the pixmap to a PPM file. */ int pixmap_export_ppm(const pixmap_t* p, const char* filename); /* * Save the pixmap to a BMP file. */ int pixmap_export_bmp(const pixmap_t* p, const char* filename); /* * Draw a smooth gradient triangle to the pixmap. */ void pixmap_draw_tri(pixmap_t* p, const tri_t* triangle); #endif // __PIXMAP_H__