Module radiant_rs::utils [] [src]

Optional utility features. These may eventually be moved into the example code or a separate library.

Structs

LoopState

Passed to renderloop() and mainloop() callbacks.

Periodic

A generic interval, testable for elapsation. !todo Is that even a word?

Rng

A very simple, seedable random number generator based on sin(). It is provided to simplify experimentation with the library but not suitable for applications that require good quality random numbers.

Functions

approach

Mutates source_value to approach target_value at the rate_of_change. Effectively a lerp that writes to source.

lerp

Interpolates between values. Returns source_value for ratio = 0.0 and target_value for ratio = 1.0.

mainloop

Main loop helper function. Provides callbacks for game state changes and rendering. Calls state_callback multiple times if the actual render_callback call interval exceeds the given interval. Both callbacks receive a LoopState object containing frame delta and fps data.

max

Returns the greater of the two given values, ignoring edge-cases like NaN.

min

Returns the smaller of the two given values, ignoring edge-cases like NaN.

renderloop

Render loop helper function. Provides given callback with frame delta and fps data. This is a more simple alternative to the main loop helper function.