![]() |
![]() |
![]() |
---|---|---|
In One Weekend | The Next Week | The Rest of Your Life |
The Ray Tracing in One Weekend series of books are now available to the public for free directly from the web:
These books have been formatted for both screen and print. For printed copies, or to create PDF versions, use the print function in your browser.
The GitHub home for this project contains all source and documentation associated with the Ray Tracing in One Weekend series of books. To clone or download the source code, see the green "Clone or download" button in the upper right of the project home page.
Copies of source are provided for you to check your work and compare against. If you wish to build the provided source, the project uses CMake. At the root of the project directory, run the following commands to build the debug version of every executable:
$ cmake -B build
$ cmake --build build
You can specify the target with the --target <program>
option, where the program may be
inOneWeekend
, theNextWeek
, theRestOfYourLife
, or any of the demonstration programs. By default
(with no --target
option), CMake will build all targets.
On Windows, you can build either debug
(the default) or release
(the optimized version). To
specify this, use the --config <debug|release>
option.
You may choose to use the CMake GUI when building on windows.
- Open CMake GUI on Windows
- For "Where is the source code:", set to location of the copied directory. For example,
C:\Users\Peter\raytracing.github.io
. - Add the folder "build" within the location of the copied directory. For example,
C:\Users\Peter\raytracing.github.io\build
. - For "Where to build the binaries", set this to the newly-created build directory.
- Click "Configure".
- For "Specify the generator for this project", set this to your version of Visual Studio.
- Click "Done".
- Click "Configure" again.
- Click "Generate".
- In File Explorer, navigate to build directory and double click the newly-created
.sln
project. - Build in Visual Studio.
If the project is succesfully cloned and built, you can then use the native terminal of your operating system to simply print the image to file.
On Linux or OSX, from the terminal, run like this:
$ build/inOneWeekend > image.ppm
On Windows, run like this:
build\debug\inOneWeekend > image.ppm
or, run the optimized version (if you've built with --config release
):
build\release\inOneWeekend > image.ppm
The generated PPM file can be viewed directly as a regular computer image, if your operating system supports this image type. If your system doesn't handle PPM files, then you should be able to find PPM file viewers online. We like ImageMagick.
If you spot errors, have suggested corrections, or would like to help out with the project, please review the CONTRIBUTING document for the most effective way to proceed.