-
How to enable/force VSYNC ?
Is there any code to enable vsync in openGL? The program has to start in vsync, platform independent.
If this is not possible (which I hope not) are there any other methods to force vsync?
-
Super Moderator
OpenGL Lord
Re: How to enable/force VSYNC ?
It is possible, but the exact code depends on the windowing system or the lib used for it. Just like swapbuffers is not stricly opengl and depends on windowing system.
windows: wglSwapInterval(1);
SDL: search for SDL_GL_SWAP_CONTROL
linux: glXSwapInterval
etc...
-
Senior Member
OpenGL Guru
Re: How to enable/force VSYNC ?
Dylan:
Is there any code to enable vsync in openGL? The program has to start in vsync, platform independent.
On Linux, __GL_SYNC_TO_VBLANK=1 in the environment will trigger this on NVidia. Can't speak for Windows.
-
Member
Regular Contributor
Re: How to enable/force VSYNC ?
For Windows this is the code you are probably
looking for!
HEADER FILE:
/*******************VSync*************************/
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
extern PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT;
/**************************************************/
SOURCE FILE
static inline void init_EXT_Vsync()
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)extgl_GetProcAddress( "wglSwapIntervalEXT" );
}
Cheers!
Rod
P.S: Don't forget to query if extension is supported by checking in GL Extensions string before calling init_EXT_Vsync().
Afterwards, wglSwapIntervalEXT(1) will turn Vsync on.
wglSwapIntervalEXT(0) will turn it off.
-
Re: How to enable/force VSYNC ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules