]> Dogcows Code - chaz/rasterize/blob - vert.h
add scene lighting constructs; real stdin support
[chaz/rasterize] / vert.h
1
2 /*
3 * CS5600 University of Utah
4 * Charles McGarvey
5 * mcgarvey@eng.utah.edu
6 */
7
8 #ifndef _VERT_H_
9 #define _VERT_H_
10
11 #include "color.h"
12 #include "vec.h"
13
14
15 /*
16 * A vertex is a point, a normal, and a color.
17 */
18 struct vert
19 {
20 vec_t v;
21 vec_t n;
22 color_t c;
23 };
24 typedef struct vert vert_t;
25
26
27 /*
28 * Initialize a vertex with a point vector, normal, and a color.
29 */
30 INLINE_MAYBE
31 void vert_init(vert_t* r, vec_t v, vec_t n, color_t c)
32 {
33 r->v = v;
34 r->n = n;
35 r->c = c;
36 }
37
38
39 /*
40 * Create a new vertex with a point vector.
41 */
42 INLINE_MAYBE
43 vert_t vert_new(vec_t v)
44 {
45 vert_t r;
46 vert_init(&r, v, VEC_ZERO, COLOR_WHITE);
47 return r;
48 }
49
50 /*
51 * Create a new vertex from vector components.
52 */
53 INLINE_MAYBE
54 vert_t vert_new2(scal_t x, scal_t y, scal_t z)
55 {
56 return vert_new(vec_new(x, y, z));
57 }
58
59 #define VERT_ZERO vert_new(VEC_ZERO)
60
61
62 #endif // _VERT_H_
63
This page took 0.035769 seconds and 4 git commands to generate.