consolidating code into gl.hpp