implemented OpenGL state caching