Loading multiple scenes - fastest way?
3 posters
Loading multiple scenes - fastest way?
In my application I have several, very different scenes which happen as a sequence (i mean that they never interleave, once I am done with one, I can destroy it and load the other). I would like each to have its own sio2 file and would like to know what is the best way to cleanly unload a scene and be ready to load another
michele.balistreri- Posts : 5
Join date : 2008-10-21
Re: Loading multiple scenes - fastest way?
sio2ResourceUnloadAll( sio2->_SIO2resource );
This will literally destroy everything and restore back the resource manager to its initial stage... you can also use the sio2ResourceUnload function with one of the follow parameters:
Each of them will delete from the resource manager everything that have been allocated for a proper type. If you have resources that you want to keep because they are shared or? I suggest you implement your own unloading routine and add (ex:) a custom tag to the object or resource to avoid to be deleted etc... SIO2 provide you everything that you need to implement this type of mechanism, checkout the sio2ResourceUnload function for more information.
Hope this help,
This will literally destroy everything and restore back the resource manager to its initial stage... you can also use the sio2ResourceUnload function with one of the follow parameters:
- Code:
typedef enum
{
SIO2_OBJECT = 0,
SIO2_MATERIAL,
SIO2_LAMP,
SIO2_CAMERA,
SIO2_IMAGE,
SIO2_SOUNDBUFFER,
SIO2_SCRIPT,
SIO2_VIDEO,
SIO2_SOUND,
SIO2_WIDGET,
SIO2_PHYSIC,
SIO2_SENSOR,
SIO2_EMITTER,
SIO2_MIST,
SIO2_FONT,
SIO2_RESOURCE_ALL
} SIO2_RESOURCE_TYPE;
Each of them will delete from the resource manager everything that have been allocated for a proper type. If you have resources that you want to keep because they are shared or? I suggest you implement your own unloading routine and add (ex:) a custom tag to the object or resource to avoid to be deleted etc... SIO2 provide you everything that you need to implement this type of mechanism, checkout the sio2ResourceUnload function for more information.
Hope this help,
Re: Loading multiple scenes - fastest way?
Is it possible that there is a problem when loading a scene with physics (the scene itself is ok and works as expected) and then unloading everything with sio2ResourceUnloadAll() and then loading another scene (which is also ok)? I get an error in sio2_physic.cc - bad access at:
btSoftRigidDynamicsWorld seems to be null - any ideas?
Greetings,
- Code:
_SIO2physic->_btSoftRigidDynamicsWorld->addRigidBody( _SIO2object->_btRigidBody );
btSoftRigidDynamicsWorld seems to be null - any ideas?
Greetings,
charlierby- Posts : 27
Join date : 2008-10-17
Re: Loading multiple scenes - fastest way?
Heuuuuuuu.... yeah man... the physic world is also destroyed... just recreate one with sio2PhysicInit() or avoid unloading it when you are flushing the resources...
Re: Loading multiple scenes - fastest way?
thx for your help
charlierby- Posts : 27
Join date : 2008-10-17
Re: Loading multiple scenes - fastest way?
Another thing that you can do but this is considered as "advanced" is:
Maintain multiple handle to _SIO2resource, and load your scene in another thread making sure that the resource handle that you load is assigned to the main sio2 context. Then in the main thread when everything is ready GenMatrix & GenIds (since they are the only commands that uses GL).
Like that you can load another scene while still rendering and only when ready you can switch the SIO2resource handles to render/unload.
The only thing that you need to pay attention is: When a new resource is created it will automatically be added to the resource handle assigned to the sio2 handle. ( I know Im kinda repeating myself but that's important )
Maintain multiple handle to _SIO2resource, and load your scene in another thread making sure that the resource handle that you load is assigned to the main sio2 context. Then in the main thread when everything is ready GenMatrix & GenIds (since they are the only commands that uses GL).
Like that you can load another scene while still rendering and only when ready you can switch the SIO2resource handles to render/unload.
The only thing that you need to pay attention is: When a new resource is created it will automatically be added to the resource handle assigned to the sio2 handle. ( I know Im kinda repeating myself but that's important )
Similar topics
» resetting scenes, sio2 resource files, and multiple levels
» How to switch scenes?
» Need help with multiple textures
» rendering multiple resources
» SIO2Splash fade - not fading with multiple render windows
» How to switch scenes?
» Need help with multiple textures
» rendering multiple resources
» SIO2Splash fade - not fading with multiple render windows
Permissions in this forum:
You cannot reply to topics in this forum