Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

What calls paintGL



  • This is Qt3 using QGLWidget.
    A couple of weeks ago, when my app was working I checked up on paintGL() and found that it was being called at 60 Hz. Nothing in my code called it so I surmised that it was being called automatically from either Qt or OpenGL, I cannot determine which. Cool, use that to keep my display updated.

    While trying to make the display driven by time everything stopped. After much messing around I added code back in to check the call rate for paintGL() and its not getting called. As I verified that I was not calling it from anywhere, I don’t know what might have done to cause it to not be called. I am finding some things about paintGL and other things that might cause it to be called, but nothing about what causes it to be called automatically at a regular interval.
    Have you any clues as to where/what I should examine?
    Edit: This just occurred to me: Is this a Qt or an Open GL question?



  • what happens when you manually call the widgets update() method? If that doesn't work then you need to carefully examine the state of the openGL context. You may have issued a non-available visual, or broke it with bad calls to the immediate mode openGL. You are using the old openGL calls, right? not doing anything with the modern shader pipeline?

    insert some qDebug or console output in the paintGL so that you can verify if it is being called.



  • Calling update() does refresh the screen. When the app stopped all displays within the QGLWidget I messed around for several days trying to find the problem, then finally called a function to display static data. At first it did not work, then I explicitly called update() and it worked. Then I restored some code that had written to see how often paintGL() was being called. That showed that it was not being called.
    It was being called at 60Hz. I don't know what I did not stop those calls.
    This is a Qt app with a single QGLWidget that is used to display a strip chart.
    How might I access what-ever it is that controls how often paintGL() is called?


  • Qt Champions 2017

    @BKBK said in What calls paintGL:

    This is Qt3 using QGLWidget.

    This is a mistake, right? You don't mean 15+ years old code, I hope.



  • @kshegunov said in What calls paintGL:

    @BKBK said in What calls paintGL:

    This is Qt3 using QGLWidget.

    This is a mistake, right? You don't mean 15+ years old code, I hope.

    Unfortunately, we are using Qt3. The government Information Protection team (name has been recently updated, I might not have the latest) has changed their rules about using code that is foreign owned. They hate that. And I have been told hate open source. Never did understand that. From what I have found Qt has always been foreign owned, but the rules changed since we started with Qt so we can keep what we have but cannot introduce the new stuff.
    A Royal PIA.



  • I have this partially figured out, but I have not found a simple enough configuration to draw good conclusions.
    It seems to me: update() is strictly within the Qt environment. It schedules repaint() whereas repaint() does a redraw immediately.
    updateGL() is an open GL function that I can call. paintGL() is a GL function that I override and add in the code I need.
    Is this on the right track?

    But still, I have one version where paintGL() gets called at 60 Hz. As noted, and so far, I have not been able to determine what or why it gets called at that rate.
    So, of these functions update() and updateGL() and paintGL(), when should be explicitly called and when?
    Edit
    I think this is resolved by organizing my drawing function in this manner:
    display_strip_chart()

    {  // showing the essence only
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glClear( GL_COLOR_BUFFER_BIT );  // white background
    glColor3f( 0.0, 0.0, 0.0 );
    glBegin( GL_LINE_STRIP );
    for( i = oldest, i <. Newest; i ++
        glVertex2dv( gl_vector[i].p);  // circular buffer, but all that code is omitted.
    glend();
    glFlush();
    glMatrixMode( GL_PROJECTION )
    glLoadIdentity();
    update();
    }
    

    I am not positive, but it does display the points. There is a bad flicker that I don't know how to resolve. That question is posted here: https://forum.qt.io/topic/100159/how-to-double-buffer-with-qt-and-wglwidget


Log in to reply