]>
Dogcows Code - chaz/rasterize/blob - raster.h
3 * CS5600 University of Utah
5 * mcgarvey@eng.utah.edu
19 * A pixel map for storing and manipulating a 2D grid of color values.
21 typedef struct raster raster_t
;
25 * Create a new raster on the heap.
27 raster_t
* raster_alloc(int width
, int height
, color_t fill
);
30 * Free up the memory associated with the raster.
32 void raster_destroy(raster_t
* p
);
36 * Print some optimization statistics.
38 void raster_printstats(raster_t
* p
);
42 * Get the color value at a particular point.
44 color_t
raster_color(const raster_t
* p
, vec_t pt
);
47 * Get the width of the raster.
49 int raster_width(const raster_t
* p
);
52 * Get the height of the raster.
54 int raster_height(const raster_t
* p
);
57 * Get a copy of the raw RGBA pixel data of the raster. The returned
58 * buffer is indeed a copy and must be freed when no longer needed.
60 void* raster_data(const raster_t
* p
);
64 * Set the viewport rectangle. This effectively sets up a clipping rectangle
65 * where nothing is drawn outside of the rectangle. The default viewport is
66 * [0, 0, width, height], or the entire raster area.
68 void raster_viewport(raster_t
* p
, int x
, int y
, int width
, int height
);
71 * Set the model matrix. This positions the model, providing the
72 * transformation for converting to eye coordinates.
74 void raster_model(raster_t
* p
, const mat_t
* transform
);
77 * Set the view matrix. This positions the camera, providing the
78 * transformation for converting to world coordinates.
80 void raster_view(raster_t
* p
, const mat_t
* transform
);
83 * Set the projection matrix. This provides the transformation for converting
84 * to canonical coordinates.
86 void raster_projection(raster_t
* p
, const mat_t
* transform
);
90 * Set the location of the viewer in world coordinates. This is used in
91 * specular lighting calculations.
93 void raster_eye(raster_t
* p
, vec_t eye
);
96 * Set the ambient light for the scene.
98 void raster_ambient(raster_t
* p
, color_t ambient
);
101 * Add a light to the scene.
103 void raster_light(raster_t
* p
, light_t light
);
106 * Set the material properties for the scene.
108 void raster_material(raster_t
* p
, color_t specular
, scal_t shininess
);
112 * Save the raster to a PPM file.
114 int raster_export_ppm(const raster_t
* p
, const char* filename
);
117 * Save the raster to a BMP file.
119 int raster_export_bmp(const raster_t
* p
, const char* filename
);
123 * Load the raster from an image file. The file extension is used to
124 * determine which importer is actually called.
126 raster_t
* raster_import(const char* filename
);
129 * Load the raster from a PPM file.
131 raster_t
* raster_import_ppm(const char* filename
);
134 * Load the raster from a BMP file.
136 raster_t
* raster_import_bmp(const char* filename
);
140 * Fill the entire raster with a solid color and reset the raster statistics.
142 void raster_clear(raster_t
* p
, color_t fill
);
145 * Draw a model to the raster.
147 void raster_draw_model(raster_t
* p
, const model_t
* model
);
150 * Draw a triangle to the raster.
152 void raster_draw_tri(raster_t
* p
, const tri_t
* triangle
);
This page took 0.040366 seconds and 5 git commands to generate.