Vertical Retrace

I’m programming OpenGL under Win32.
Is there some way to wait for a vertical
retrace before I swap the front/back buffer ?
Sometimes (depends on how the scene looks like) you see it flickering a bit. It’s not
really bad, but it would be nice if I could
get rid of it, even if this will cost some
FPS.

regards
Ann

Use the swap control extension … this code will enable Vsync if available through this extension:

typedef void (APIENTRY * PFNWGLEXTSWAPCONTROLPROC) (int i);
PFNWGLEXTSWAPCONTROLPROC wglSwapControl = NULL;
wglSwapControl = (PFNWGLEXTSWAPCONTROLPROC) wglGetProcAddress(“wglSwapIntervalEXT”);
if (wglSwapControl != NULL) wglSwapControl(1);