par_shapes.h

One of the practical uses for procedural generation that we’ve discussed in the past is as test data. When you’re testing a system, you need to put it through its paces. Things that are reproducible and have as few outside dependencies as possible are very valuable for testing. Which means that generating the test data is the often best way to go.

That was certainly Philip Rideout’s goal in writing par_shapes.h, an MIT-licensed single-file library for procedurally generating test geometry. With everything in code, you can use it to test graphics APIs in isolation, using complex shapes without worrying about if your file loading code is contributing to the errors.

The library includes platonic solids, parametric shapes, rocks, l-systems, and trefoil knots, which is a nice selection of basic procedural geometry. Plus the code’s on github.