What will the 'dt' value in update(dt) be if game freezes for some time?

I use biquad filters in my project. To configure the filters I need to know the frame rate the game will run at.

Until now the dt value of the update(dt) function always indicated 16 ms. Thus a framerate of 60Hz.

But what happens when the framerate drops? Will that be reflected by the dt value?

If there computer needs to do something else for a long time and the game freezes for 1 sec. Does the dt value indicates this 1 sec the next time?

And can I influence the target frame rate?

Hi @simmania,

Yes, that dt value will reflect the time it took to render the last frame, so if your main thread is to lag and take longer, it will reflect that.

You shouldn’t be targeting 16ms as the norm, since on high refresh rate monitors like gaming monitors that number can be lower (half on 120Hz, even less on 240Hz).

If you are talking of putting a max cap on that, then there is a way, check here: [SOLVED] Any way to cap game at 30fps?

But if I do not know if the framerate will be 60Hz, 120Hz, 240Hz (or whatever), how can I setup my filters?
Filters like biquad filters must be calculated for a specific sample rate. I call the filter each frame, so I need to know the frame rate in advance.

You shouldn’t base your code on something so variable. You can’t really fix the frame rate, you may be able to cap it to a maximum but there is no guarantee the user’s device is powerful enough to render to the maximum fixed frame rate all the time.

You should instead create a fixed timer that runs independently of the frame rate. For example search around for fixed physics update, that’s a similar problem and there have been some discussions on how to approach t hat.