home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / simplerd.lha / simplerad / FinalFTP / WalkT / args.c next >
Encoding:
C/C++ Source or Header  |  1992-05-22  |  4.9 KB  |  163 lines

  1. /**********************************************************************/
  2. /*                                                                    */
  3. /* args.c : handle command line args                                  */
  4. /*                                                                    */
  5. /* Copyright (C) 1992, Bernard Kwok                                   */
  6. /* All rights reserved.                                               */
  7. /* Revision 1.0                                                       */
  8. /* May, 1992                                                          *
  9. /**********************************************************************/
  10. #include <stdio.h>
  11. #include <math.h>
  12. #include <ctype.h>
  13. #include <string.h>
  14. #include <gl/gl.h>
  15. #include <fmclient.h>
  16. #define IRIS4D 1
  17. #include "geo.h"
  18. #include "walk.h"
  19. #include "vcr.h"
  20.  
  21. extern char *meshfilename;
  22. #define shift argc--; argv++;
  23.  
  24. /**********************************************************************/
  25. static char StrUsage[] =              /* program usage                */
  26.   "[-dghBW] [-s #] [[-w x y x y] -p patch-file";
  27.  
  28. /**********************************************************************/
  29. /* Syntax                                                             */
  30. /**********************************************************************/
  31. static void Usage()
  32. {
  33.   fprintf(stderr,"usage: %s %s\n", ProgName, StrUsage);
  34. }
  35.  
  36. /**********************************************************************/
  37. /* Help                                                               */
  38. /**********************************************************************/
  39. static void LongUsage()
  40. {
  41.   fprintf(stderr,"\nWhere:\n");
  42.   fprintf(stderr,"\td : debug mode\n");
  43.   fprintf(stderr,"\tg : gamma correction\n");
  44.   fprintf(stderr,"\tp : set patch file to use\n");
  45.   fprintf(stderr,"\th : this message\n");
  46.   fprintf(stderr,"\tw x y x y : window origin(x,y) and size(x,y)\n");
  47.   fprintf(stderr,"\tn : Set to NTSC mode\n");
  48.   fprintf(stderr,"\ts : RGB scale factor\n");
  49.   fprintf(stderr,"\tv : Record to VCR in NTSC mode\n");
  50.   fprintf(stderr,"\tB : Black and white mesh rendering\n");
  51.   fprintf(stderr,"\tW : Display on full screen\n");
  52. }
  53.  
  54. /**********************************************************************/
  55. /* Parse command line arguments                                       */
  56. /**********************************************************************/
  57. void ParseArgs(argc, argv)
  58.      int argc;
  59.      char **argv;
  60. {
  61.   float tmp;
  62.   int has_patchname = 0;
  63.  
  64.   if (argc < 2) {
  65.     Usage();
  66.     exit(1);
  67.   }
  68.  
  69.   shift;
  70.   while (argc && **argv == '-') {
  71.     switch(*++*argv) {
  72.  
  73.     case 'd':                     /* Run in debug mode */
  74.       fprintf(stderr,"In debug mode\n");
  75.       Option.debug = 1; 
  76.       break;
  77.  
  78.     case 'g':                     /* Gamma correction */
  79.       System.gamma = TRUE;
  80.       break;
  81.       
  82.     case 'h':                     /* Help */
  83.       Usage();
  84.       LongUsage();
  85.       exit(0);
  86.       break;
  87.  
  88.     case 'n':                     /* Set NTSC window size and placement */
  89.       System.VCRmode = NTSC;
  90.       System.UseVCR = TRUE;
  91.       fprintf(stderr,"Displaying NTSC mode\n");
  92.       break;
  93.       
  94.     case 'p':                    /* Patch file name */
  95.       shift;
  96.       if (!argc) {
  97.     fprintf(stderr,"Sorry, no patch file parameter given\n");
  98.     exit(1);
  99.       }
  100.       meshfilename = *argv;
  101.       has_patchname = 1;
  102.       break;
  103.  
  104.     case 's':                     /* RGB scaling factor */
  105.       shift;
  106.       if (!argc) {
  107.     fprintf(stderr,"No RGB colour scaling given\n");
  108.     exit(1);
  109.       }
  110.       tmp = atof(*argv);
  111.       Option.RGBscale = tmp;
  112.       fprintf(stderr,"Scaling by factor %g\n", Option.RGBscale);
  113.       break;
  114.  
  115.     case 'v':                    /* Run in NTSC mode */
  116.       fprintf(stderr,"Recording NTSC mode\n");
  117.       System.VCRmode = REC;
  118.       System.UseVCR = TRUE;
  119.       Option.debug = 0;
  120.       break;
  121.  
  122.     case 'w': /* provide x1,y1,x2,y2  and xsize, ysize */
  123.       shift;
  124.       if (argc < 4) {
  125.     fprintf(stderr,"Not enough args for w\n");
  126.         exit(1);
  127.       }
  128.       WindXorigin = atoi(*argv); shift;
  129.       WindYorigin = atoi(*argv); shift;
  130.       WindXsize = atoi(*argv); shift;
  131.       WindYsize = atoi(*argv); ;
  132.       System.UsePrefpos = 1;
  133.       System.UsePrefsize = 1;
  134.       fprintf(stderr,"Window parms are: Origin: %d,%d Size: %d,%d\n",
  135.          WindXorigin, WindYorigin, WindXsize, WindYsize);
  136.       break;
  137.  
  138.     case 'B':                    /* Black & white mesh rendering */
  139.       Option.shadeBW = TRUE;
  140.       break;
  141.  
  142.     case 'F':                    /* Display on full screen */
  143.       System.FullScreen = 1;
  144.       break;
  145.  
  146.     case 'P':           /* Directory containing patch files (not used) */
  147.       Option.data_dir = ".";
  148.       fprintf(stderr,"Set patch directory to current. Not done yet.\n");
  149.       break;
  150.  
  151.     default:
  152.       Usage();
  153.       exit(-1);
  154.     }
  155.     shift;
  156.   }
  157.  
  158.   if (has_patchname == 0) {
  159.     fprintf(stderr, "Sorry, no patch file parameter given\n");
  160.     exit(0);
  161.   }
  162. }
  163.