Restructure opengl-related code