refactor gl error checking into checkGLError()