Refactoring of demo_gl