================================================================
R E A D M E
================================================================
Advanced Graphics Programming in C & C++
Roger Stevens & Christopher Watkins
M&T Publishing
501 Galveston Drive
Redwood City, CA 94063
ISBN 1-55851-173-3
ABOUT THIS DISKETTE
This diskette contains four files, in addition to this README file.
These files are:
PART1 EXE 29561 6-19-91 6:51a
PART2 EXE 48078 6-19-91 6:28a
PART3 EXE 47946 6-19-91 6:29a
PART4 EXE 41893 6-25-91 8:03p
Each file is a self-extracting compressed archive file that contains
the source code and data files for each of the four parts of the book
"Advanced Graphics Programming in C", by Roger Stevens and
Christopher Watkins.
Because of limited storage space, no executable files are shipped
with this diskette. Rather, it is assumed you will compile the
source code to create your own EXE files, using the Turbo
C or Borland C++ language products from Borland International, Inc
(1800 Green Hills Road, Scotts Valley, CA 95067-0001 Tel: 408-438-8400).
USING THIS DISKETTE
It's best if you copy each of the above four files into its own
directory on your DOS drive. As always, save the original diskette in
a safe place in case your copies become lost or damaged. To
"explode" (uncompress) the archive files, simply go into the
directory you've created for that file (e.g. "PART1"), and then type
the name of the file. In less than a minute, you will have all
the source and data files for that section of the book in your
directory.
A GENERAL NOTE ABOUT ROBUSTNESS
The source code files in this diskette are for illustration purposes
only. As such, there is very little "bulletproofing" of the kind
found in commercial programs. For example, many programs do not
check if a particular data file is present before trying to open it.
As a consequence you will get a runtime error if you mistype a
filename. Also, in the case of abnormal program exit such as this,
the VGA display state may be left in a different mode from the one at
time of program start. You may need to reboot the machine to restore
the original VGA mode. If you encounter runtime errors, you can try
to determine the cause by using powerful Turbo Debugger that is
bundled with some Borland language products (and also available
separately).
FILES FOR PART I OF THE BOOK
To produce the files for Part I of the book, explode the
self-extracting archive file PART1.EXE by typing: PART1
This will produce the following files in your directory:
PART1 EXE 29561 6-19-91 6:51a
BIFURCAT C 1221 5-07-91 11:22p
GRAPH INC 10681 5-13-91 7:23a
LORENZ3D C 1770 5-28-91 6:00a
MATH INC 9354 5-13-91 7:28a
MSETJSET C 5195 6-15-91 3:58p
ORBIT2P C 2365 5-07-91 11:25p
ORBIT3P C 3501 5-07-91 11:25p
STRATR3D C 1612 5-07-91 11:27p
TRIANGLE C 1720 5-22-91 8:29p
Note that the PART1.EXE file remains in your directory.
Two of the files (GRAPH.INC and MATH.INC) are code files
that are included (by use of the preprocessor directive "#include")
within other source files.
To compile any of the above source code files, first make sure that
the Turbo C (or Borland C++) directory forms part of your current
path, and then type:
BCC TRIANGLE
to compile, say, the source code file TRIANGLE.C (in the case of
Borland C++). Consult your Borland or Turbo manual for more
information on running the compiler. After compilation, run the
resulting program TRIANGLE.EXE to produce the image of a recursive
triangle.
PART II: SOLID MODELING
To explode the files for part II of the book, run
the self-extracting program by typing: PART2
This will produce the following files in your directory:
PART2 EXE 48078 6-19-91 6:28a
ADDOBJS INC 9121 5-30-91 1:55a
CONEPYRM C 2456 5-30-91 6:20a
CUBE DAT 102 6-03-91 8:13p
CUBEPLAN SCN 337 6-03-91 8:51p
CYLINDER C 2796 5-30-91 6:21a
DESMAKE C 2367 5-30-91 1:46a
DISPOBJS INC 11931 5-30-91 5:15a
FOURCOLS SCN 970 2-04-90 2:13p
GRAPH INC 10800 5-30-91 1:56a
HMSPHERE C 3037 5-30-91 6:21a
MAKEOBJS C 2067 6-01-91 3:56a
MATH INC 9407 5-30-91 1:56a
MODEL C 13852 6-03-91 8:58p
MODEL DES 33 5-30-91 5:18a
MODEL INC 5331 5-30-91 1:56a
MOLECULE SCN 658 7-07-90 6:51p
PLOTEQN1 SCN 203 7-07-90 12:03p
PLOTEQN2 SCN 203 7-07-90 12:03p
PLOTEQN3 SCN 203 7-07-90 12:03p
PLOTEQN4 SCN 203 7-07-90 12:04p
PLOTEQNS C 3668 6-12-91 6:42p
PYRAMID SCN 514 5-30-91 5:32a
SCNMAKER C 5065 6-03-91 8:50p
SHAPES SCN 823 5-30-91 8:43a
SHPMK INC 2886 5-30-91 1:57a
SOLOFREV C 4443 6-12-91 6:53p
SOLOFREV SCN 868 6-20-90 11:36p
SPHERE C 2365 5-30-91 6:22a
SPHRPLAN SCN 311 10-14-90 5:21p
SPHRWALL SCN 514 2-04-90 2:14p
STAKTORS SCN 397 11-08-90 9:25p
TOROID C 2895 5-30-91 6:22a
WELL SCN 1897 7-10-90 12:34p
Note that the original file PART2.EXE remains in your directory.
Although you should consult the relevant sections of the book for
more information, the following will describe the steps necessary to
create one example from in the book, in this case the MOLECULE image.
1. First, create the file SPHERE.DAT by compiling SPHERE.C
and running the resulting program SPHERE.EXE. This will show an
image of a sphere on the screen and create a corresponding .DAT
file
2. Then, create the file CYLINDER.DAT by compiling CYLINDER.C
and running the resulting program CYLINDER.EXE. This will show an
image of a cylinder on the screen and create a corresponding .DAT
file.
3. Then, create the program MODEL.EXE by compiling MODEL.C (and
its associated include files). Run the program MODEL.EXE and
when it prompts you for a .SCN file name, type: MOLECULE
This will result in an image of a molecule displayed on the screen.
Follow a similar procedure for the other .SCN files. Some images
require the file GRID.DAT. This data file is produced by the program
PLOTEQNS.EXE (created by compiling PLOTEQNS.C).
Note that (as mentioned in the book text) PLOTEQNS.C is capable of
creating several different .DAT files, depending on which blocks of
code are enable. To enable the fragment of code that results in
GRID.DAT (which starts on line 33 and ends on line 44 of PLOTEQNS.C)
make sure that this section has no begin-comment marker in front of
it. (The begin-comment in C is "/*"). This is the default.
To enable creation of a different .DAT file by PLOTEQNS.EXE (say, the
file "PLOTEQN1.DAT"), disable the block of code from line 33 to 44,
and enable the code from line 45 to line 59 of the same file.
Then compile the program and run it to create PLOTEQN1.DAT.
PART 3: Z-BUFFER AND HORIZON RENDERING
To explode the files for part III of the book, run
the self-extracting program PART3.EXE by typing: PART3
This will produce the following files in your directory:
PART3 EXE 47946 6-19-91 6:29a
ADDONS INC 5050 6-02-91 1:50p
BOWL DES 55 5-06-91 9:32a
CPM C 2641 5-13-91 7:09a
CPM1 DES 46 6-02-91 1:40p
CPM2 DES 47 5-08-91 1:27a
CPMJ C 2879 5-07-91 11:07p
CPMJ1 DES 46 6-02-91 1:34p
CPMJ2 DES 45 5-08-91 1:29a
DESMAKE C 3489 6-02-91 1:50p
FINDLMTS C 1222 5-07-91 11:09p
GRAPH INC 10681 5-13-91 7:23a
HMSPHERE C 2342 5-07-91 11:10p
HMSPHERE DES 56 5-06-91 9:34a
HMTOROID C 3094 5-07-91 11:11p
HMTOROID DES 55 5-06-91 9:24a
MAGNFLDS C 1918 5-15-91 11:30a
MAGNFLDS DES 54 5-06-91 4:04a
MATH INC 9354 5-13-91 7:28a
MOUNTAIN C 3621 5-07-91 11:12p
MOUNTAIN DES 44 5-06-91 9:49a
PLASMA C 2796 5-15-91 11:31a
PLOTEQN C 2726 5-07-91 11:15p
PLOTEQN1 DES 43 5-06-91 5:16p
PLOTEQN2 DES 43 5-06-91 5:15p
PLOTEQN3 DES 43 5-06-91 5:15p
PLOTEQN4 DES 43 5-06-91 7:01a
QUATER C 5174 5-08-91 10:35p
QUATER INC 2065 5-13-91 7:19a
RENDER C 13717 6-17-91 9:53p
RENDER INC 3092 5-13-91 7:20a
REVSOL2 DES 44 6-03-91 9:49p
REVSOLID DES 44 6-03-91 9:49p
SMEAR C 1546 6-03-91 10:19p
SMOOTH C 1376 5-07-91 11:18p
TC000A SWP 131072 6-17-91 9:54p
VIEWSLIC C 1943 5-07-91 11:19p
Note that PART3.EXE also remains in the directory.
You should consult the book text for more information,
but, briefly, here are the steps necessary to produce
one of the example images in the book, that of a
fractal mountain.
1. First, create the data file MOUNTAIN.DAT by
compiling the source code file MOUNTAIN.C and running
the resulting program MOUNTAIN.EXE. This produces
the desired data file
2. Then compile the source code file RENDER.C to
produce the program RENDER.EXE. Run this program and
type "MOUNTAIN" when prompted for a file name.
PART 4: RAY-TRACING
To explode the files for part IV of the book, run
the self-extracting program PART4.EXE by typing: PART4
This will produce the following files in your directory:
PART4 EXE 41893 6-25-91 8:03p
RAYTRACE C 48586 5-15-91 1:20p
MARBLES RT 2006 6-18-91 12:32p
MOLECULE RT 6264 6-19-91 3:17p
OFFICE RT 5083 6-19-91 9:44a
PARK RT 6914 6-18-91 1:26p
PLANETS RT 6261 6-19-91 7:56p
PYRAMID RT 4951 6-18-91 9:54p
DISPLAY C 5013 5-13-91 7:00a
MATH2 INC 9488 5-13-91 7:28a
STACK RT 3412 6-18-91 2:33p
GRAPH2 INC 11317 5-13-91 7:24a
Note that PART4.EXE also remains in the directory.
You should consult the book text for more information,
but, briefly, here are the steps necessary to produce
one of the example images in the book, that of a
ray-traced office scene.
Note that some examples in this section are set up
for Super-VGA resolution (1024 x 768). If you do not
have a Super-VGA display adapter of the kind mentioned
in the text, you will need to make changes in the
source code (and in some of the datafiles).
For the office scene:
1. Edit the file GRAPH2.INC to change the resolution
from super-VGA (1024x768) to 320x200, by changing
lines 39 & 40 from:
#define MaxXres 1024
#define MaxYres 768
To:
#define MaxXres 320
#define MaxYres 200
2. Then compile the source code file RAYTRACE.C to
produce the program RAYTRACE.EXE. Run this program and
type "OFFICE" when prompted for a file name. This
will use the data file OFFICE.RT to create an image
with VGA resolution of 320 (Horz) by 200 (Vert). RAYTRACE
generates a monochrome image to the screen as it is
raytracing the image, and produces a color image file
OFFICE.CPR on your hard drive. Depending on the output
resolution some of these files can be very large!
3. Compile the source code file DISPLAY.C to produce
the executable file DISPLAY.EXE. This file will
generate a color image on the screen using the data
in OFFICE.CPR
Some of the RT files in this section are setup for SuperVGA
resolution. For example the file MARBLES.RT has the following
at lines 13 & 14:
XRES = 1024
YRES = 768
This will need to be changed to 320x200 for lower resolution
display.
Good luck, and enjoy these programs!