]> Dogcows Code - chaz/rasterize/blob - raster.h
add scene lighting constructs; real stdin support
[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 * Set the ambient light for the scene.
74 */
75 void raster_ambient(raster_t* p, color_t ambient);
76
77 /*
78 * Add a light to the scene.
79 */
80 void raster_light(raster_t* p, light_t light);
81
82 /*
83 * Set the material properties for the scene.
84 */
85 void raster_material(raster_t* p, color_t specular, scal_t shininess);
86
87
88 /*
89 * Save the raster to a PPM file.
90 */
91 int raster_export_ppm(const raster_t* p, const char* filename);
92
93 /*
94 * Save the raster to a BMP file.
95 */
96 int raster_export_bmp(const raster_t* p, const char* filename);
97
98
99 /*
100 * Fill the entire raster with a solid color and reset the raster statistics.
101 */
102 void raster_clear(raster_t* p, color_t fill);
103
104 /*
105 * Draw a smooth gradient triangle to the raster.
106 */
107 void raster_draw_tri(raster_t* p, const tri_t* triangle);
108
109
110 #endif // _RASTER_H_
111
This page took 0.031576 seconds and 4 git commands to generate.