QOpenGLWidget on Mac: update is automatically called?



  • Hello,

    I have an openGl application that runs on Windows, Linux and Mac. Until recently, I used QGLWidget, but since I upgraded to Qt 5.5, I am now using QOpenGLWidget.
    Before, I had to swap buffers with QGLWidget::swapBuffers()
    Now, I swap buffers (or update the image after rendering was done) with QOpenGLWidget::update()

    This works fine on Windows and Linux, but on Mac (Yosemite), the rendering appears flickering, and incomplete. It is like update() is called automatically, also while a rendering is underway. Imagine, you want to display in every frame 3 cubes. So I do:

    render cube 1 ( glBegin(GL_QUADS), etc..., glEnd() )
    render cube 2
    render cube 3
    update()

    Above works as expected on Linux and Windows, but on Mac, sometimes I have only one cube displayed, othertimes, 2 or 3 (or none). And the colors are very bright (as if the color buffer accumulates 2-3 frames)

    This makes me think that internally, a swapBuffers() is called while I am still rendering (e.g. between cube 2 and cube 3).
    If I explicitely set the swap behaviour of the surface format to double buffer (i.e. surface.setSwapBehavior(QSurfaceFormat::DoubleBuffer) ), then the colors look ok, but the missing cubes problem remains (i.e. incomplete rendering display).

    Does anyone have a clue what is going on?

    If I revert back to using QGLWidget on Qt5.5, everything looks normal.

    Thanks for any insight



  • I have a small update on this:

    If I call glFinish() after my rendering is done, then I can make it work right (given that I specified double-buffering, otherwise the colors appear way too bright).
    The downside is that with glFinish(), the rendering takes 30% longer..


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.