View Full Version : How to enable/force VSYNC ?
Dylan
06-09-2007, 11:33 AM
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?
ZbuffeR
06-09-2007, 02:21 PM
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...
Dark Photon
06-09-2007, 07:14 PM
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.
Rodrix
06-10-2007, 03:02 AM
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. :)
Dylan
06-11-2007, 01:51 AM
Thank you all very much!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.