How to inquire FPSAnimator (or some other class) for the time increment?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to inquire FPSAnimator (or some other class) for the time increment?

andreasdr
As a newcomer to JOGL, I first went through some tutorials and then began trying to port a little game/animation of my own (let's call it a game from now on) to the JOGL framework. This game implements a game loop that relies on calls to System.nanoTime(). The update method that advances the game simulation takes a time step as input, which is naturally computed by my game loop.

As standard procedure in the context of JOGL seems to be to use a FPSAnimator to handle animation, I'm wondering how, if possible, one would go about obtaining the time step between the current call to display() and the previous one. (Of course, one could solve this by storing a couple of instance variables and calling System.nanoTime() within display(), but since it seems like FPSAnimator should be able to have this functionality, this seems a bit inelegant.)

/Andreas
Reply | Threaded
Open this post in threaded view
|

Re: How to inquire FPSAnimator (or some other class) for the time increment?

gouessej
Administrator
Hi

Please look at the Java documentation of FPSAnimator and its subclasses, you can use getLastFPSPeriod() and getUpdateFPSFrames().
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: How to inquire FPSAnimator (or some other class) for the time increment?

andreasdr
Ah, getLastFPSPeriod() is what I'm after, thanks!
/Andreas
Reply | Threaded
Open this post in threaded view
|

Re: How to inquire FPSAnimator (or some other class) for the time increment?

gouessej
Administrator
You're welcome. Feel free to tell us whether the documentation contains spelling mistakes as usual ;)
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: How to inquire FPSAnimator (or some other class) for the time increment?

andreasdr
gouessej wrote
You're welcome. Feel free to tell us whether the documentation contains spelling mistakes as usual ;)
Haha, you can count on it :).