These functions allow you to record a simulation for later playback. More...
Typedefs | |
| typedef struct b2Recording | b2Recording |
| Opaque handle for a recording buffer. | |
Functions | |
| b2Recording * | b2CreateRecording (int byteCapacity) |
| Create a recording buffer. | |
| void | b2DestroyRecording (b2Recording *recording) |
| Destroy a recording buffer and free its memory. | |
| const uint8_t * | b2Recording_GetData (const b2Recording *recording) |
| Get a pointer to the recorded bytes, for saving to a file or transmitting. | |
| int | b2Recording_GetSize (const b2Recording *recording) |
| Get the number of recorded bytes. | |
| void | b2World_StartRecording (b2WorldId worldId, b2Recording *recording) |
Begin recording the world into recording. | |
| void | b2World_StopRecording (b2WorldId worldId) |
| Stop recording. | |
| bool | b2Recording_SaveToFile (const b2Recording *recording, const char *path) |
| Save a recording buffer to a file. | |
| b2Recording * | b2CreateRecordingFromFile (const char *path) |
| Load a recording from a file into a new recording buffer. | |
These functions allow you to record a simulation for later playback.
| typedef struct b2Recording b2Recording |
Opaque handle for a recording buffer.
Create one, hand it to b2World_StartRecording, then save its bytes and destroy it. The buffer grows as the world records into it.
| b2Recording * b2CreateRecording | ( | int | byteCapacity | ) |
Create a recording buffer.
The buffer grows on demand. byteCapacity pre-sizes it to avoid reallocations during a known-length session. Pass 0 for a small default.
| b2Recording * b2CreateRecordingFromFile | ( | const char * | path | ) |
Load a recording from a file into a new recording buffer.
Convenience wrapper over your own file I/O. Destroy the result with b2DestroyRecording.
| const uint8_t * b2Recording_GetData | ( | const b2Recording * | recording | ) |
Get a pointer to the recorded bytes, for saving to a file or transmitting.
Valid until the next recording call or b2DestroyRecording.
| bool b2Recording_SaveToFile | ( | const b2Recording * | recording, |
| const char * | path ) |
Save a recording buffer to a file.
Convenience wrapper over your own file I/O.
| void b2World_StartRecording | ( | b2WorldId | worldId, |
| b2Recording * | recording ) |
Begin recording the world into recording.
Serializes a snapshot of the current world as the seed, then logs every mutating call. Call at a step boundary, before or after creating bodies. Start before the first step to capture the whole session. No effect if already recording or if the world is locked.
| worldId | The world to record |
| recording | A recording buffer from b2CreateRecording |
| void b2World_StopRecording | ( | b2WorldId | worldId | ) |
Stop recording.
The recording buffer keeps its bytes. Save and destroy it yourself.
| worldId | The world being recorded |