Refactoring OpenGL render code