Class: reschunk

resdata is separated into resource chunks, each chunk has a memory pool, and can hold a specific amount of resources. Every chunk also generates Vertex/IndexBufferObjects for the models if needed.

If you want to clear resources and keep others active during runtime, you will need multiple resource chunks. When a chunk is destroyed it will however keep the resources that are still needed by other chunks. Since the 'unique resource' lookup on loading is done over all resources and not individually to save memory, this was needed. The separation in ResourceChunks can be done only once until the built in maximums are hit. On startup a core chunk is generated, only to holdall resources that the engine itself needs. A default chunk is allocated (8 megs) afterwards. If you destroy the default, you must set up all yourself.
The user can specify what should happen when a chunk is full and a resource wants to be loaded in it. you can either throw an error, or just fill the next chunk.

Resources are classified as 'direct' loaded or 'indirect' indirect are those resources that are loaded by other resources. When a ResourceChunk is reloaded only 'directlys' are loaded again, of course with their dependants This is done to prevent collecting unused resources, when e.g. materials or other scripts have changed some textures might not be needed anymore.

Methods:

Method overview:


activate (reschunk)
returns: ()
makes this the active reschunk, all new resources will be loaded into it.
clearload (reschunk,int indirection)
returns: ()
clears all resources in this chunk.Then reloads resources with a smaller or equal indirection depth than the given, or none if indirection is negative.About indirection: eg. a model loads a texture and a material, both have a ind. depth of 1, the material loads a texture and shader, both with depth of 2. The shader finally loads another texture with depth of 3. So we have 3 textures with depths of 1,2,3 and 1 material with depth of 1, and 1 shader with depth of 1. The model has level 0, and to do a complete clear you pass -1.
Additionally we will always try to reload resources that were referenced from other reschunks.
create (string name,int mbsize,|int kbsize|, float restypecnt...)
returns: (reschunk)
creates a new resource chunk, with given sized memory pool (in megabytes, kbsize optional),and given number of openslots per restype. The slotcount comes at the 'restyped' position. When a count is < zero it is used as multiplied of the total slots. So -1 tries to use all slots, -0.5 half and so on. Of course if more slots are already in use, than queried for, we will use the maximum of those still available.
Make sure you have called destroydefault() before you use your own chunks.
destroydefault ()
returns: ()
destroys the default chunk. If you want to do your own handling you must call this right at start, before you create new reschunks.
getcurrent ()
returns: (reschunk)
returns current active chunk.
getdefault ()
returns: (reschunk)
returns default chunk (or first if default was destroyed).
getloaded (reschunk, int restype, [int nth])
returns: (int count/resource)
returns either number of all loaded resources or the nth resource of that type.
usecore (boolean)
returns: ()
uses core memory chunk (very small and reserved for luxinia core modules, you should never use this).
vbonewsize ([int vbo,int ibo])
returns: ([int vbo,int ibo])
returns or sets the size of new allocated Vertex/IndexBufferObjects in KiloBytes. Be aware that using a size greater 2048, means that only vertex64 can be addressed via shorts.
vbostats (reschunk)
returns: (string,string)
returns strings on vertexbufferobjects useage statistics for this chunk.