Vertical sync control

It will be nice to add support for better vsync
control. For example add some function like glGetTimeToSwap(GL_MILISECONDS) or add some wgl/glx functions that can use OS specific syncing objects like events.

Right now, SwapBuffers take too much CPU time.

Example:
HANDLE hswap = wglGetSwapEvent();
while (!bQuit)
{
Render();
WaitForSingleObject(hswap, INFINITE);
SwapBuffers();
}

This code is usefull only when you enable vsync.

What do you mean by “SwapBuffers take too much CPU time”? Do you mean the wall-clock time used between calling SwapBuffers and returning from SwapBuffers is too long? If so, then the code you present won’t solve the problem. That’s basically what SwapBuffers looks like internally.

The problem is that SwapBuffers is, by default, synchronous. It doesn’t return until after the swap has occured. That means that it has to wait until all previously issued rendering commands have completed and the swap interval has been satisfied. If you put a glFinish call before the SwapBuffers call, I bet that will take most of the time you were seeing SwapBuffers take. This won’t solve your problem either. It’s just to illustrate where the time is spent.

There are some extensions, such as OML_sync_control , that explicitly allow for asynchronous swaps. I think that’s what you really want.