Calculate FPS with QGLWidget - paintGL() is not called
-
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?
Thanks