+ // Make sure we never have more than one frame pending at any time.
+ // This ensures we do not swamp the GPU with so much work
+ // that we cannot actually display the frames we generate.
+ if (prev_sync != NULL) {
+ glFlush();
+ glClientWaitSync( prev_sync, 0, GL_TIMEOUT_IGNORED );
+ glDeleteSync( prev_sync );
+ }