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 4 of 4

Thread: glutSwapBuffers

  1. #1
    Intern Contributor
    Join Date
    Sep 2001
    Location
    paris, france
    Posts
    84

    glutSwapBuffers

    Hi !

    Suppose you are doing a very simple animation that can be drawn on 1 millisec, and that you end your drawing with a call to glutSwapBuffers, then loop.

    glutSwapBuffers is supposed to tag the backbuffer to be swapped during the next vertical blanking, then return ; the successive calls to gl functions beeing not executed untill the buffer exchange is completed.

    So what if the described loop needs only a ten'th of the vertical rate to perform ?
    Will the second glutSwapBuffers will block, so that the animation is done at the maximum frame rate, but not more ; or will it just invalidate the prior glutSwapBuffer so that some frames are drawn for nothing ?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: glutSwapBuffers

    GLUT has nothing to say whether the driver should wait for a vertical retrace or not before changing back and front buffer. There's usually a switch in some control panel, at least under Windows, to control the vertical retrace.

  3. #3
    Intern Contributor
    Join Date
    Sep 2001
    Location
    paris, france
    Posts
    84

    Re: glutSwapBuffers

    There are some switch to (dis)allow the vertical synchro, but the general behavior is to wait, as is tell on the manual page :

    "The update typically takes place during the vertical retrace of the monitor, rather than immediately after glutSwapBuffers is called.
    An implicit glFlush is done by glutSwapBuffers before it returns. Subsequent OpenGL commands can be issued immediately after calling glutSwapBuffers, but are not executed until the buffer exchange is completed."

    So, under normal circumstancies, glutSwapBuffers should swap on the VBL.

    What is left unspecified, however, is what happen to the buffer when you supply 2 glutSwapBuffers before any VBL occurence - and so, my initial question :]

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

    Re: glutSwapBuffers

    The manual is correct.

    I think the second call to swap will have to wait for the first to complete. If timing is important, it's a good idea to query the refresh rate and time your rendering loop. That way, you don't waste time waiting and instead can compute something.
    You might also want to see if you have an extension available to control the swapping like WGL_EXT_swap_control
    ------------------------------
    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
  •