ef358e71855b96d05eaef150f6a526e0d12dac12
[chaz/rasterize] / raster.h
1
2 /*
3 * CS5600 University of Utah
4 * Charles McGarvey
5 * mcgarvey@eng.utah.edu
6 */
7
8 #ifndef _RASTER_H_
9 #define _RASTER_H_
10
11 #include "color.h"
12 #include "common.h"
13 #include "light.h"
14 #include "tri.h"
15
16
17 /*
18 * A pixel map for storing and manipulating a 2D grid of color values.
19 */
20 typedef struct raster raster_t;
21
22
23 /*
24 * Create a new raster on the heap.
25 */
26 raster_t* raster_alloc(int width, int height, color_t fill);
27
28 /*
29 * Free up the memory associated with the raster.
30 */
31 void raster_destroy(raster_t* p);
32
33
34 /*
35 * Print some optimization statistics.
36 */
37 void raster_printstats(raster_t* p);
38
39
40 /*
41 * Set the viewport rectangle. This effectively sets up a clipping rectangle
42 * where nothing is drawn outside of the rectangle. The default viewport is
43 * [0, 0, width, height], or the entire raster area.
44 */
45 void raster_viewport(raster_t* p, int x, int y, int width, int height);
46
47 /*
48 * Set the model matrix. This positions the model, providing the
49 * transformation for converting to eye coordinates.
50 */
51 void raster_model(raster_t* p, const mat_t* transform);
52
53 /*
54 * Set the view matrix. This positions the camera, providing the
55 * transformation for converting to world coordinates.
56 */
57 void raster_view(raster_t* p, const mat_t* transform);
58
59 /*
60 * Set the projection matrix. This provides the transformation for converting
61 * to canonical coordinates.
62 */
63 void raster_projection(raster_t* p, const mat_t* transform);
64
65
66 /*
67 * Set the location of the viewer in world coordinates. This is used in
68 * specular lighting calculations.
69 */
70 void raster_eye(raster_t* p, vec_t eye);
71
72 /*
73 * Add a light to the scene.
74 */
75 void raster_light(raster_t* p, light_t light);
76
77
78 /*
79 * Save the raster to a PPM file.
80 */
81 int raster_export_ppm(const raster_t* p, const char* filename);
82
83 /*
84 * Save the raster to a BMP file.
85 */
86 int raster_export_bmp(const raster_t* p, const char* filename);
87
88
89 /*
90 * Fill the entire raster with a solid color and reset the raster statistics.
91 */
92 void raster_clear(raster_t* p, color_t fill);
93
94 /*
95 * Draw a smooth gradient triangle to the raster.
96 */
97 void raster_draw_tri(raster_t* p, const tri_t* triangle);
98
99
100 #endif // _RASTER_H_
101
This page took 0.041809 seconds and 3 git commands to generate.