Similar to computer IO buffer, OpenGL commands are not executed immediately.
All commands are stored in buffers first, including network buffers and the graphics
accelerator itself, and are awaiting execution until buffers are full. For example, if
an application runs over the network, it is much more efficient to send a collection
of commands in a single packet than to send each command over network one at a time.
glFlush() empties all commands in these buffers and forces all pending commands
will to be executed immediately without waiting buffers are full.
Therefore glFlush() guarantees that all OpenGL commands made up to that point
will complete executions in a finite amount time after calling glFlush().
And glFlush() does not wait until previous executions are complete and may return
immediately to your program. So you are free to send more commands even though
previously issued commands are not finished.
glFinish() flushes buffers and forces commands to begin execution as glFlush() does,
but glFinish() blocks other OpenGL commands and waits for all execution is complete.
Consequently, glFinish() does not return to your program until all previously called
commands are complete. It might be used to synchronize tasks or to measure exact
elapsed time that certain OpenGL commands are executed.
所以两个命令都是使命令缓存中的指令立即执行并清空缓存,
只是glFlush()立即返回,而glFinish()等到指令执行完成之后才返回。