Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: wglSwapIntervalEXT problem

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10

    wglSwapIntervalEXT problem

    I need vsync in my project. So, I called wglSwapIntervalEXT(60). At function BOOL wglSwapIntervalEXT(int interval), the parameter interval must be my monitor frequency? Do I need call another function to enable vsync?

    I just called wglSwapIntervalEXT(60), but doesn't works...

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    If you would have read the spec, you would know:

    Quote Originally Posted by WGL_EXT_swap_control
    The parameter <interval> specifies the minimum number of video frames that are displayed before a buffer swap will occur.


    Thus no matter what is your monitor frequency, if you want to enable vsync to match your monitor frequency you have to set it to "1", which is actually the default behavior.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10
    Now I call the function by this way: wglSwapIntervalEXT(1)

    I'm using cout to see the values of interval between the frames. I think the values must be equals at all iterations and, as my monitor frequency is 60 Hz, this value must be 1000/60 = 16.66 ms. But I got the values 1 or 2 only, like the vsync was disabled... My code:

    while(true){
    draw code...
    SDL_GL_SwapBuffers();
    current = clock();
    cout << current - old << endl;
    old = current;
    }

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    Don't forget that there may be settings in your driver's control panel that may prevent the swap internal from taking effect. Usually there are three options on the control panel: always on, always off and application controlled. Make sure that you don't have "always off" selected.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10
    I didn't found this option in my driver' control panel =/ But the function wglSwapIntervalEXT(1) returns 1. This means that the vsync should be enabled?

  6. #6
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,076
    Are you serious?

  7. #7
    Quote Originally Posted by S1ngular View Post
    Don't forget vsync works only in fullscreen mode.
    No, it doesn't.

  8. #8
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    Quote Originally Posted by eile View Post
    No, it doesn't.
    ok, i've fixed that and i'm gonna remove misleading post;

    For vsync to work, your PFD should have parameters "PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER", read more about pixelformatdescriptor and contexts. You should end every frame with SwapBuffers(hdc). And you should check if your driver doesn't override vsync(nvidia control panel/amd ccc, or google how to allow vsync through driver).

    little advice: although i wouldn't enable vsync in any input precision critical application. the problem is it creates slight input lag. it is ok for third person game or not very fast first person game and other genres. it's ok for some demos or school projects. but for sharp\multiplayer FPS it is unacceptable, and i wouldn't even put option to enable it because there are a lot of clueless people who will enable it and after some time notice aiming problems, forgetting after changing which setting that lag appeared.
    Last edited by Nowhere-01; 01-07-2013 at 03:41 AM.

  9. #9
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10
    My example worked on a machine with NVIDIA driver... But, I tested on another machine with other NVIDIA driver and it didn't work...
    I use glew to load wglSwapIntervalEXT. glewinfo show me wglSwapIntervalEXT is OK:
    WGL_EXT_swap_control: OK
    ---------------------
    wglGetSwapIntervalEXT: OK
    wglSwapIntervalEXT: OK

    But... my code says it not ok!:

    if(WGLEW_EXT_swap_control){
    cout << "wglSwapIntervalEXT ok" << endl;
    bool ret = wglSwapIntervalEXT(1);
    cout << "ret = " << ret << endl;
    } else {
    cout << "wglSwapIntervalEXT - extension not ok" << endl; // this is my cout...
    return 0;
    }

    What shall be wrong?

  10. #10
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10
    Using another driver from NVIDIA I mentioned, I realized that Glew not load any function but glewInit not returning any error. I decided to change the number of bits per pixel to 24 and everything worked, including wglSwapIntervalEXT! Now my problem is: how to find the correct configuration to run on each machine?

Tags for this Thread

Posting Permissions

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