Re: How can I get a 30 or 60 frame rate when using QGLWidget? QTimer is not acurate
Does your application do anything apart from performing the animation at the same time?
BTW. I'm afraid updateGL() only schedules a repaint, not performs it immediately, so your calculations are not really that precise. As for the 20ms problem - I have no idea... maybe there is some vblank issue related or something. Or maybe you simply didn't repeat the tests enough number of times.
Re: How can I get a 30 or 60 frame rate when using QGLWidget? QTimer is not acurate
Quote:
Originally Posted by
wysota
Does your application do anything apart from performing the animation at the same time?
BTW. I'm afraid updateGL() only schedules a repaint, not performs it immediately, so your calculations are not really that precise. As for the 20ms problem - I have no idea... maybe there is some vblank issue related or something. Or maybe you simply didn't repeat the tests enough number of times.
Nope. Just update my world and render it.
I read on docs:
"If you need to trigger a repaint from places other than paintGL() (a typical example is when using timers to animate scenes), you should call the widget's updateGL() function."
From: http://doc.trolltech.com/4.5/qglwidget.html#paintGL
Re: How can I get a 30 or 60 frame rate when using QGLWidget? QTimer is not acurate
Quote:
Originally Posted by
ricardo
Which still doesn't determine when paintGL() will be called after a call to updateGL(). But I just checked in the code - the redraw is immediate.
Re: How can I get a 30 or 60 frame rate when using QGLWidget? QTimer is not acurate
Hi friends!
I think I found a way. just a WHILE(1) and use qApp->processEvents() to avoid a blocked UI. This code is executed when PLAY is pressed. There are no timers.
Code:
// simulate it for 10 seconds
m_rendered_frames=0;
m_time.start();
while (m_time.elapsed()<=10000) {
now.start();
qApp->processEvents();
m_current_level->Update(0);
m_gl_drawer->updateGL();
m_rendered_frames++;
// sleep a while
if (SIMULATION_UPDATE_INTERVAL_IN_MS-now.elapsed()>0) {
QTest::qSleep(SIMULATION_UPDATE_INTERVAL_IN_MS-now.elapsed());
}
}
// info
float fps=m_rendered_frames/10.0;
QString m
=QString("FPS: %1. rendered frames: %2. Timer interval (ms): %3.").
arg(fps
).
arg(m_rendered_frames
).
arg(SIMULATION_UPDATE_INTERVAL_IN_MS
);
It works properly. What do you think?
Re: How can I get a 30 or 60 frame rate when using QGLWidget? QTimer is not acurate
Event processing is sparse, keys might not be responding or might respond with a delay. That's not a good way to do it. But if it suits your needs...