]> Dogcows Code - chaz/rasterize/blob - config.h
add phong interpolation (lighting)
[chaz/rasterize] / config.h
1
2 /*
3 * CS5600 University of Utah
4 * Charles McGarvey
5 * mcgarvey@eng.utah.edu
6 */
7
8 #ifndef _CONFIG_H_
9 #define _CONFIG_H_
10
11 /*
12 * BACKFACE_CULLING
13 * If enabled, triangles that are facing away from the viewer, according to
14 * the right-hand rule and counter-clockwise winding of the verticies, will
15 * not be drawn. This option can improve performance in some situations, but
16 * it may also cause visual problems for models that aren't entirely closed.
17 */
18 #if BACKFACE_CULLING
19 #define IF_BACKFACE_CULLING(X) X
20 #else
21 #define IF_BACKFACE_CULLING(X)
22 #endif
23
24 /*
25 * CLIPPING
26 * If enabled, triangles will be not be drawn if they are entirely outside of
27 * the viewing volume. The number of pixels tested while rasterizing a
28 * triangle can also be minimized, which leads to a huge performance boost.
29 * For that reason, this is on unless explicitly disabled, and you really
30 * always want to leave it enabled. Note that this does not have anything to
31 * do with viewport clipping, which is always performed. Also note that any
32 * triangle which is partially within the viewing volume will be entirely
33 * drawn, which may be somewhat unexpected.
34 */
35 #ifndef CLIPPING
36 #define CLIPPING 1
37 #endif
38 #if CLIPPING
39 #define IF_CLIPPING(X) X
40 #else
41 #define IF_CLIPPING(X)
42 #endif
43
44 /*
45 * DEPTH_TEST
46 * If enabled, a z-buffer will be used to perform some sort of depth testing,
47 * resulting in the generally desirable situation where triangles that are
48 * further away will not appear in front of triangles that are closer. There
49 * is a performance penalty for this, so it must be enabled.
50 */
51 #if DEPTH_TEST
52 #define IF_DEPTH_TEST(X) X
53 #else
54 #define IF_DEPTH_TEST(X)
55 #endif
56
57 /*
58 * DOUBLE_FLOAT
59 * If enabled, scalars will be of type double. This provides and insane level
60 * of precision at a performance cost. The default behavior just uses floats.
61 */
62 #if DOUBLE_FLOAT
63 #define IF_DOUBLE_FLOAT(X) X
64 #else
65 #define IF_DOUBLE_FLOAT(X)
66 #endif
67
68 /*
69 * EXPORT_BMP
70 * If enabled, each scene rasterization will be saved as a BMP image file.
71 * This is on unless explicitly disabled.
72 */
73 #ifndef EXPORT_BMP
74 #define EXPORT_BMP 1
75 #endif
76 #if EXPORT_BMP
77 #define IF_EXPORT_BMP(X) X
78 #else
79 #define IF_EXPORT_BMP(X)
80 #endif
81
82 /*
83 * EXPORT_PPM
84 * If enabled, each scene rasterization will be saved as a PPM image file.
85 * This is on unless explicitly disabled.
86 */
87 #ifndef EXPORT_PPM
88 #define EXPORT_PPM 1
89 #endif
90 #if EXPORT_PPM
91 #define IF_EXPORT_PPM(X) X
92 #else
93 #define IF_EXPORT_PPM(X)
94 #endif
95
96 /*
97 * EXTRA_INLINE
98 * If enabled, functions that are defined in interface files will be marked as
99 * inline. The compiler will generally inline functions according to its own
100 * optimization heuristics, and this inline marking may persuade the compiler
101 * to inline a function that it otherwise would not. This option may bring a
102 * small performance boost, but it can also increase the size of the program
103 * executable.
104 */
105 #if EXTRA_INLINE
106 #define IF_EXTRA_INLINE(X) X
107 #else
108 #define IF_EXTRA_INLINE(X)
109 #endif
110
111 /*
112 * LIGHTING
113 * If enabled, local lighting will be used to increase realism of the scene.
114 * This option has a performance cost, but it can produce interesting visuals.
115 * The behavior of this option is effected by its precise value:
116 * 1 Phong lighting model with flat (per-face) interpolation.
117 * 2 Phong lighting model with Gouraud (per-vertex) interpolation.
118 * 3 Phong lighting model with Phong (per-pixel) interpolation.
119 */
120 #if LIGHTING
121 #define IF_LIGHTING(X) X
122 #else
123 #define IF_LIGHTING(X)
124 #endif
125
126 /*
127 * NDEBUG
128 * If enabled, assertions and other nonessential checks will not be compiled
129 * into the programs.
130 */
131 #if NDEBUG
132 #define IF_NDEBUG(X) X
133 #else
134 #define IF_NDEBUG(X)
135 #endif
136
137 /*
138 * PRE_NORMALS
139 * If enabled, normals are pre-computed while the triangles are loading.
140 * Otherwise, the normals are computed during rasterization. The behavior of
141 * this option is effected by its precise value:
142 * 1 Normals are computed per-face, according to the right-hand rule and
143 * counter-clockwise winding of the verticies.
144 * 2 Normals are computed per-vertex; the normal for a vertex that is shared
145 * between two or more faces will be the average of the normals of the
146 * faces. There is a performance penalty for this setting.
147 * 3 Same as 2, but the normals will be cached so that they will not need to
148 * be computed the next time the mesh is loaded.
149 */
150 #if PRE_NORMALS
151 #define IF_PRE_NORMALS(X) X
152 #else
153 #define IF_PRE_NORMALS(X)
154 #endif
155
156 /*
157 * SMOOTH_COLOR
158 * If enabled, color will be interpolated across the face of a triangle.
159 * Otherwise, the color will flat, and the average color of the colors
160 * associated with each vertex will be used.
161 */
162 #if SMOOTH_COLOR
163 #define IF_SMOOTH_COLOR(X) X
164 #else
165 #define IF_SMOOTH_COLOR(X)
166 #endif
167
168 /*
169 * VERBOSITY
170 * If enabled, a description of what is happening will be printed to stdout.
171 * Otherwise, nothing is printed. The behavior of this option is effected by
172 * its precise value:
173 * 1 Print just a few very general descriptions.
174 * 2 After rasterization, also print the triangle count and other
175 * information that may be interesting.
176 * 3 Also print the number of seconds it took to render the entire scene,
177 * according to wall time.
178 * 4 Also print the number of triangles as they are being rastered. This
179 * uses ANSI escape codes which may not be supported on all terminals.
180 * It also causes a lot to be printed, so it can actually decrease render
181 * performance, especially on a slow (or remote) terminal.
182 * The default setting for this option is 3.
183 */
184 #ifndef VERBOSITY
185 #define VERBOSITY 3
186 #endif
187 #if VERBOSITY >= 2
188 #define IF_RASTER_STATS(X) X
189 #else
190 #define IF_RASTER_STATS(X)
191 #endif
192 #if VERBOSITY >= 3
193 #define IF_RENDER_TIMER(X) X
194 #else
195 #define IF_RENDER_TIMER(X)
196 #endif
197 #if VERBOSITY >= 4
198 #define IF_RENDER_PROGRESS(X) X
199 #else
200 #define IF_RENDER_PROGRESS(X)
201 #endif
202
203 #endif // _CONFIG_H_
204
This page took 0.042581 seconds and 5 git commands to generate.