]> Dogcows Code - chaz/rasterize/blob - raster.h
refactor triangle group into a separate class
[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 "model.h"
15 #include "tri.h"
16
17
18 /*
19 * A pixel map for storing and manipulating a 2D grid of color values.
20 */
21 typedef struct raster raster_t;
22
23
24 /*
25 * Create a new raster on the heap.
26 */
27 raster_t* raster_alloc(int width, int height, color_t fill);
28
29 /*
30 * Free up the memory associated with the raster.
31 */
32 void raster_destroy(raster_t* p);
33
34
35 /*
36 * Print some optimization statistics.
37 */
38 void raster_printstats(raster_t* p);
39
40
41 /*
42 * Set the viewport rectangle. This effectively sets up a clipping rectangle
43 * where nothing is drawn outside of the rectangle. The default viewport is
44 * [0, 0, width, height], or the entire raster area.
45 */
46 void raster_viewport(raster_t* p, int x, int y, int width, int height);
47
48 /*
49 * Set the model matrix. This positions the model, providing the
50 * transformation for converting to eye coordinates.
51 */
52 void raster_model(raster_t* p, const mat_t* transform);
53
54 /*
55 * Set the view matrix. This positions the camera, providing the
56 * transformation for converting to world coordinates.
57 */
58 void raster_view(raster_t* p, const mat_t* transform);
59
60 /*
61 * Set the projection matrix. This provides the transformation for converting
62 * to canonical coordinates.
63 */
64 void raster_projection(raster_t* p, const mat_t* transform);
65
66
67 /*
68 * Set the location of the viewer in world coordinates. This is used in
69 * specular lighting calculations.
70 */
71 void raster_eye(raster_t* p, vec_t eye);
72
73 /*
74 * Set the ambient light for the scene.
75 */
76 void raster_ambient(raster_t* p, color_t ambient);
77
78 /*
79 * Add a light to the scene.
80 */
81 void raster_light(raster_t* p, light_t light);
82
83 /*
84 * Set the material properties for the scene.
85 */
86 void raster_material(raster_t* p, color_t specular, scal_t shininess);
87
88
89 /*
90 * Save the raster to a PPM file.
91 */
92 int raster_export_ppm(const raster_t* p, const char* filename);
93
94 /*
95 * Save the raster to a BMP file.
96 */
97 int raster_export_bmp(const raster_t* p, const char* filename);
98
99
100 /*
101 * Fill the entire raster with a solid color and reset the raster statistics.
102 */
103 void raster_clear(raster_t* p, color_t fill);
104
105 /*
106 * Draw a model to the raster.
107 */
108 void raster_draw_model(raster_t* p, const model_t* model);
109
110 /*
111 * Draw a triangle to the raster.
112 */
113 void raster_draw_tri(raster_t* p, const tri_t* triangle);
114
115
116 #endif // _RASTER_H_
117
This page took 0.035993 seconds and 4 git commands to generate.