Hi !

Suppose you are doing a very simple animation that can be drawn on 1 millisec, and that you end your drawing with a call to glutSwapBuffers, then loop.

glutSwapBuffers is supposed to tag the backbuffer to be swapped during the next vertical blanking, then return ; the successive calls to gl functions beeing not executed untill the buffer exchange is completed.

So what if the described loop needs only a ten’th of the vertical rate to perform ?
Will the second glutSwapBuffers will block, so that the animation is done at the maximum frame rate, but not more ; or will it just invalidate the prior glutSwapBuffer so that some frames are drawn for nothing ?

GLUT has nothing to say whether the driver should wait for a vertical retrace or not before changing back and front buffer. There’s usually a switch in some control panel, at least under Windows, to control the vertical retrace.

There are some switch to (dis)allow the vertical synchro, but the general behavior is to wait, as is tell on the manual page :

“The update typically takes place during the vertical retrace of the monitor, rather than immediately after glutSwapBuffers is called.
An implicit glFlush is done by glutSwapBuffers before it returns. Subsequent OpenGL commands can be issued immediately after calling glutSwapBuffers, but are not executed until the buffer exchange is completed.”

So, under normal circumstancies, glutSwapBuffers should swap on the VBL.

What is left unspecified, however, is what happen to the buffer when you supply 2 glutSwapBuffers before any VBL occurence - and so, my initial question :]

The manual is correct.

I think the second call to swap will have to wait for the first to complete. If timing is important, it’s a good idea to query the refresh rate and time your rendering loop. That way, you don’t waste time waiting and instead can compute something.
You might also want to see if you have an extension available to control the swapping like WGL_EXT_swap_control