partially refactored WebGL code into gl-header.js