A Rive .riv file is a binary container of artboards, animations,
state machines, view models, and assets. The C++ API gives you
read-only access to that container (File, Artboard) and mutable instances
you can advance and draw (ArtboardInstance, StateMachineInstance).
Importing a File
File is reference-counted (rcp<File>). It owns the parsed object graph and
the assets imported in-band. Keep it alive for as long as any artboard
instance derived from it is alive.
The Factory* you pass in is responsible for constructing every
RenderPath, RenderPaint, RenderImage, font, and audio source the
file produces. When using Rive’s GPU renderer, this is your
RenderContext. When using a custom renderer, it is your Factory
implementation.
Determinism
A static flag that forces a fixed RNG seed and timestamp-driven scrolling for
all subsequent loads. Useful for golden-image tests and frame-by-frame
captures.
Querying Artboards
Artboard* returned by these accessors is read-only metadata — do not
advance or draw it. To play an artboard, create an instance.
Instancing
Each call returns a fresh, independent copy. You can have many instances of
the same artboard playing at once — each with its own state machine, its own
data bindings, and its own layout.
Creating a State Machine
StateMachineInstance is the unit of playback in C++ — what you advance
each frame, draw, and forward pointer events to.
Sizing & Layout
Artboards have an intrinsic size set in the editor, plus an optional layout
mode (Yoga-driven). For non-layout fits the artboard stays at its intrinsic
size; for Fit::layout you drive width and height yourself:
Artboard::bounds() returns the current ‘rect’ — feed it to computeAlignment
to map artboard-space into your viewport.
File Lifetime
Reference-counted ownership keeps lifetimes simple:
Always destroy Rive objects before tearing down your RenderContext —
they hold references to GPU resources owned by the context.