Inside the companion
First Light
Make your first CPU image, rasterize triangles, and trace an allocation budget.
Project files 15
Run the triangle rasterizer
The command-line path from a demo raster scene to a saved image.
#include "prism/raster_lab.hpp"
#include <exception>
#include <iostream>
#include <string_view>
int main(int argc, char* argv[]) {
if (argc == 2 && std::string_view{argv[1]} == "--help") {
std::cout << "Parallax screen-space raster reference\nUsage: prism-raster <output.ppm>\n";
return 0;
}
if (argc != 2) { std::cerr << "Usage: prism-raster <output.ppm>\n"; return 1; }
try {
auto image = prism::rasterize(prism::demo_raster_scene());
if (!image) { std::cerr << image.error().message << '\n'; return 1; }
if (const auto result = prism::write_ppm(std::filesystem::path{argv[1]}, *image); !result) {
std::cerr << result.error().message << '\n'; return 1;
}
std::cout << "Rasterized " << image->width << " × " << image->height << " pixels.\n";
return 0;
} catch (const std::exception&) {
std::cerr << "The raster experiment could not complete.\n"; return 1;
}
}
This is the file included with the course. Copy and download give you its complete source.
Taking your work offline? Download all course companions
