natiny_backend_loop

C
void natiny_backend_loop(natiny_loop_fn fn, void* userdata);

Starts the main application loop. The callback is called once per frame.

natiny_loop_fn is declared in natiny.h as

C
typedef void (*natiny_loop_fn)(float dt, void* userdata);

Parameters

Name Type Description
fn natiny_loop_fn Function called every frame with delta time in seconds
userdata void* User pointer passed to the callback

Example

C
void frame(float dt, void* ud) {
    update_scene(dt, ud);
}

natiny_backend_loop(frame, &app_state);

Notes

  • On web this uses requestAnimationFrame.