moderngl_window.timers
- class moderngl_window.timers.base.BaseTimer[source]
A timer controls the time passed into the the render function. This can be used in creative ways to control the current time such as basing it on current location in an audio file.
All methods must be implemented.
- property fps: float
Get the current frames per second.
- property fps_average: float
get the average fps since the timer was started
- property is_paused: bool
The pause state of the timer
- Type:
bool
- property is_running: bool
Is the timer currently running?
- Type:
bool
- next_frame() tuple[float, float][source]
Get timer information for the next frame.
- Returns:
The frametime and current time
- Return type:
tuple[float, float]
- stop() tuple[float, float][source]
Stop the timer. Should only be called once when stopping the timer.
- Returns:
tuple[float, float]> Current position in the timer, actual running duration
- property time: float
Get or set the current time. This can be used to jump around in the timeline.
- Returns:
The current time in seconds
- Return type:
float
- class moderngl_window.timers.clock.Timer(**kwargs: Any)[source]
Bases:
BaseTimerTimer based on python
time.- property fps: float
Get the current frames per second.
- property fps_average: float
The average fps since the timer was started
- property is_paused: bool
The pause state of the timer
- Type:
bool
- property is_running: bool
Is the timer currently running?
- Type:
bool
- 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]
- start() None[source]
Start the timer by recoding the current
time.time()preparing to report the number of seconds since this timestamp.
- 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]
- property time: float
Get or set the current time. This can be used to jump around in the timeline.
- Returns:
The current time in seconds