– "Look mom, no GPU!"
Instead, this is a software renderer running, written in C++ 20 and compiled to LLVM IR ➜ WebAssembly using Emscripten. Therefore, expect this to run significantly slower than hardware-accelerated WebGL (this demo is running in a single thread!).
License: Boost Software License 1.0
Download v0.9.0
Features
- Draw directly into a surface pointer
- Write vertex and pixel shaders directly in C++ as functors, including state
- Instant access to uniform data
- Arbitrary vertex inputs and outputs
- Stateless drawing functions
- Alpha blending (blend states)
- Depth buffering
- Image sampling (samplers) including optional linear filtering
- Multiple render targets
- Standalone, no dependencies beside the C++ STL
- Multithreaded rasterization using OpenMP if available
- Pretty fast!
For a draw call, almost the entire pipeline state is specified. Where possible, the library infers some information for you. This allows the library to decide which code paths to take at compile time. You therefore only pay for what you use.
Usage
Either
add_subdirectory(cppgfx), thentarget_link_libraries(MyApp PRIVATE cppgfx)#include <cppgfx.hpp>
or copy cppgfx.hpp to your project and #include from there.
Example
See the Demo folder for an example application. It uses CMake and downloads all dependencies automatically. Configure & build as usual:
> cd cppgfx
> cmake -B build
> cmake --build build --config Release
Why software rasterization?
Software renderers provide hassle-free and highly-flexible drawing operations down to the pixel. They are essential in fields where GPUs are unavailable or drivers cannot be trusted (e.g., medical workstations). They can also be used for cheap rendering tasks where CPU-GPU synchronization is too expensive.