Clocks
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
Time control.
Functions
Clock* | clock_create (...) |
void | clock_destroy (...) |
bool_t | clock_frame (...) |
void | clock_reset (...) |
real64_t | clock_elapsed (...) |
Simple objects that allow us, in a comfortable way, to measure the time span between two instants. They are also useful for launching events at regular time intervals (Listing 1).
1 2 3 4 5 6 7 8 9 |
Clock *clock = clock_create(.04); for (;;) { ... if (clock_frame(clock) == TRUE) listener_event(transition, ekGUI_EVENT_ANIMATION, NULL, params, NULL, void, EvTransition, void); ... } clock_destroy(&clock); |
clock_create ()
Create a clock.
Clock* clock_create(const real64_t interval);
interval | Time interval for animation control (in seconds). |
Return
The new clock.
clock_destroy ()
Destroy the clock.
void clock_destroy(Clock **clk);
clk | Clock. Will be set to |
clock_frame ()
Detect if a new sequence in an animation has expired.
bool_t clock_frame(Clock *clk, real64_t *prev_frame, real64_t *curr_frame);
clk | Clock. |
prev_frame | Time mark of the previous instant. Only relevant if returns |
curr_frame | Time mark of the current instant. Only relevant if returns |
Return
TRUE
if the time has come to launch a new sequence. FALSE
if we have to wait.
clock_reset ()
Set the clock to 0.0.
void clock_reset(Clock *clk);
clk | Clock. |
clock_elapsed ()
Gets the time elapsed since the object was created or since the last call to clock_reset.
real64_t clock_elapsed(Clock *clk);
clk | Clock. |
Return
The number of seconds (with precision of micro-seconds 0.000001).