[Interest] Calculate FPS with QGLWidget - paintGL() is not called

Dietrich.Gossen at continental-corporation.com Dietrich.Gossen at continental-corporation.com
Fri Feb 10 08:56:13 CET 2012


Hi,

I am trying to calculate the fps of my application. I know in general how 
to do it, but my implemented QGLWidget doesn’t work properly. The 
paintGL() Method doesn’t get called.

That’ how my own Widget GLWidget looks like:

GLWidget.h

    #include <QGLWidget>
    #include <QTime>
 
 
    class GLWidget : public QGLWidget {
 
        Q_OBJECT
    public:
        GLWidget(QWidget *parent = 0 );
 
 
    protected:
        void paintGL ();
 
    private:
        int m_frameCount;
        QTime m_time;
 
    };

GLWidget.cpp

    #include "glwidget.h"
    #include <QDebug>
 
    GLWidget::GLWidget(QWidget *parent)
        : QGLWidget(parent)
    {
        m_frameCount = 0;
    }
 
    void GLWidget::paintGL()
    {
        if (m_frameCount == 0) {
             m_time.start();
        } else {
            qDebug("FPS is %f ms\n", m_time.elapsed() / 
float(m_frameCount));
        }
        m_frameCount++;
 
        qDebug() << "frameCount: " << m_frameCount;
        QGLWidget::paintGL();
    }

And that’s my main.cpp

    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
 
        QGraphicsScene scene;
 
 
        QGraphicsView view(&scene);
 
        GLWidget *gl = new GLWidget();
 
        view.setViewport(gl);
        view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
 
        view.show();
 
        return a.exec();
    }

My problem is that it works hardware accerlated but the paintGL() Method 
doesn’t get called…

Any Ideas?


Regards,

Dietrich Gossen
Continental Engineering Services

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120210/e7ba0a0d/attachment.html>


More information about the Interest mailing list