home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / msdos / raytrace / rayshade / src / main.c < prev    next >
C/C++ Source or Header  |  1992-04-29  |  3KB  |  119 lines

  1. /*
  2.  * main.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * $Id: main.c,v 4.0 91/07/17 14:50:39 kolb Exp Locker: kolb $
  17.  *
  18.  * $Log:    main.c,v $
  19.  * Revision 4.0  91/07/17  14:50:39  kolb
  20.  * Initial version.
  21.  * 
  22.  */
  23.  
  24. char rcsid[] = "$Id: main.c,v 4.0 91/07/17 14:50:39 kolb Exp Locker: kolb $";
  25.  
  26. #include "rayshade.h"
  27. #include "options.h"
  28. #include "stats.h"
  29. #include "viewing.h"
  30. #include "picture.h"
  31.  
  32. #if defined(__BORLANDC__) || defined(__WATCOMC__)
  33. #include <time.h>
  34. time_t    starttime;
  35. #endif
  36.  
  37. int
  38. #ifdef LINDA
  39. rayshade_main(argc, argv)
  40. #else
  41. main(argc, argv)
  42. #endif
  43. int argc;
  44. char **argv;
  45. {
  46.     Float utime, stime, lasttime;
  47.     int i;
  48.     extern Geom *World;
  49.  
  50. #ifdef LINDA
  51.     Options.workernum = 0;    /* we're the supervisor */
  52. #endif
  53.  
  54.     RSInitialize(argc, argv);
  55.  
  56.  
  57.     /*
  58.      * Start the first frame.
  59.      */
  60.     RSStartFrame(Options.startframe);
  61.     /*
  62.       * Print more information than we'll ever need to know...
  63.      */
  64.     if (Options.verbose) {
  65.         /* World object info. */
  66.         AggregatePrintInfo(World, Stats.fstats);
  67.         /* Print info about rendering options and the like. */
  68.         RSOptionsList();
  69.     }
  70.     /*
  71.      * Start new picture.
  72.      */
  73.     PictureStart(argv);
  74.     /*
  75.      * Print preprocessing time.
  76.      */
  77.  
  78. #if defined(__BORLANDC__) || defined(__WATCOMC__)
  79.     starttime=time(&starttime);
  80. #endif
  81.  
  82.     RSGetCpuTime(&utime, &stime);
  83.     fprintf(Stats.fstats,"Preprocessing time:\t");
  84.     fprintf(Stats.fstats,"%2.2fu  %2.2fs\n", utime, stime);
  85.     fprintf(Stats.fstats,"Starting trace.\n");
  86.     (void)fflush(Stats.fstats);
  87.     lasttime = utime+stime;
  88.     /*
  89.      * Render the first frame
  90.      */
  91.     raytrace(argc, argv);
  92.     /*
  93.      * Render the remaining frames.
  94.      */
  95.     for (i = Options.startframe+1; i <= Options.endframe ; i++) {
  96.         PictureFrameEnd();    /* End the previous frame */
  97.         RSGetCpuTime(&utime, &stime);
  98.         fprintf(Stats.fstats, "Total CPU time for frame %d: %2.2f \n",
  99.             i - 1, utime+stime - lasttime);
  100.         PrintMemoryStats(Stats.fstats);
  101.         (void)fflush(Stats.fstats);
  102.         lasttime = utime+stime;
  103.         RSStartFrame(i);
  104.         if (Options.verbose) {
  105.             AggregatePrintInfo(World, Stats.fstats);
  106.             (void)fflush(Stats.fstats);
  107.         }
  108.         PictureStart(argv);
  109.         raytrace(argc, argv);
  110.     }
  111.     /*
  112.      * Close the image file.
  113.      */
  114.     PictureFrameEnd();    /* End the last frame */
  115.     PictureEnd();
  116.     StatsPrint();
  117.     return 0;
  118. }
  119.