refactored opengl calls