]> Dogcows Code - chaz/rasterize/blob - raster.h
make animate script work for modern luas
[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 * Get the color value at a particular point.
43 */
44 color_t raster_color(const raster_t* p, vec_t pt);
45
46
47 /*
48 * Set the viewport rectangle. This effectively sets up a clipping rectangle
49 * where nothing is drawn outside of the rectangle. The default viewport is
50 * [0, 0, width, height], or the entire raster area.
51 */
52 void raster_viewport(raster_t* p, int x, int y, int width, int height);
53
54 /*
55 * Set the model matrix. This positions the model, providing the
56 * transformation for converting to eye coordinates.
57 */
58 void raster_model(raster_t* p, const mat_t* transform);
59
60 /*
61 * Set the view matrix. This positions the camera, providing the
62 * transformation for converting to world coordinates.
63 */
64 void raster_view(raster_t* p, const mat_t* transform);
65
66 /*
67 * Set the projection matrix. This provides the transformation for converting
68 * to canonical coordinates.
69 */
70 void raster_projection(raster_t* p, const mat_t* transform);
71
72
73 /*
74 * Set the location of the viewer in world coordinates. This is used in
75 * specular lighting calculations.
76 */
77 void raster_eye(raster_t* p, vec_t eye);
78
79 /*
80 * Set the ambient light for the scene.
81 */
82 void raster_ambient(raster_t* p, color_t ambient);
83
84 /*
85 * Add a light to the scene.
86 */
87 void raster_light(raster_t* p, light_t light);
88
89 /*
90 * Set the material properties for the scene.
91 */
92 void raster_material(raster_t* p, color_t specular, scal_t shininess);
93
94
95 /*
96 * Save the raster to a PPM file.
97 */
98 int raster_export_ppm(const raster_t* p, const char* filename);
99
100 /*
101 * Save the raster to a BMP file.
102 */
103 int raster_export_bmp(const raster_t* p, const char* filename);
104
105
106 /*
107 * Load the raster from an image file. The file extension is used to
108 * determine which importer is actually called.
109 */
110 raster_t* raster_import(const char* filename);
111
112 /*
113 * Load the raster from a PPM file.
114 */
115 raster_t* raster_import_ppm(const char* filename);
116
117 /*
118 * Load the raster from a BMP file.
119 */
120 raster_t* raster_import_bmp(const char* filename);
121
122
123 /*
124 * Fill the entire raster with a solid color and reset the raster statistics.
125 */
126 void raster_clear(raster_t* p, color_t fill);
127
128 /*
129 * Draw a model to the raster.
130 */
131 void raster_draw_model(raster_t* p, const model_t* model);
132
133 /*
134 * Draw a triangle to the raster.
135 */
136 void raster_draw_tri(raster_t* p, const tri_t* triangle);
137
138
139 #endif // _RASTER_H_
140
This page took 0.035466 seconds and 5 git commands to generate.