+/*
+ * Render a scene that is read from standard input, and export to BMP.
+ */
+static void draw_from_stdin(const char* filename)
+{
+ scene_t* scene;
+ TRY_DO("Loading from stdin", load_from_stdin(&scene));
+
+ raster_t* raster = scene_render(scene);
+ scene_destroy(scene);
+ raster_printstats(raster);
+
+ TRY_DO("Exporting to %s", raster_export_bmp(raster, filename), filename);
+
+ raster_destroy(raster);
+}
+
+/*
+ * Render one or more scenes from 3D scene files.
+ */
+int main(int argc, char* argv[])
+{
+ int out = 0;
+ int c;
+ while ((c = getopt(argc, argv, "o:")) != -1) {
+ switch (c) {
+ case 'o':
+ ++out;
+ draw_from_stdin(optarg);
+ }
+ }
+
+ if (out == 0 && argc <= 1) {
+ draw("scene.u3d");
+ }
+ else {
+ for (int i = optind; i < argc; ++i) {
+ draw(argv[i]);
+ }
+ }
+
+#if !NDEBUG