refactor opengl