Modified to add a flag for compileGLObjects