4.3 KiB
Computer Graphics Lab1 - Ray Casting
Deadline: Oct. 11 2024, 22:00
Welcome to the GitHub repository for the first Computer Graphics assignment. This readme contains some additional information on the GitHub Classroom system, and how to compile, build, and execute your code. The actual Ray Casting assignment can be found in 01_RayCasting.html
. Good luck!
What is GitHub Classroom?
This feature allows us the create 1 "template" repository with the unsolved assignment, that can be cloned by every student. Once the student makes some local changes and pushes them back to GitHub, they create their own, private repository that can only be accessed by them and us, the teaching staff. In short, you have all the version control benefits of Git, while we can easily collect submissions at the deadline.
Submission
While you are working on the assignment, feel free to push your changes to GitHub for version control. Before the deadline, push your final changes to the remote GitHub repository. Changes made after the deadline will not be taken into account during grading.
The .gitignore
makes sure that your bin/
or build/
or Visual Studio specific folders don't get pushed. We don't need those, only your C++ files in src/
and include/
.
Running your code on a .json
file from the data/
folder results in 3 files: depth.png
id.png
and normal.png
. If these do not look exactly like the files in correct_results/
folder, there is something wrong with your implementation and you will lose points.
Building the project using CMake
In short, CMake
makes sure that all the necessary source files and libraries are included during the compiling and building of your executable. It knows which files to include by reading the CMakeLists.txt
file. Go ahead and have a quick look at CMakeLists.txt
before you continue.
Linux (or WSL on Windows)
Install CMake (and GCC if this was not the case already, since you will need a C++ compiler). Open a terminal and navigate to the directory containing the CMakeLists.txt
. Now run:
mkdir build
cd build
cmake ..
make
If everything goes well, make
has built the executable file ./raycasting
(might require sudo chmod +x <filename>
). If you make changes to the files in /src
, simply re-run make
to rebuild the executable.
MacOS
See the previous section. You can use the C++ compiler in XCode for example.
Windows
(We use Visual Studio as an example, but feel free to use other software.)
Install Visual Studio
(!= Visual Studio Code
, which does not have a C++ compiler by default). If you are unsure whether or not your installation is sufficient, open the Visual Studio Installer
, click "Modify" and make sure the checkbox of "Desktop development with C++" is checked.
Open Visual Studio. On the right side, click "Continue without code". In the top-left corner, choose "File > Open > CMake.." and in the file explorer, select the CMakeLists.txt
file of the assignment. This will set up your project in Visual Studio. After waiting a bit, you should see a terminal opening at the bottom, running CMake. Check if there are errors. If not, you can find the /src
folder in Visual Studio's "Solution Explorer" on the left. Open it and click on one of the cpp
files to start coding.
To build and run the project, click "Build > Build Solution" or press F7. If there are build errors, they will appear at the bottom of Visual Studio. If not, then the executable file raycasting.exe
should have been created somewhere in a subdirectory. Open a terminal (also called command prompt), navigate to the folder with raycasting.exe
and run the .exe file from there.
Important! Debug vs. Release mode
By default, the executable is built in Debug
mode, which allows for debugging but runs slow, especially for data/bunny.json
. Speed things up by switching to Release mode
.
Linux/MacOS/WSL for Windows: instead of cmake ..
run cmake .. -DCMAKE_BUILD_TYPE=Release
Windows: In Visual Studio, at the top, click on the drop-down next to x64-Debug
and click Manage Configurations..
(as shown below). Then click the green plus sign on the left, choose x64-Release
, and type Ctrl+S to save. You can now switch between x64-Debug
and x64-Release
. Rebuild.