home *** CD-ROM | disk | FTP | other *** search
- /*
- * main.c
- *
- * Copyright (C) 1989, 1991, Craig E. Kolb
- * All rights reserved.
- *
- * This software may be freely copied, modified, and redistributed
- * provided that this copyright notice is preserved on all copies.
- *
- * You may not distribute this software, in whole or in part, as part of
- * any commercial product without the express consent of the authors.
- *
- * There is no warranty or other guarantee of fitness of this software
- * for any purpose. It is provided solely "as is".
- *
- * $Id: main.c,v 4.0 91/07/17 14:50:39 kolb Exp Locker: kolb $
- *
- * $Log: main.c,v $
- * Revision 4.0 91/07/17 14:50:39 kolb
- * Initial version.
- *
- */
-
- char rcsid[] = "$Id: main.c,v 4.0 91/07/17 14:50:39 kolb Exp Locker: kolb $";
-
- #include <console.h>
-
- #include "rayshade.h"
- #include "options.h"
- #include "stats.h"
- #include "viewing.h"
- #include "picture.h"
-
- int main()
- {
- /* Stick the dummy procedure in whatever module you wish to set breakpoints in */
- dummy() ;
-
- console_options.title = "\pRayshade Report Window";
- console_options.left = 0;
- console_options.top = 360;
- console_options.nrows = 10;
- console_options.ncols = 105;
-
- MacInitialize() ;
-
- printf("Welcome to Rayshade-M !\n");
- printf("Ray Tracing code by Craig Kolb\n");
- printf("Macintosh conversion and Object Editor by Adam Lock\n\n");
- printf("To open a new scene, select New from the menu\n");
-
- RSSetup() ; /* Set up default rendering options */
-
- for (;;) HandleEvent();
-
- return 0;
- }
-
- void StartRendering()
- {
- int argc;
- char **argv;
- Float utime, stime, lasttime;
- int i, start_frame, end_frame;
- extern Geom *World;
- extern char GetFrameRange(int *start, int *end) ;
- char anim = 0 ;
-
- RSInitialize();
- if(Options.totalframes > 1) {
- if(!GetFrameRange(&start_frame,&end_frame)) {
- RLerror(RL_WARN,"Rendering cancelled",0,0,0) ;
- return ;
- }
- else
- anim = 1 ;
- }
- else {
- start_frame = Options.startframe ;
- end_frame = Options.endframe ;
- }
- /*
- * Start the first frame.
- */
- RSStartFrame(start_frame);
- /*
- * Print more information than we'll ever need to know...
- */
- if (Options.verbose) {
- /* World object info. */
- AggregatePrintInfo(World);
- /* Print info about rendering options and the like. */
- RSOptionsList();
- }
- /*
- * Start new picture.
- */
- PictureStart(argv);
- /*
- * Print preprocessing time.
- */
- RSGetCpuTime(&utime, &stime);
- printf("Preprocessing time:\t");
- printf("%2.2fu %2.2fs\n", utime, stime);
- printf("Starting trace.\n");
-
- lasttime = utime+stime;
- /*
- * Render the first frame
- */
- raytrace(argc, argv);
- /*
- * Render the remaining frames.
- */
- for (i = start_frame +1; i <= end_frame ; i++) {
- if(anim) write_frame_picture(i) ;
- PictureFrameEnd(); /* End the previous frame */
- RSGetCpuTime(&utime, &stime);
- printf("Total CPU time for frame %d: %2.2f \n", i - 1, utime+stime - lasttime);
- PrintMemoryStats();
- lasttime = utime+stime;
- RSStartFrame(i);
- if (Options.verbose)
- AggregatePrintInfo(World);
- PictureStart(argv);
- raytrace(argc, argv);
- }
- /*
- * Close the image file.
- */
- if(anim) write_frame_picture(i) ;
- PictureFrameEnd(); /* End the last frame */
- PictureEnd();
- StatsPrint();
- }
-