[Qt-interest] Blocking Flip Problem

John McClurkin jwm at nei.nih.gov
Tue Nov 9 13:29:21 CET 2010


naiqiao liang wrote:
> HI,
> 
> The problem is that we will sometimes need to update the screen 
> every vertical retrace, so we can't put in a delay.  
> 
> The code below is some try to block the flip, but it failed. Could 
> anyone give me some tips on that. Thanks ahead.
> 
>     def swapBuffers(self):
> 
>         # first call the swap on the QGLWidget
>         self.glw.swapBuffers()
> 
>         # The following is taken from the PsychToolbox
>         # Draw a single pixel in left-top area of back-buffer. This
> will wait/stall the rendering pipeline
>         # until the buffer flip has happened, aka immediately after
> the VBL has started.
>         # We need the pixel as "synchronization token", so the
> following glFinish() really
>         # waits for VBL instead of just "falling through" due to the
> asynchronous nature of
>         # OpenGL:
>         glDrawBuffer(GL_BACK)
>         # We draw our single pixel with an alpha-value of zero - so
> effectively it doesn't
>         # change the color buffer - just the z-buffer if z-writes are 
> enabled...
>         glColor4f(0,0,0,0)
>         glBegin(GL_POINTS)
>         glVertex2i(10,10)
>         glEnd()
>         # This glFinish() will wait until point drawing is finished,
> ergo backbuffer was ready
>         # for drawing, ergo buffer swap in sync with start of VBL has 
> happened.
>         glFinish()
> 
> I don't know why the glFinish is not blocking...

What operating system are you using? For linux, you can set the 
__GL_SYNC_TO_VBLANK environment variable to 1. For windows, you can set 
the driver properties to sync on vertical retrace.



More information about the Qt-interest-old mailing list