Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: How to enable/force VSYNC ?

  1. #1
    Intern Contributor
    Join Date
    Sep 2006
    Location
    Delft
    Posts
    57

    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?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    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...

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    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.

  4. #4
    Member Regular Contributor
    Join Date
    Dec 2005
    Posts
    256

    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.

  5. #5
    Intern Contributor
    Join Date
    Sep 2006
    Location
    Delft
    Posts
    57

    Re: How to enable/force VSYNC ?

    Thank you all very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •