Simple and easy to read template class for clipping 2d polygons to bounding box. Vertex positions are clipped to bounding box, and other optional attributes such as texcoord and color are interpolated based on the clipped position values.
Class accepts a single line, triangle or convex quad, and clips it into multiple polygons of the requested type.
See main.cpp for an example. Various types of vertexes are introduced in Vertex2d.h – file.
Feel free to use the codes as you like. Also if you are interested to see these codes in action, check out my game Dandy Boy Adventures: https://dandyboyoni.itch.io/dandyboyadventures WARNING, game contains adult content!