Sync & queriesGL 1.0
glFinish
Blocks the CPU until the GPU has completely executed every command issued so far.
Signature
void glFinish(void);
How it works
The blunt instrument: CPU and GPU stop overlapping until everything is done. That kills the parallelism that keeps frames fast, so it does not belong in a render loop.
It is still handy in two places: crude timing while learning (glFinish before reading the clock makes the time include the GPU's work), and isolating a crash or corruption to a specific draw while debugging. For real GPU timings use timer queries; for waiting on specific work use fences.
Tips & pitfalls
glFlush only sends the queued commands to the GPU without waiting;
glFinishsends and waits.
Example
example.cpp
1auto t0 = clock::now();
2drawScene();
3glFinish(); // include the GPU's work in the time
4auto ms = elapsedMs(t0);