Here’s a little WebGL app that lets you draw a closed path. The app uses an ear clipping algorithm to figure out how to fill the path with triangles, assuming the vertices are ordered counter-clockwise.

https://prideout.net/polygon.js


You can browse the CoffeeScript source here:

polygon.coffee