Task execution

Is there a way to control when a Task is executed? I’m trying to timestamp the beginning and end of a frame, for framerate computations.

Frame rate computation??? There is built in frame rate computation. I believe it’s FrameRateMeter, best part is that it provides you with a string

Is there any way to retrieve the value FPS value from FrameRateMeter? I checked the API, and there doesn’t seem to be something along the lines of getValue, or getFrameRate or getFPS.

Also, do text nodes use the depth buffer? I can’t seem to set the display order so that the fps is always on top.

globalClock.getAverageFrameRate() is the value you’re looking for.

You can control when a task is executed by setting sort = value when you create the task. Smaller (or negative) sort values execute first, larger (more positive) sort values execute last. Use ‘print taskMgr’ to see what the current task list is and their sort values. (However, if you wanted to calculate the frame rate yourself, you shouldn’t do it with a task at the beginning and a task at the end of the frame. That would overlook the time spent between frames. Instead, you should use just one task, and remember the time from one frame to the next–that’s how the globalClock does it.)

TextNodes use the depth buffer if they’re told to use it, just like any other node. But the depth buffer is only part of the equation when you’re trying to set the render order. Incidentally, the default frame rate meter (enabled by setting ‘show-frame-rate-meter 1’ in your Config.prc file, or by calling base.setFrameRateMeter(True)) is already configured to draw always on top.

David

Editing the config-prc seems to work, but base.setFrameRateMeter(True) seems to have no effect. Is the value returned by globalClock.getAverageFrameRate() the same value used in the FrameRateMeter?

I don’t know how that can have no effect, since the show-frame-rate-meter variable is itself implemented by calling base.setFrameRateMeter(True) if it is set.

Yes, the frame rate meter displays the same numeric value reported by globalClock.getAverageFrameRate().

David

Odd… I can’t seem to get that call to work. I’m using this instead:

loadPrcFileData("", "show-frame-rate-meter  #t") 

This should be fine. Thanks.