rect was pretty slow

Using GL_POLYGON was a lot slower than glRectf for 2 reasons: 
1. GL_POLYGON isn't purpose-built for rectangles
2. there's a lot less function calls just using glRectf.

Similarly, I believe that line should use GL_LINES and triangle() should use GL_TRIANGLES, although these changes wouldn't get the benefit of 2).

I didn't make those changes because I haven't had time to test them yet.