Sign in to follow this  
DeMohn

enable v-sync in openGL app

Recommended Posts

hi there, i have to be able to enable or disable v-sync in my openGL application. I am using glut to create the main window. Any idea how to do that? thanks in advance, DeMohn

Share this post


Link to post
Share on other sites


void InitVSync()
{
char* extensions = (char*)glGetString(GL_EXTENSIONS);
if (strstr(extensions,"WGL_EXT_swap_control"))
{
wglSwapIntervalEXT = (PFNWGLEXTSWAPCONTROLPROC)
wglGetProcAddress("wglSwapIntervalEXT");
wglGetSwapIntervalEXT = (PFNWGLEXTGETSWAPINTERVALPROC)
wglGetProcAddress("wglGetSwapIntervalEXT");
}
}
void SetVSync(bool VSync)
{
wglSwapIntervalEXT(VSync ? 1 : 0);
}
bool GetVSync()
{
return wglGetSwapIntervalEXT()==0 ? false : true;
}



Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this