Media Management
Blitz3D Forums/Blitz3D Programming/Media Management
| ||
The following will go on the code archives once we have a few testers. Feedback is appreciated. Basically it allows you to store media in memory for faster use. I can see this being used in case where a resource is used repeatedly. How to: include "media manager.bb" Media_Mesh_Get("myfile.b3d") ; loads from disk Media_Mesh_Get("myfile.b3d") ; loads from memory Media_Mesh_Get("myfile.b3d") ; loads from memory You can have a function that will load a level each time called, within you can call all the media manager functions. Level 1 Media_Reset() test1 = Media_Mesh_Get("myfile.b3d") ; loads from disk test2 = Media_Mesh_Get("myfile.b3d") ; loads from memory test 3 = Media_Mesh_Get("myotherfile.b3d") ; loads from disk Media_FreeUnused() Free Level1 frees test1, test2, test3 Level2 Media_Reset() Media_Mesh_Get("myfile.b3d") ; loads from memory Media_FreeUnused() ;will free file ""myotherfile.b3d", but keeps "myfile.b3d" If you have few resources then you don't need to use Media_Reset and Media_FreeUnused() that way you can almost instantly load levels. Use Media_Clear() if your levels are huge, that way it clears memory usage by freeing everything that is in the media manager. I suggest you time your load time using this functions compared to using manual loadmesh and loadanimmesh commands. ml = millisecs() load level debuglog "Load time: " + str(millisecs() - ml) media manager.bb |