# With vsync enabled where does the wait happen in OpenGL?

When having vsync enabled I'm imagining that OpenGL has an explicit wait function to try and keep the frame rate constant. If so where is this function implemented exactly? After running some tests glClear() function seems to take almost 16 ms with minimal OpenGL script on my machine. When removing this function, the wait seems to happen where the first (?) glDrawArrays() or glDrawElements() function is implemented. If none of these functions are implemented then on my machine the wait happens during glxSwapBuffers().

I'm hoping to get some better understanding behind his, partly to know when to best poll the input events. Previously I polled at the start of the main loop and then rendered the scene. But since there's a wait during glClear() function, I'm experiencing a bit of an input delay. So maybe it would make more sense to poll in-between clearing the buffers and rendering the scene?