TINYGL: Refactored the triangle function in a template fashion