Skip to main content

Time

Query time information and control how it elapses.

Summary

Functions

Name
floattime() const
Returns the time in seconds since the creation of the Context.
floatdelta_time() const
Returns an estimate of the time that elapses between two update() calls.
voidtime_perceived_as_realtime()
Sets the time mode as realtime.
voidtime_perceived_as_constant_delta_time(float framerate)
Sets the time mode as constant delta time.
voidframerate_synced_with_monitor()
Makes sure that the framerate is adapted to your monitor: it will be 60 fps if you have a 60 Hertz monitor (which is the most common), or 120 fps if you have a 120 Hertz monitor, etc.
voidframerate_as_high_as_possible()
Removes any limit on the framerate. update() will be called as fast as possible.
voidframerate_capped_at(float framerate)
Keeps the framerate at the given value.

Functions

time()

float time() const;

Returns the time in seconds since the creation of the Context.

delta_time()

float delta_time() const;

Returns an estimate of the time that elapses between two update() calls.

time_perceived_as_realtime()

void time_perceived_as_realtime();

Sets the time mode as realtime.

This means that what is returned by time() and delta_time() corresponds to the actual time that elapsed in the real world. This is ideal when you want to do realtime animation and interactive sketches.

time_perceived_as_constant_delta_time()

void time_perceived_as_constant_delta_time(float framerate);

Sets the time mode as constant delta time.

This means that what is returned by time() and delta_time() corresponds to an ideal world where there is exactly 1/framerate seconds between each updates. This is ideal when you are exporting a video and don't want the long export time to influence your animation. framerate is expressed in frames per second

framerate_synced_with_monitor()

void framerate_synced_with_monitor();

Makes sure that the framerate is adapted to your monitor: it will be 60 fps if you have a 60 Hertz monitor (which is the most common), or 120 fps if you have a 120 Hertz monitor, etc.

This is the default framerate mode.

framerate_as_high_as_possible()

void framerate_as_high_as_possible();

Removes any limit on the framerate. update() will be called as fast as possible.

framerate_capped_at()

void framerate_capped_at(float framerate);

Keeps the framerate at the given value.


Updated on 2024 October 24