A CPU renderer written in standard c++
Just clone this repo in your machine and you're done!
Please ensure you've got a C++ compiler installation on your machine. This project uses Premake 5 as its build system, so you can customize your environment as you wish.
Generate the project using Premake:
premake5 gmake
After that, you can execute the Makefile:
make
You can also choose which project to build. This repo includes two projects:
- Renderer:
make Renderer
- Tonemapper:
make Tonemapper
Note The default makefile command builds the app with debug symbols. In order to generate production-ready and optimized builds, enter the
config=release
option:
make config=release
Generate the project using Premake:
premake5 vs2022
Note If you're working on VSCode, please update your
.vscode/c_cpp_properties.json
and include the following on yourincludePath
to avoid annoying error highlighting:
{
"configurations": [
{
...
"includePath": [
...
"${workspaceFolder}/vendor/"
],
...
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "c++17",
...
}
],
"version": 4
}
Please refer to the Premake Docs if you need another action for your custom environment.
./bin/ToneMapper <in_file{bmp|ppm}> <out_file.{bmp|ppm}>
./bin/Renderer
This renderer allows parallel rendering on the CPU, deferring tasks on a queue so threads can process them and return the result back. The number of threads can be chosen by hand but it is recommended to allow the maximum number of threads for peak performance.
Here are some funny rendering mistakes that we found during development:
---We all know how annoying C/C++ can be with memory management, so here's a little tool to help. First install Valgrind on your machine via package manager or from the official website. After that, execute Valgrind with the executable as an argument:
valgrind --track-origins=yes --verbose ./bin/ToneMapper
There are some good analysis tools for C++, such as CPPCheck. You can install this tool (On Ubuntu for example it would be sudo apt-get install cppcheck
) and analyze the project with the following command:
cppcheck .
- PPM format specification
- BMP format explained
- A great article about Tone Mapping: Tone Mapping | δelta, by 64