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 use wglSwapBuffers?

  1. #1
    Advanced Member Frequent Contributor Ehsan Kamrani's Avatar
    Join Date
    May 2005
    Posts
    537

    How to use wglSwapBuffers?

    Hi
    I want to use wglSwapBuffers in my examples-- I have seen this function in the book "More OpenGL Game Programming".However I have not found this function in wglext.h( or wglew.h ).I have seen a similar function called wglSwapBuffersMscOML() however. How to disable VSYNC with these functions?
    -Ehsan-

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: How to use wglSwapBuffers?

    1.) There is a Win32 API function wglSwapLayerBuffers().
    The SwapBuffers() function you might know is just a wrapper on top of this. SwapBuffers() swaps all color buffers from back to front.
    With wglSwapLayerBuffers() you can swap mainplane and overlay plane independently. That is, if your OpenGL implementation supports overlays and you use them.
    If not, SwapBuffers() is the same as wglSwapLayerBuffers(hdc, WGL_SWAP_MAIN_PLANE).

    2.) Waiting for vertical retrace is not controlled with these functions but with the extension http://www.opengl.org/registry/specs...ap_control.txt

    If your OpenGL implementaton supports this and returns a valid function pointer for it, call wglSwapIntervalEXT(0) and both of the above mentioned swap buffer calls should stop waiting on the next vsync.

    In most graphics drivers there is a setting in their control panels which can be used to ovveride this.

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264

    Re: How to use wglSwapBuffers?

    There is wglSwapBuffers and wglSwapLayerBuffers and wglSwapMultipleBuffers which is standard on all Windows. It's not recommended to use these because it causes some weird behavior/performance loss.

    Only use SwapBuffers(HDC hdc)
    wglSwapBuffers is suppose to do the same thing, but it's not recommended.
    Some of those wgl functions are defined in wingdi.h
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  4. #4
    Advanced Member Frequent Contributor Ehsan Kamrani's Avatar
    Join Date
    May 2005
    Posts
    537

    Re: How to use wglSwapBuffers?

    Thanks
    With wglSwapLayerBuffers() and wglSwapIntervalEXT(0) I disabled VSYNC--It's an option in our game.
    -Ehsan-

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264

    Re: How to use wglSwapBuffers?

    You only need wglSwapIntervalEXT to control v-sync
    wglSwapIntervalEXT(0) = off
    wglSwapIntervalEXT(1) = on
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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