Add OpenGL code and refactoring