typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
void setVSync(int interval=1)
{
const char *extensions = glGetString( GL_EXTENSIONS );
if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 )
return; // Error: WGL_EXT_swap_control extension not supported on your computer.\n");
else
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" );
if( wglSwapIntervalEXT )
wglSwapIntervalEXT(interval);
}
}
The default 'interval' is 1, which means VSync is on. Setting it to 0 would turn it off.


This topic is locked









