clock.Timer

moderngl_window.timers.clock.Timer[source]

Timer based on python time.

Methods

Timer.__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Timer.next_frame() → Tuple[float, float][source]

Get the time and frametime for the next frame. This should only be called once per frame.

Returns:

current time and frametime

Return type:

Tuple[float, float]

Timer.start()[source]

Start the timer by recoding the current time.time() preparing to report the number of seconds since this timestamp.

Timer.pause()[source]

Pause the timer by setting the internal pause time using time.time()

Timer.toggle_pause()[source]

Toggle the paused state

Timer.stop() → Tuple[float, float][source]

Stop the timer. Should only be called once when stopping the timer.

Returns:

Current position in the timer, actual running duration

Return type:

Tuple[float, float]

Attributes

Timer.is_paused

The pause state of the timer

Type:

bool

Timer.is_running

Is the timer currently running?

Type:

bool

Timer.time

Get or set the current time. This can be used to jump around in the timeline.

Returns:

The current time in seconds