Setting FrameRate

Sort of on the same lines of my last post, I think there should be an easy way of setting the framrate of a panda app without having to write your own version of the igLoop task (unless there is something im missing).

By default, Panda runs as fast as it can. If you want the frame rate to be higher, you have to do less work each frame. :slight_smile:

But there are options to artificially lower the frame rate, or clamp it to a particular max frame rate, or similar options. Is this what you want to do?


Yeah, I was more interested in clamping the framerate

There are several options for mucking with the frame rate. See ClockObject::set_frame_rate() in the API documentation for specifics. You can also do this in the config file; for instance, to force to frame rate to 25Hz, you could do:

clock-mode forced
clock-frame-rate 25

And to universally degrade your frame rate by 10%, you could do:

clock-mode degrade
clock-degrade-factor 1.10

However, I just realized that we are conspicuously missing a “limited” option, which would allow the clock to run at normal speed except up to a specified frame rate. So I just added this option, which will be available in a future version of Panda. When it is available, you will be able to specify an upper limit to your frame rate, say 50 Hz, like this:

clock-mode limited
clock-frame-rate 50

Of course, in the meantime, you may also be interested in the sync-video option:

sync-video 1

which tells Panda to request that the video flip occurs in sync with your video refresh rate, effectively limiting your frame rate to your video rate (usually 60 to 85 Hz). It may also be necessary to enable this option in your driver control panel. This is actually the preferred way to run Panda, since it provides a tighter integration with the video hardware and prevents needlessly consuming more CPU than you need.

If your only purpose is to allow multiple Panda applications to run on one CPU without starving each other out, you may also be interested in:

client-sleep 0.01