]> Dogcows Code - chaz/rasterize/blob - config.h
add opengl support
[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 * OPENGL
13 * If enabled, the software rasterizer will be bypassed and the scene will
14 * be rendered using OpenGL. The resulting image will not be exported;
15 * rather, GLUT will be used to display the scene in a window. This option
16 * overrides options effecting the software rasterizer. Also, the float
17 * size will be 32-bit regardless of the DOUBLE_FLOAT option.
18 */
19 #if OPENGL
20 #define IF_OPENGL(X) X
21 #undef DOUBLE_FLOAT
22 #else
23 #define IF_OPENGL(X)
24 #endif
25
26 /*
27 * BACKFACE_CULLING
28 * If enabled, triangles that are facing away from the viewer, according to
29 * the right-hand rule and counter-clockwise winding of the verticies, will
30 * not be drawn. This option can improve performance in some situations, but
31 * it may also cause visual problems for models that aren't entirely closed.
32 */
33 #if BACKFACE_CULLING
34 #define IF_BACKFACE_CULLING(X) X
35 #else
36 #define IF_BACKFACE_CULLING(X)
37 #endif
38
39 /*
40 * BLENDING
41 * If enabled, the blending function Crgb = (1 - Sa)Drgb + (Sa)Srgb is
42 * applied when calculating final colors on the raster.
43 */
44 #if BLENDING
45 #define IF_BLENDING(X) X
46 #else
47 #define IF_BLENDING(X)
48 #endif
49
50 /*
51 * CLIPPING
52 * If enabled, triangles will be not be drawn if they are entirely outside of
53 * the viewing volume. The number of pixels tested while rasterizing a
54 * triangle can also be minimized, which leads to a huge performance boost.
55 * For that reason, this is on unless explicitly disabled, and you really
56 * always want to leave it enabled. Note that this does not have anything to
57 * do with viewport clipping, which is always performed. Also note that any
58 * triangle which is partially within the viewing volume will be entirely
59 * drawn, which may be somewhat unexpected.
60 */
61 #ifndef CLIPPING
62 #define CLIPPING 1
63 #endif
64 #if CLIPPING
65 #define IF_CLIPPING(X) X
66 #else
67 #define IF_CLIPPING(X)
68 #endif
69
70 /*
71 * DEPTH_TEST
72 * If enabled, a z-buffer will be used to perform some sort of depth testing,
73 * resulting in the generally desirable situation where triangles that are
74 * further away will not appear in front of triangles that are closer. There
75 * is a performance penalty for this, so it must be enabled.
76 */
77 #if DEPTH_TEST
78 #define IF_DEPTH_TEST(X) X
79 #else
80 #define IF_DEPTH_TEST(X)
81 #endif
82
83 /*
84 * DOUBLE_FLOAT
85 * If enabled, scalars will be of type double. This provides and insane level
86 * of precision at a performance cost. The default behavior just uses floats.
87 */
88 #if DOUBLE_FLOAT
89 #define IF_DOUBLE_FLOAT(X) X
90 #else
91 #define IF_DOUBLE_FLOAT(X)
92 #endif
93
94 /*
95 * EXPORT_BMP
96 * If enabled, each scene rasterization will be saved as a BMP image file.
97 * This is on unless explicitly disabled.
98 */
99 #ifndef EXPORT_BMP
100 #define EXPORT_BMP 1
101 #endif
102 #if EXPORT_BMP
103 #define IF_EXPORT_BMP(X) X
104 #else
105 #define IF_EXPORT_BMP(X)
106 #endif
107
108 /*
109 * EXPORT_PPM
110 * If enabled, each scene rasterization will be saved as a PPM image file.
111 * This is on unless explicitly disabled.
112 */
113 #ifndef EXPORT_PPM
114 #define EXPORT_PPM 1
115 #endif
116 #if EXPORT_PPM
117 #define IF_EXPORT_PPM(X) X
118 #else
119 #define IF_EXPORT_PPM(X)
120 #endif
121
122 /*
123 * EXTRA_INLINE
124 * If enabled, functions that are defined in interface files will be marked as
125 * inline. The compiler will generally inline functions according to its own
126 * optimization heuristics, and this inline marking may persuade the compiler
127 * to inline a function that it otherwise would not. This option may bring a
128 * small performance boost, but it can also increase the size of the program
129 * executable.
130 */
131 #if EXTRA_INLINE
132 #define IF_EXTRA_INLINE(X) X
133 #else
134 #define IF_EXTRA_INLINE(X)
135 #endif
136
137 /*
138 * LIGHTING
139 * If enabled, local lighting will be used to increase realism of the scene.
140 * This option has a performance cost, but it can produce interesting visuals.
141 * The behavior of this option is effected by its precise value:
142 * 1 Phong lighting model with flat (per-face) interpolation.
143 * 2 Phong lighting model with Gouraud (per-vertex) interpolation.
144 * 3 Phong lighting model with Phong (per-pixel) interpolation.
145 */
146 #if LIGHTING
147 #define IF_LIGHTING(X) X
148 #else
149 #define IF_LIGHTING(X)
150 #endif
151
152 /*
153 * NDEBUG
154 * If enabled, assertions and other nonessential checks will not be compiled
155 * into the programs.
156 */
157 #if NDEBUG
158 #define IF_NDEBUG(X) X
159 #else
160 #define IF_NDEBUG(X)
161 #endif
162
163 /*
164 * CACHE_GEOMETRY
165 * If enabled, models will be saved to a quick-loading binary format after
166 * they are loaded. Or, if a cached version of a model is discovered when a
167 * model is requested to be loaded, it is loaded from the cache instead. This
168 * provides a decent speed improvement in cases where the model would
169 * otherwise be loaded from some kind of text format which would load slowly.
170 */
171 #if CACHE_GEOMETRY
172 #define IF_CACHE_GEOMETRY(X) X
173 #else
174 #define IF_CACHE_GEOMETRY(X)
175 #endif
176
177 /*
178 * CALC_NORMALS
179 * If enabled, per-vertex normals are calculated for models that don't come
180 * with pre-computed normals. This occurs at loading time. The normals are
181 * calculated by averaging the true normals of all the faces shared by each
182 * vertex. Otherwise, only per-face normals are calculated for such models,
183 * also at loading time.
184 */
185 #if CALC_NORMALS
186 #define IF_CALC_NORMALS(X) X
187 #else
188 #define IF_CALC_NORMALS(X)
189 #endif
190
191 /*
192 * SMOOTH_COLOR
193 * If enabled, color will be interpolated across the face of a triangle.
194 * Otherwise, the color will flat, and the average color of the colors
195 * associated with each vertex will be used.
196 */
197 #if SMOOTH_COLOR
198 #define IF_SMOOTH_COLOR(X) X
199 #else
200 #define IF_SMOOTH_COLOR(X)
201 #endif
202
203 /*
204 * TEXTURING
205 * If enabled, a texture will be used to color models that have texture
206 * coordinates. The color from the texture will actually be multiplied
207 * (i.e. mixed) with the regular color associated with the geometry. Also,
208 * Phong interpolation lighting (LIGHTING >= 3) is required to get actual
209 * texturing; otherwise, only the color at the origin point of the texture
210 * will be used.
211 */
212 #if TEXTURING
213 #define IF_TEXTURING(X) X
214 #else
215 #define IF_TEXTURING(X)
216 #endif
217
218 /*
219 * PERSPECTIVE_FIX
220 * If enabled, texturing will have correct perspective on triangles which
221 * show depth. You typically always want this, so it's enabled by default.
222 * This option is useful only if TEXTURING is also enabled.
223 */
224 #ifndef PERSPECTIVE_FIX
225 #define PERSPECTIVE_FIX 1
226 #endif
227 #if PERSPECTIVE_FIX
228 #define IF_PERSPECTIVE_FIX(X) X
229 #else
230 #define IF_PERSPECTIVE_FIX(X)
231 #endif
232
233 /*
234 * VERBOSITY
235 * If enabled, a description of what is happening will be printed to stdout.
236 * Otherwise, nothing is printed. The behavior of this option is effected by
237 * its precise value:
238 * 1 Print just a few very general descriptions.
239 * 2 After rasterization, also print the triangle count and other
240 * information that may be interesting.
241 * 3 Also print the number of seconds it took to render the entire scene,
242 * according to wall time.
243 * 4 Also print the number of triangles as they are being rastered. This
244 * uses ANSI escape codes which may not be supported on all terminals.
245 * It also causes a lot to be printed, so it can actually decrease render
246 * performance, especially on a slow (or remote) terminal.
247 * The default setting for this option is 3.
248 */
249 #ifndef VERBOSITY
250 #define VERBOSITY 3
251 #endif
252 #if VERBOSITY >= 2
253 #define IF_RASTER_STATS(X) X
254 #else
255 #define IF_RASTER_STATS(X)
256 #endif
257 #if VERBOSITY >= 3
258 #define IF_RENDER_TIMER(X) X
259 #else
260 #define IF_RENDER_TIMER(X)
261 #endif
262 #if VERBOSITY >= 4
263 #define IF_RENDER_PROGRESS(X) X
264 #else
265 #define IF_RENDER_PROGRESS(X)
266 #endif
267
268 #endif // _CONFIG_H_
269
This page took 0.039912 seconds and 4 git commands to generate.