Factor out some WebGL code.