![]() |
RAMSES Documentation
27.0.130
Information for RAMSES users and developers
|
Objects of the RAMSES Client API live in different scopes, which determine
Scope: RamsesClient Instance
Scope: Scene Instance
Scope: Animation System
Object lifecycle is an important topic in any C++ framework. In the case of RAMSES, creation and destruction is strict, straightforward and simple, but leaves the responsibility of object deletion in some cases to the user.
As described in the Scopes chapter, the ownership of objects is defined by their scope. A MeshNode is owned by a Scene, which is owned by a RamsesClient. If a RamsesClient is destroyed, all of its scenes will be destroyed automatically, which in turn will destroy the MeshNodes in those scenes and so on. This implicit destruction done by RAMSES is limited to this case only, ie. when the 'owner' is destroyed then all the objects created within this owner are destroyed and any pointers to those become invalid.
There is no reference counting of any sort therefore RAMSES will not automatically destroy an object if it is not used by any other object and therefore user is responsible for destroying unused content to free up resources. Creation and destruction of objects can cause performance hit on both client and renderer so it is recommended to consider some caching strategy on the application side.
The RAMSES API is designed to check most errors on usage - for example trying to create TextureSampler using a write-only RenderBuffer will result in error. The error message will appear in log and/or can be retrieved by using RamsesClient::getStatusMessage and passing the status code returned from the API call.
It is highly recommended to check the status of every RAMSES API call, at least in debug configuration. See RAMSES Validation to find out other ways of checking the state of RAMSES objects.