]> Dogcows Code - chaz/rasterize/blob - raster.h
add opengl 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 "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 * Get the width of the raster.
48 */
49 int raster_width(const raster_t* p);
50
51 /*
52 * Get the height of the raster.
53 */
54 int raster_height(const raster_t* p);
55
56 /*
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.
59 */
60 void* raster_data(const raster_t* p);
61
62
63 /*
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.
67 */
68 void raster_viewport(raster_t* p, int x, int y, int width, int height);
69
70 /*
71 * Set the model matrix. This positions the model, providing the
72 * transformation for converting to eye coordinates.
73 */
74 void raster_model(raster_t* p, const mat_t* transform);
75
76 /*
77 * Set the view matrix. This positions the camera, providing the
78 * transformation for converting to world coordinates.
79 */
80 void raster_view(raster_t* p, const mat_t* transform);
81
82 /*
83 * Set the projection matrix. This provides the transformation for converting
84 * to canonical coordinates.
85 */
86 void raster_projection(raster_t* p, const mat_t* transform);
87
88
89 /*
90 * Set the location of the viewer in world coordinates. This is used in
91 * specular lighting calculations.
92 */
93 void raster_eye(raster_t* p, vec_t eye);
94
95 /*
96 * Set the ambient light for the scene.
97 */
98 void raster_ambient(raster_t* p, color_t ambient);
99
100 /*
101 * Add a light to the scene.
102 */
103 void raster_light(raster_t* p, light_t light);
104
105 /*
106 * Set the material properties for the scene.
107 */
108 void raster_material(raster_t* p, color_t specular, scal_t shininess);
109
110
111 /*
112 * Save the raster to a PPM file.
113 */
114 int raster_export_ppm(const raster_t* p, const char* filename);
115
116 /*
117 * Save the raster to a BMP file.
118 */
119 int raster_export_bmp(const raster_t* p, const char* filename);
120
121
122 /*
123 * Load the raster from an image file. The file extension is used to
124 * determine which importer is actually called.
125 */
126 raster_t* raster_import(const char* filename);
127
128 /*
129 * Load the raster from a PPM file.
130 */
131 raster_t* raster_import_ppm(const char* filename);
132
133 /*
134 * Load the raster from a BMP file.
135 */
136 raster_t* raster_import_bmp(const char* filename);
137
138
139 /*
140 * Fill the entire raster with a solid color and reset the raster statistics.
141 */
142 void raster_clear(raster_t* p, color_t fill);
143
144 /*
145 * Draw a model to the raster.
146 */
147 void raster_draw_model(raster_t* p, const model_t* model);
148
149 /*
150 * Draw a triangle to the raster.
151 */
152 void raster_draw_tri(raster_t* p, const tri_t* triangle);
153
154
155 #endif // _RASTER_H_
156
This page took 0.035139 seconds and 4 git commands to generate.