]> Dogcows Code - chaz/rasterize/blobdiff - config.h
add scene lighting constructs; real stdin support
[chaz/rasterize] / config.h
diff --git a/config.h b/config.h
new file mode 100644 (file)
index 0000000..9637dea
--- /dev/null
+++ b/config.h
@@ -0,0 +1,194 @@
+
+/*
+ * CS5600 University of Utah
+ * Charles McGarvey
+ * mcgarvey@eng.utah.edu
+ */
+
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+/*
+ * BACKFACE_CULLING
+ * If enabled, triangles that are facing away from the viewer, according to
+ * the right-hand rule and counter-clockwise winding of the verticies, will
+ * not be drawn.  This option can improve performance in some situations, but
+ * it may also cause visual problems for models that aren't entirely closed.
+ */
+#if BACKFACE_CULLING
+#define IF_BACKFACE_CULLING(X) X
+#else
+#define IF_BACKFACE_CULLING(X)
+#endif
+
+/*
+ * CLIPPING
+ * If enabled, triangles will be not be drawn if they are entirely outside of
+ * the viewing volume.  The number of pixels tested while rasterizing a
+ * triangle can also be minimized, which leads to a huge performance boost.
+ * For that reason, this is on unless explicitly disabled, and you really
+ * always want to leave it enabled.  Note that this does not have anything to
+ * do with viewport clipping, which is always performed.  Also note that any
+ * triangle which is partially within the viewing volume will be entirely
+ * drawn, which may be somewhat unexpected.
+ */
+#ifndef CLIPPING
+#define CLIPPING 1
+#endif
+#if CLIPPING
+#define IF_CLIPPING(X) X
+#else
+#define IF_CLIPPING(X)
+#endif
+
+/*
+ * DEPTH_TEST
+ * If enabled, a z-buffer will be used to perform some sort of depth testing,
+ * resulting in the generally desirable situation where triangles that are
+ * further away will not appear in front of triangles that are closer.  There
+ * is a performance penalty for this, so it must be enabled.
+ */
+#if DEPTH_TEST
+#define IF_DEPTH_TEST(X) X
+#else
+#define IF_DEPTH_TEST(X)
+#endif
+
+/*
+ * EXPORT_BMP
+ * If enabled, each scene rasterization will be saved as a BMP image file.
+ * This is on unless explicitly disabled.
+ */
+#ifndef EXPORT_BMP
+#define EXPORT_BMP 1
+#endif
+#if EXPORT_BMP
+#define IF_EXPORT_BMP(X) X
+#else
+#define IF_EXPORT_BMP(X)
+#endif
+
+/*
+ * EXPORT_PPM
+ * If enabled, each scene rasterization will be saved as a PPM image file.
+ * This is on unless explicitly disabled.
+ */
+#ifndef EXPORT_PPM
+#define EXPORT_PPM 1
+#endif
+#if EXPORT_PPM
+#define IF_EXPORT_PPM(X) X
+#else
+#define IF_EXPORT_PPM(X)
+#endif
+
+/*
+ * EXTRA_INLINE
+ * If enabled, functions that are defined in interface files will be marked as
+ * inline.  The compiler will generally inline functions according to its own
+ * optimization heuristics, and this inline marking may persuade the compiler
+ * to inline a function that it otherwise would not.  This option may bring a
+ * small performance boost, but it can also increase the size of the program
+ * executable.
+ */
+#if EXTRA_INLINE
+#define IF_EXTRA_INLINE(X) X
+#else
+#define IF_EXTRA_INLINE(X)
+#endif
+
+/*
+ * LIGHTING
+ * If enabled, local lighting will be used to increase realism of the scene.
+ * This option has a performance cost, but it can produce interesting visuals.
+ * The behavior of this option also depends on the SMOOTH_COLOR option and
+ * whether or not the model has unique vertex normals; if SMOOTH_COLOR is
+ * disabled, each triangle will be shaded a flat color.  If it is enabled,
+ * Gouraud interpolation is used to smooth the lighting across the face of
+ * each triangle.  See the PRE_NORMALS and SMOOTH_COLOR options.
+ */
+#if LIGHTING
+#define IF_LIGHTING(X) X
+#else
+#define IF_LIGHTING(X)
+#endif
+
+/*
+ * NDEBUG
+ * If enabled, assertions and other nonessential checks will not be compiled
+ * into the programs.
+ */
+#if NDEBUG
+#define IF_NDEBUG(X) X
+#else
+#define IF_NDEBUG(X)
+#endif
+
+/*
+ * PRE_NORMALS
+ * If enabled, normals are pre-computed while the triangles are loading.
+ * Otherwise, the normals are computed during rasterization.  The behavior of
+ * this option is effected by its precise value:
+ *   1 Normals are computed per-face, according to the right-hand rule and
+ *     counter-clockwise winding of the verticies.
+ *   2 Normals are computed per-vertex; the normal for a vertex that is shared
+ *     between two or more faces will be the average of the normals of the
+ *     faces.  There is a performance penalty for this setting.
+ *   3 Same as 2, but the normals will be cached so that they will not need to
+ *     be computed the next time the mesh is loaded.
+ */
+#if PRE_NORMALS
+#define IF_PRE_NORMALS(X) X
+#else
+#define IF_PRE_NORMALS(X)
+#endif
+
+/*
+ * SMOOTH_COLOR
+ * If enabled, color will be interpolated across the face of a triangle.
+ * Otherwise, the color will flat, and the average color of the colors
+ * associated with each vertex will be used.
+ */
+#if SMOOTH_COLOR
+#define IF_SMOOTH_COLOR(X) X
+#else
+#define IF_SMOOTH_COLOR(X)
+#endif
+
+/*
+ * VERBOSITY
+ * If enabled, a description of what is happening will be printed to stdout.
+ * Otherwise, nothing is printed.  The behavior of this option is effected by
+ * its precise value:
+ *   1 Print just a few very general descriptions.
+ *   2 After rasterization, also print the triangle count and other
+ *     information that may be interesting.
+ *   3 Also print the number of seconds it took to render the entire scene,
+ *     according to wall time.
+ *   4 Also print the number of triangles as they are being rastered.  This
+ *     uses ANSI escape codes which may not be supported on all terminals.
+ *     It also causes a lot to be printed, so it can actually decrease render
+ *     performance, especially on a slow (or remote) terminal.
+ * The default setting for this option is 3.
+ */
+#ifndef VERBOSITY
+#define VERBOSITY 3
+#endif
+#if VERBOSITY >= 2
+#define IF_RASTER_STATS(X) X
+#else
+#define IF_RASTER_STATS(X)
+#endif
+#if VERBOSITY >= 3
+#define IF_RENDER_TIMER(X) X
+#else
+#define IF_RENDER_TIMER(X)
+#endif
+#if VERBOSITY >= 4
+#define IF_RENDER_PROGRESS(X) X
+#else
+#define IF_RENDER_PROGRESS(X)
+#endif
+
+#endif // _CONFIG_H_
+
This page took 0.022134 seconds and 4 git commands to generate.