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

Thread: glutSwapBuffers: How to execute that in plan GL ?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2008
    Posts
    5

    glutSwapBuffers: How to execute that in plan GL ?

    Hello, (new to openGL)

    I'm finding glutSwapBuffers() function a bit slow in some circumstances. I would like to try with equivalent commands in plain GL but I could not find them.

    Can someone give me some help/directions on that ?
    (I'm using Ruby just in case language implementation became important).

    Thank you.

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

    Re: glutSwapBuffers: How to execute that in plan GL ?

    swapping buffers is not slow, check doing a glFlush right before.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2008
    Posts
    5

    Re: glutSwapBuffers: How to execute that in plan GL

    Well, glFlush() before glutSwapBuffers() did not improved.

    Let me explain my scenario:

    1. The model is a simple 35500 vertex rendered as GL_POINTS.
    2. My machine needs 30 ms to render those points in a non-buffered view (GLUT_SINGLE) using just the CPU.
    3. Needs only 0.15 ms in a non-buffered view but now using the GPU (via glNewList(x, GL_COMPILE).
    4. 30 ms in a buffered view (GLUT_DOUBLE) with CPU.
    5. 17 ms buffered view with GPU.
    6. 17 ms to render nothing in a buffered view (just simple execution of the glutSwapBuffers).

    And doing a glFlush right before does not change these numbers.
    Am I missing something or doing something wrong ?

    Thank you
    Marcio

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

    Re: glutSwapBuffers: How to execute that in plan GL

    The actual cost of swapping buffers is negligible.
    What you see is probably an effect of vsync. Before doing benchmarks, disable it, otherwise you only measure your display refresh rate.
    ie : 1 s /60 Hz = 16.667 ms

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2008
    Posts
    5

    Re: glutSwapBuffers: How to execute that in plan GL

    Bingo! Thank you very much.

    Turning off vsync resolved my "issue".

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    Re: glutSwapBuffers: How to execute that in plan GL

    "swapping buffers is not slow, check doing a glFlush right before"

    Yeah, but doesn't glutSwapBuffers() block until all previously sent data flows out of the rendering pipeline and into the frame buffer before swapping?
    Striving for proficiency...

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

    Re: glutSwapBuffers: How to execute that in plan G

    My mistake, I meant glFinish().
    Normally swapbuffers implies glFlush(), not a glFinish(). Of course the implementation can do a glFinish() instead.
    What happens is that the card can buffer a bunch of GL commands before blocking, so you can already have submitted multiple frames without blocking, and before they are actually drawn.

Posting Permissions

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