[Qt-interest] Fwd: calculate FPS using QTime
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Mon Jan 12 11:10:57 CET 2009
ami guru wrote on Monday, January 12, 2009 10:19 AM:
> ...
> void GLWidget::calculateFPS()
> ...
> Is there any idle function or any kind of looping function so that i
> can continuously update the fps
>
> Now i do not get that updated one untill i interact with the scene.
Ah okay, now I seem to understand your problem better: I don't know your exact application context, but I understand that only when you e.g. rotate the scene is the FPS actually updated.
It seems that you don't have a continuous update of your scene (model), so the behaviour you are observing is what I would expect: if you don't rotate the scene, to updateGL() is ever called - why should it? You did not modify the scene, so no need for painting it again using OpenGL! And if no GL update is necessary your paintGL() method is never called, nor your calculateFPS(). That's the nature of the problem :)
If on the other hand you had a thread (or a timer which would fire at the desired rate of say 30 FPS, for example) which would constantly update/change the scene (the model) and hence an updateGL() would be triggered (e.g. a constantly rotating cube), then your FPS counter would be updated as well continuously. Think "Quake" were you have opponents running around all the time in the "world": the scene is constantly being updated!
So it's very simple: no moving objects(1), no update of the scene, no re-rendering necessary, no updated FPS counter ;)
Cheers, Oliver
(1) For measurements reasons you could off course simply re-render the same scene over and over again, but the FPS you get then is not very meaningful/close to reality.
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list