The C++ raytracer for the v6 FMI raytracing course. raytracing-bg.net
Recommended setup on Windows if you don't have Visual Studio (e.g. you only have Visual Studio Code)
- Use the following instructions. It boils down to:
- Installing MSYS2
- Installing the MinGW-w64 toolchain using
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
- You may also need the
make
package:pacman -S mingw-w64-ucrt-x86_64-make
- You may also need the
- Adding the path to gcc.exe to the system PATH variable. Likely you'd want to modify it from Environment variables editor in Windows Settings, so that it points to
C:\msys64\ucrt64\bin
- Install CMake — any version later than 3.7 is OK.
- Setup SDL with one of the following options:
- (Recommended) Use the development package for MinGW using
pacman -S mingw-w64-ucrt-x86_64-SDL2
- Download the libSDL2 development package for MinGW from here.
- E.g., use SDL2-devel-2.30.1-mingw.zip
- Make a "SDK" directory, either in a "develop" subfolder in your user directory (e.g.
C:\Users\«USERNAME»\develop
) or inC:\
- Unarchive the SDL2-devel there, e.g. so that CMake can see
C:\Users\«USERNAME»\develop\SDK\SDL2-2.30.1\cmake
- (Recommended) Use the development package for MinGW using
- Download the OpenEXR development package for MinGW using
pacman -S mingw-w64-ucrt-x86_64-openexr
- C/C++
- CMake tools
- clarity/navigation: Boomkarks, Trailing Spaces, Overtype
- Create a "build" sub-directory:
mkdir build
- Change into it:
cd build
- Run CMake, targeting MinGW:
cmake -G "MinGW Makefiles" ..
- Run
make
to build your code- Using the Windows
cmd
may require usingmingw32-make
instead ofmake
.
- Using the Windows
- Copy SDL2.dll from SDL2\x86_64-w64-mingw32\bin\ to your "build" directory (only necessary if you did not use
pacman
and do not have theucrt64/bin
in$PATH
) - You may need to copy the OpenEXR .DLLs in the same manner - again, depends on whether they are in your
$PATH
. - You're all set - run
hexray.exe
The setup works best if you install the CMake Tools extension for Visual Studio Code. This adds an option to change the build type (Debug, Release, MinSizeRel, ...) from the blue ribbon at the bottom of Visual Studio Code screen; the default setting is Debug, which is suitable for debugging. If you want to time how your changes contributed to the rendering speed, compile with Release.
- Install Visual Studio Community edition (free for personal use). It can be downloaded from here.
- Only the
Desktop Development with C++
is necessary for building the project. There are additional instructions here.
- Only the
- Download the SDL2 development package for VC from here
- E.g., use SDL-devel-2.30.1-VC.zip
- Install CMake — version 3.13 or newer is OK.
- (Same as regular setup) Make a "SDK" directory, either in a "develop" subfolder in your user directory (e.g.
C:\Users\«USERNAME»\develop
) or inC:\
- (Same as regular setup) Unarchive the SDL2-devel there, e.g. so that CMake can see
C:\Users\«USERNAME»\develop\SDK\SDL2-2.30.1\cmake
- Setup OpenEXR with one of the following options:
- Using
vcpkg
. OpenEXR can be built and setup with the following command linevcpkg install openexr:x64-windows --x-install-root="C:\Users\«USERNAME»\develop\SDK"
.- Details on setting up
vcpkg
can be found here. - OR directly use the following command line:
git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && bootstrap-vcpkg.bat
, then simply execute the install command above.
- Details on setting up
- Build
OpenEXR
during CMake configuration, by adding-DHEXRAY_BUILD_OPENEXR
to the cmake configuration line (or withcmake-gui
).
- Using
- Create a "build" sub-directory:
mkdir build
- Change into it:
cd build
- Run CMake, targeting a supported Visual Studio version:
- Visual Studio 2022 (recommended):
cmake -G "Visual Studio 17 2022" -A x64 ..
- Visual Studio 2019:
cmake -G "Visual Studio 16 2019" -A x64 ..
- Visual Studio 2017:
cmake -G "Visual Studio 15 2017 Win64" ..
- Visual Studio 2022 (recommended):
- Open the generated
heX-Ray.sln
solution file. - Build the solution (
Build
->Build Solution
OR[Ctrl]+[Shift]+[B]
(some VS may have[F7]
as shortcut for building)). - Start the build (
Debug
->Start Debugging
OR[F5]
).
- (Recommended): install Visual Studio Code (with the recommended extensions like CMake Tools)
- Download the SDK:
- RedHat-based distros like Fedora, CentOS:
sudo dnf install SDL2-devel OpenEXR-devel
- Debian-based distros like Debian, Ubuntu:
sudo apt install libsdl2-dev openexr-dev
- RedHat-based distros like Fedora, CentOS:
- Open the folder via Visual Studio code, let CMake Tools to configure it, then it should be buildable from Visual Studio code
- (alternatively): you can always go to the hexray dir, and do
mkdir build; cd build; cmake ..; make
to build it manually as per above