Runtime Lifecycle¶
The zividomelive facade owns Processing hook registration, manager initialization, scene updates, rendering, input forwarding, pause/resume, and terminal disposal.
Initialization States¶
InitState |
Meaning |
|---|---|
NOT_INITIALIZED |
Instance exists; setup() has not completed |
SETUP_COMPLETE |
Basic services exist; renderer managers wait for a valid post-setup OpenGL context |
MANAGERS_READY |
Camera, renderers, local texture backend, and controls are ready |
READY |
Reserved 1.x enum value for future lifecycle expansion |
Typical sequence:
constructor
-> register pre/draw/post/input/dispose hooks
setup()
-> target frame rate, OpenGL diagnostics, hints, OutputManager, splash, fallback scene
first post()
-> CameraManager, output and preview renderers, Syphon/Spout preparation, ControlManager
-> MANAGERS_READY
initializeManagers() is public for 1.x compatibility, but ordinary sketches rely on the registered post() hook. Duplicate setup() calls are ignored.
Processing Hooks¶
| Hook | Responsibility |
|---|---|
pre() |
Update shared OrbitCamera, then call active Scene.update() once |
draw() |
Render required targets, send outputs, composite preview, draw controls |
post() |
Lazily initialize managers once after Processing setup |
keyEvent() |
Global shortcuts, then active-scene forwarding |
mouseEvent() |
Optional scene camera, Standard camera, then active scene |
controlEvent() |
Internal panel handling, then active scene |
dispose() / stop() |
Terminal cleanup |
Do not call or forward these hooks manually from a sketch.
Scene Ownership¶
SceneManager is the active-scene authority:
- the first registered scene is activated and receives
setupScene(); - activating a different scene disposes the leaving scene before setting up the arriving scene;
- selecting the active scene again is a no-op;
- inactive scenes that were never activated have not entered setup/dispose ownership;
clearScenes()disposes the active scene and clears registrations;- replacing a manager preserves a transferred active instance and otherwise disposes old ownership.
StandardRenderer instances are synchronized with the current scene after ownership changes.
Pause and Resume¶
pause() records which outputs were publishing, stops output services, and gates update/render work. resume() reinitializes required managers when necessary and attempts to restore the previously enabled publications.
Backend restoration can fail independently. Query OutputState and getOutputFailureReason() rather than assuming a successful native restart.
Terminal Disposal¶
dispose() is idempotent and terminal. It:
- marks the facade disposed;
- releases splash and ControlP5 resources;
- shuts down NDI, Syphon, and Spout;
- disposes preview and output render targets;
- clears scene ownership;
- disposes camera state;
- shuts down the shared
ThreadManager; - unregisters Processing callbacks.
After disposal, setup, scene changes, rendering, and manager initialization are ignored.
Thread Boundaries¶
- Processing and OpenGL work remains on the Processing thread.
Scene.sceneRender()must not create its own draw lifecycle around the provided target.- NDI CPU conversion and sending use a dedicated worker with bounded shutdown.
- Library background tasks should use
ThreadManager; examples may own executors only when they also own and release their lifecycle.
Error Recovery¶
Partial manager initialization rolls back allocated resources and returns to SETUP_COMPLETE instead of advancing to a ready state. A later valid initialization attempt can retry.
Syphon/Spout publication errors disable publication without immediately destroying their prepared backend. NDI initialization failure marks the backend unavailable; another explicit enable request retries.
See Scene Management, Event Handling, and External Integration.