An alternative to #41

@errcw I cherry-picked that from my repo, so you can take a look at it.
Untested inside go-gl/glow.