Encapsulating the OpenGL state machine