home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / source / rayce27s / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-02  |  3.6 KB  |  160 lines

  1. /*
  2.  * main.c -- main() and its belongings.
  3.  * 
  4.  * (c) 1993, 1994 by Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>
  5.  * 
  6.  * based on work originally by George Kyriazis, 1988.
  7.  * 
  8.  * This program is free software; you can redistribute it and/or modify it
  9.  * under the terms of the GNU General Public License as published by the
  10.  * Free Software Foundation;
  11.  * 
  12.  * This program is distributed in the hope that it will be useful, but
  13.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU General Public License along
  18.  * with this program; if not, write to the Free Software Foundation, Inc.,
  19.  * 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  * 
  21.  */
  22.  
  23. #include    <stdio.h>
  24. #include     <stdlib.h>
  25.  
  26. #include    "ray.h"
  27. #include    "proto.h"
  28. #include     "extern.h"
  29.  
  30. /* proto */
  31. PRIVATE void    usage(void);
  32. PRIVATE void    notice(void);
  33.  
  34.  
  35.  
  36. int
  37. main(int argc, char *argv[])
  38. {
  39.     char            infn[100] = "input.r",
  40.                     outfn[100] = "output.tga";
  41.  
  42.     char            c;
  43.  
  44.     /* print the (c) stuff */
  45.     notice();
  46.  
  47.     /* no commandline options? */
  48.     if (argc == 1)
  49.     usage();
  50.  
  51.     /* set some global vars */
  52.     set_defaults();
  53.     initialize();
  54.  
  55.     /* scan commandline */
  56.     while (--argc && ((c = **(++argv)) == '-' || c == '+')) {
  57.     c = *++(argv[0]);
  58.     switch (c) {
  59.     case 'c':        /* continue a previously interrupted
  60.                  * picture */
  61.         continue_flag = TRUE;
  62.         break;
  63.     case 'd':        /* turn on debugging */
  64.         if (sscanf(++argv[0], "%ld", &debug_options) != 1)
  65.         debug_options = ~0;
  66.         break;
  67.     case 'i':        /* inputfile */
  68.         if (sscanf(++argv[0], "%s", infn) != 1)
  69.         usage();
  70.  
  71.         break;
  72.  
  73.     case 's':
  74.         silent_mode = TRUE;
  75.         break;
  76.     case 'o':        /* output file */
  77.         if (sscanf(++argv[0], "%s", outfn) != 1)
  78.         usage();
  79.         break;
  80.     case 'h':        /* horizontal resolution */
  81.         if (sscanf(++argv[0], "%d", &yres) != 1)
  82.         usage();
  83.         break;
  84.     case 'w':        /* vertical resolution */
  85.         if (sscanf(++argv[0], "%d", &xres) != 1)
  86.         usage();
  87.         break;
  88.     case 'x':        /* disable keypress-exit */
  89.         keyboard_exit = 0;
  90.         break;
  91.     case 't':        /* for testing 'n debugging */
  92.         test_flag = TRUE;
  93.         break;
  94.     case 'I':        /* number of frames, "iterations" */
  95.         if (sscanf(++argv[0], "%d", &iter_override) != 1)
  96.         usage();
  97.         tries = iter_override;
  98.         break;
  99.     default:
  100.         usage();
  101.         break;
  102.     }
  103.     }
  104.  
  105.  
  106.     /* initialize any machine dependent stuff */
  107.     init_machine();
  108.  
  109.     /* parse the input */
  110.     readfile(infn);
  111.     start_stats();
  112.  
  113.     /* and do the tracing */
  114.     raytrace(outfn);
  115.  
  116.     exit(0);
  117. }
  118.  
  119.  
  120. PRIVATE void
  121. usage(void)
  122. {
  123.     printf(
  124.           "Rayce <options>\n"
  125.           "-I#        number of frames\n"
  126.           "-i<file>   input\n"
  127.           "-o<file>   output\n"
  128.           "-h#        height\n"
  129.           "-w#        width\n"
  130.           "-x         disable exit\n"
  131.           "-c         continue trace\n"
  132.           "-d#        debugging\n"
  133.           "  1 = tokenizer, 2 = parser, 4 = runtime warnings, 8 = print_interior()\n"
  134.           "\n"
  135.           "  Rayce was compiled with DEBUG %sdefined\n",
  136.  
  137. #ifdef DEBUG
  138.           ""
  139. #else
  140.           "not "
  141. #endif
  142.  
  143.     );
  144.     exit(0);
  145. }
  146.  
  147. PRIVATE void
  148. notice(void)
  149. {
  150.     printf("This is Rayce version 2.7\n"
  151.     "Rayce is (c) 1993, 1994 Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>\n"
  152.        "  It is based on \"Ray\" by George Kyriazis <kyriazis@turing.cs.rpi.edu>\n"
  153.        "  Rayce is released under the terms of the GNU General Public License,\n"
  154.        "  it has no warranty what so ever. For more details: see the file \"COPYING\"\n"
  155.        "\n"
  156.        "Enjoy!\n\n");
  157.  
  158.     return;
  159. }
  160.