We have an array of vertices, an array of vertex-indices and a rectangle. Every three indices form a triangle to be drawn. The rectangle is a mask/border that may not be drawn outside of. Though some of the triangles may be outside / overlapping the rectangle.
Does anybody know a (fast) algorithm (or C/C++ implementation of an algorithm) that can transform/re-create the triangle and indices array according to the masking rectangle?
Triangles not overlapping and inside the rectangle should just be left as they are, triangles overlapping should be cut and and the inside parts should remain, and triangles completely outside should be removed as well.
There's a good algorithm: Sutherland–Hodgman. Read more at https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm