Inside the companion
First Light
Make your first CPU image, rasterize triangles, and trace an allocation budget.
Project files 15
Describe a triangle study
Screen-space vertices, raster scenes, and the rasterizer interface.
#pragma once
#include "prism/renderer.hpp"
#include <array>
namespace prism {
// Already projected screen coordinates: +X right, +Y down. Depth 0 is near,
// depth 1 is far. This reference starts AFTER a camera's projection/clipping.
struct ScreenVertex { double x{}, y{}, depth{}; Color color; };
struct Triangle { std::array<ScreenVertex, 3> vertices; };
struct RasterScene {
std::uint32_t width{}, height{};
Color background;
std::vector<Triangle> triangles;
};
inline constexpr std::size_t max_triangles = 64;
inline constexpr std::size_t max_raster_work = 16'777'216;
inline constexpr double max_screen_coordinate = 8192;
[[nodiscard]] RasterScene demo_raster_scene();
[[nodiscard]] std::expected<void, Error> validate_raster_scene(const RasterScene& scene);
[[nodiscard]] std::expected<Image, Error> rasterize(const RasterScene& scene);
} // namespace prism
This is the file included with the course. Copy and download give you its complete source.
Taking your work offline? Download all course companions
