1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
Description: format usages and helps
Attempt to format and harmonize helps of the demonstration programs
wrt UN*X customs in view to employ help2man to generate manpages.
Origin: vendor, Debian
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2014-10-21
--- a/demosrc/getargs.c
+++ b/demosrc/getargs.c
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <libgen.h>
#include "tachyon.h"
#include "getargs.h"
#include "ctype.h"
@@ -29,34 +30,36 @@
}
static void printusage(char **argv) {
- printf("Usage: \n");
- printf(" %s modelfile [options] \n", argv[0]);
+ char *argv0=strdup(argv[0]);
+ char *progname=basename(argv0);
+ printf("Usage: %s modelfile [options] \n", progname);
+ printf("\n");
+ printf("Valid options and accepted formats are as follows (** denotes default behaviour).\n");
printf("\n");
printf("Model file formats supported:\n");
- printf(" filename.dat -- The model files originated with this package.\n");
- printf(" filaname.ac -- AC3D model files.\n");
+ printf(" filename.dat the model files originated with this package\n");
+ printf(" filaname.ac AC3D model files\n");
#ifdef USELIBMGF
- printf(" filaname.mgf -- MGF model files.\n");
+ printf(" filaname.mgf MGF model files.\n");
#endif
- printf(" filename.nff -- The NFF scene format used by Eric Haines' SPD.\n");
+ printf(" filename.nff the NFF scene format used by Eric Haines' SPD\n");
+ printf("\n");
printf("\n");
- printf("Valid options: (** denotes default behaviour)\n");
- printf("----------------------------------------------\n");
printf("Message Options:\n");
- printf(" +V verbose messages on \n");
- printf(" -V verbose messages off **\n");
+ printf(" +V verbose messages on \n");
+ printf(" -V verbose messages off **\n");
printf("\n");
printf("Speed Tuning Options:\n");
- printf(" -raydepth xxx (maximum ray recursion depth\n");
- printf(" -numthreads xxx (** default is auto-determined)\n");
+ printf(" -raydepth xxx maximum ray recursion depth\n");
+ printf(" -numthreads xxx (** default is auto-determined)\n");
printf(" -nobounding\n");
- printf(" -boundthresh xxx (** default threshold is 16)\n");
+ printf(" -boundthresh xxx (** default threshold is 16)\n");
printf("\n");
printf("Shading Options:\n");
- printf(" -fullshade best quality rendering (and slowest) **\n");
- printf(" -mediumshade good quality rendering, but no shadows\n");
- printf(" -lowshade low quality rendering, preview (and fast)\n");
- printf(" -lowestshade worst quality rendering, preview (and fastest)\n");
+ printf(" -fullshade best quality rendering (and slowest) **\n");
+ printf(" -mediumshade good quality rendering, but no shadows\n");
+ printf(" -lowshade low quality rendering, preview (and fast)\n");
+ printf(" -lowestshade worst quality rendering, preview (and fastest)\n");
printf("\n");
printf("Lighting Options:\n");
printf(" -rescale_lights xxx rescale light intensity values by\n");
@@ -64,73 +67,79 @@
printf(" lighting overrides take effect)\n");
printf(" -auto_skylight xxx force use of ambient occlusion lighting,\n");
printf(" auto-rescaling direct light sources to \n");
- printf(" compensate for ambient occlusion factor.\n");
+ printf(" compensate for ambient occlusion factor\n");
printf(" (use value 0.7 as a good starting point)\n");
printf(" -add_skylight xxx force use of ambient occlusion lighting,\n");
printf(" manually-rescaling direct light sources to\n");
- printf(" compensate for ambient occlusion factor.\n");
- printf(" -skylight_samples xxx number of sample rays to shoot.\n");
+ printf(" compensate for ambient occlusion factor\n");
+ printf(" -skylight_samples xxx number of sample rays to shoot\n");
printf("\n");
printf("Specular Highlight Shading Options:\n");
- printf(" -shade_phong Phong specular highlights\n");
- printf(" -shade_blinn Blinn's specular highlights**\n");
- printf(" -shade_blinn_fast fast approximation to Blinn's highlights\n");
- printf(" -shade_nullphong disable specular highlights\n");
+ printf(" -shade_phong Phong specular highlights\n");
+ printf(" -shade_blinn Blinn's specular highlights **\n");
+ printf(" -shade_blinn_fast fast approximation to Blinn's highlights\n");
+ printf(" -shade_nullphong disable specular highlights\n");
printf("\n");
printf("Transparency Shading Options:\n");
- printf(" -trans_max_surfaces xxx Limit the number of transparent\n");
+ printf(" -trans_max_surfaces xxx limit the number of transparent\n");
printf(" surfaces shown to the number specified\n");
- printf(" -trans_orig Original implementation**\n");
- printf(" -trans_raster3d Raster3D angle-based opacity modulation\n");
- printf(" -trans_vmd Opacity post-multiply used by VMD\n");
+ printf(" -trans_orig original implementation **\n");
+ printf(" -trans_raster3d Raster3D angle-based opacity modulation\n");
+ printf(" -trans_vmd opacity post-multiply used by VMD\n");
printf("\n");
printf("Transparent Surface Shadowing Options:\n");
- printf(" -shadow_filter_on Transparent objects cast shadows**\n");
- printf(" -shadow_filter_off Transparent objects do not cast shadows\n");
+ printf(" -shadow_filter_on transparent objects cast shadows **\n");
+ printf(" -shadow_filter_off transparent objects do not cast shadows\n");
printf("\n");
printf("Fog Shading Options:\n");
- printf(" -fog_radial Radial fog implementation**\n");
- printf(" -fog_vmd Planar OpenGL-like fog used by VMD\n");
+ printf(" -fog_radial radial fog implementation **\n");
+ printf(" -fog_vmd planar OpenGL-like fog used by VMD\n");
printf("\n");
printf("Surface Normal/Winding Order Fixup Mode:\n");
- printf(" -normalfixup [off | flip | guess] (**off is default)\n");
+ printf(" -normalfixup [off|flip|guess] (** off is default)\n");
printf("\n");
printf("Antialiasing Options:\n");
- printf(" -aasamples xxx (maximum supersamples taken per pixel)\n");
- printf(" (** default is 0, or scene file determined)\n");
+ printf(" -aasamples xxx maximum supersamples taken per pixel\n");
+ printf(" (** default is 0, or scene file determined)\n");
printf("\n");
printf("Output Options:\n");
- printf(" -res Xres Yres override scene-defined output image size\n");
- printf(" -o outfile.tga set output file name\n");
- printf(" -clamp clamp pixel values to [0 to 1) (** default)\n");
- printf(" -normalize normalize pixel values to [0 to 1)\n");
- printf(" -gamma val normalize apply gamma correction\n");
- printf(" -format BMP 24-bit Windows BMP (uncompressed)\n");
+ printf(" -res Xres Yres override scene-defined output image size\n");
+ printf(" -o outfile.tga set output file name\n");
+ printf(" -clamp clamp pixel values to [0 to 1) **\n");
+ printf(" -normalize normalize pixel values to [0 to 1)\n");
+ printf(" -gamma val normalize apply gamma correction\n");
+ printf(" -format BMP 24-bit Windows BMP (uncompressed)\n");
#if defined(USEJPEG)
- printf(" -format JPEG 24-bit JPEG (compressed, but lossy)\n");
+ printf(" -format JPEG 24-bit JPEG (compressed, but lossy)\n");
#else
- printf(" -format JPEG XXX Not compiled into this binary XXX\n");
+ printf(" -format JPEG XXX Not compiled into this binary XXX\n");
#endif
#if defined(USEPNG)
- printf(" -format PNG 24-bit PNG (compressed, lossless)\n");
+ printf(" -format PNG 24-bit PNG (compressed, lossless)\n");
#else
- printf(" -format PNG XXX Not compiled into this binary XXX\n");
+ printf(" -format PNG XXX Not compiled into this binary XXX\n");
#endif
- printf(" -format PPM 24-bit PPM (uncompressed)\n");
- printf(" -format PPM48 48-bit PPM (uncompressed)\n");
- printf(" -format PSD48 48-bit PSD (uncompressed)\n");
- printf(" -format RGB 24-bit SGI RGB (uncompressed)\n");
- printf(" -format TARGA 24-bit Targa (uncompressed) **\n");
+ printf(" -format PPM 24-bit PPM (uncompressed)\n");
+ printf(" -format PPM48 48-bit PPM (uncompressed)\n");
+ printf(" -format PSD48 48-bit PSD (uncompressed)\n");
+ printf(" -format RGB 24-bit SGI RGB (uncompressed)\n");
+ printf(" -format TARGA 24-bit Targa (uncompressed) **\n");
printf("\n");
printf("Animation Related Options:\n");
- printf(" -camfile filename.cam Animate using file of camera positions.\n");
- printf(" -nosave Disable writing of output frames to disk\n");
- printf(" (only used for doing real-time rendering)\n");
+ printf(" -camfile filename.cam animate using file of camera positions\n");
+ printf(" -nosave disable writing of output frames to disk\n");
+ printf(" (only used for doing real-time rendering)\n");
printf("\n");
printf("Interactive Spaceball/SpaceNavigator Control:\n");
- printf(" -spaceball Enable Spaceball/SpaceNavigator camera flight\n");
+ printf(" -spaceball enable Spaceball/SpaceNavigator camera flight\n");
printf(" -spaceballport serialportdevicename (only for serial devices)\n");
printf("\n");
+ printf("Getting Help:\n");
+ printf(" -help display help message and exit\n");
+ printf(" -version display version string and exit\n");
+ printf(" -banner display banner and exit\n");
+ printf("\n");
+ free(argv0);
}
static void initoptions(argoptions * opt) {
@@ -564,6 +573,17 @@
return 2;
}
+ /* getting help */
+ if (!strcmp(argv[num], "-help")) {
+ return -2;
+ }
+ if (!strcmp(argv[num], "-version")) {
+ return -3;
+ }
+ if (!strcmp(argv[num], "-banner")) {
+ return -4;
+ }
+
/* unknown parameter setting */
if (node == 0)
printf("Unrecognized parameter/option flag: %s\n", argv[num]);
@@ -590,11 +610,23 @@
while (i < argc) {
if (argv[i][0] == '-' || argv[i][0] == '+') {
rc = getparm(argc, argv, i, opt, node);
- if (rc != -1) {
+ if (0 < rc) {
i += rc;
} else {
- if (node == 0)
- printusage(argv);
+ if (node == 0) {
+ if (rc == -2)
+ printusage(argv);
+ else if (rc == -3)
+ printf(TACHYON_VERSION_STRING"\n");
+ else if (rc == -4)
+ printf(
+ "Tachyon Parallel/Multiprocessor Ray Tracer Version "TACHYON_VERSION_STRING"\n"
+ "Copyright 1994-2013, John E. Stone <john.stone@gmail.com>\n"
+ "------------------------------------------------------------\n"
+ );
+ else
+ printusage(argv);
+ }
return -1;
}
--- a/demosrc/main.c
+++ b/demosrc/main.c
@@ -602,6 +602,15 @@
rt_set_ui_message(my_ui_message);
rt_set_ui_progress(my_ui_progress);
+ if ((rc = getargs(argc, argv, &opt, node)) != 0) {
+ rt_finalize();
+#if defined(ANDROID)
+ return rc;
+#else
+ exit(rc);
+#endif
+ }
+
if (node == 0) {
char strbuf[1024];
sprintf(strbuf, "Tachyon Parallel/Multiprocessor Ray Tracer Version %s ",
@@ -613,15 +622,6 @@
my_ui_message(0, strbuf);
}
- if ((rc = getargs(argc, argv, &opt, node)) != 0) {
- rt_finalize();
-#if defined(ANDROID)
- return rc;
-#else
- exit(rc);
-#endif
- }
-
if (opt.numfiles > 1) {
if (node == 0)
printf("Rendering %d scene files.\n", opt.numfiles);
|