Refactored initGL() into several functions