home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / macraysh.sit / Code / Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-18  |  3.1 KB  |  136 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 <console.h>
  27.  
  28. #include "rayshade.h"
  29. #include "options.h"
  30. #include "stats.h"
  31. #include "viewing.h"
  32. #include "picture.h"
  33.  
  34. int main()
  35. {
  36.     /* Stick the dummy procedure in whatever module you wish to set breakpoints in */
  37.     dummy() ;
  38.     
  39.     console_options.title = "\pRayshade Report Window";
  40.     console_options.left = 0;
  41.     console_options.top = 360;
  42.     console_options.nrows = 10;
  43.     console_options.ncols = 105;
  44.  
  45.     MacInitialize() ;
  46.  
  47.     printf("Welcome to Rayshade-M !\n");
  48.     printf("Ray Tracing code by Craig Kolb\n");
  49.     printf("Macintosh conversion and Object Editor by Adam Lock\n\n");
  50.     printf("To open a new scene, select New from the menu\n");
  51.  
  52.     RSSetup() ; /* Set up default rendering options */
  53.  
  54.     for (;;) HandleEvent();
  55.  
  56.     return 0;
  57. }
  58.  
  59. void StartRendering()
  60. {
  61.     int argc;
  62.     char **argv;
  63.     Float utime, stime, lasttime;
  64.     int i, start_frame, end_frame;
  65.     extern Geom *World;
  66.     extern char GetFrameRange(int *start, int *end) ;
  67.     char anim = 0 ;
  68.  
  69.     RSInitialize();
  70.     if(Options.totalframes > 1) {
  71.         if(!GetFrameRange(&start_frame,&end_frame)) {
  72.             RLerror(RL_WARN,"Rendering cancelled",0,0,0) ;
  73.             return ;
  74.         }
  75.         else
  76.             anim = 1 ;
  77.     }
  78.     else {
  79.         start_frame = Options.startframe ;
  80.         end_frame = Options.endframe ;
  81.     }
  82.     /*
  83.      * Start the first frame.
  84.      */
  85.     RSStartFrame(start_frame);
  86.     /*
  87.       * Print more information than we'll ever need to know...
  88.      */
  89.     if (Options.verbose) {
  90.         /* World object info. */
  91.         AggregatePrintInfo(World);
  92.         /* Print info about rendering options and the like. */
  93.         RSOptionsList();
  94.     }
  95.     /*
  96.      * Start new picture.
  97.      */
  98.     PictureStart(argv);
  99.     /*
  100.      * Print preprocessing time.
  101.      */
  102.     RSGetCpuTime(&utime, &stime);
  103.     printf("Preprocessing time:\t");
  104.     printf("%2.2fu  %2.2fs\n", utime, stime);
  105.     printf("Starting trace.\n");
  106.  
  107.     lasttime = utime+stime;
  108.     /*
  109.      * Render the first frame
  110.      */
  111.     raytrace(argc, argv);
  112.     /*
  113.      * Render the remaining frames.
  114.      */
  115.     for (i = start_frame +1; i <= end_frame ; i++) {
  116.         if(anim) write_frame_picture(i) ;
  117.         PictureFrameEnd();    /* End the previous frame */
  118.         RSGetCpuTime(&utime, &stime);
  119.         printf("Total CPU time for frame %d: %2.2f \n", i - 1, utime+stime - lasttime);
  120.         PrintMemoryStats();
  121.         lasttime = utime+stime;
  122.         RSStartFrame(i);
  123.         if (Options.verbose)
  124.             AggregatePrintInfo(World);
  125.         PictureStart(argv);
  126.         raytrace(argc, argv);
  127.     }
  128.     /*
  129.      * Close the image file.
  130.      */
  131.     if(anim) write_frame_picture(i) ;
  132.     PictureFrameEnd();    /* End the last frame */
  133.     PictureEnd();
  134.     StatsPrint();
  135. }
  136.