# 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
- clearload
- destroydefault
- getcurrent
- getdefault
- getloaded
- new
- usecore
- vbonewsize
- vbostats

new (string name,int memsize,int restypecnt...)
  returns: (reschunk)
  creates a new resource chunk, with given sized memory pool (in megabytes),and given number of openslots per restype. The slotcount comes at the 'restyped' position,if -1 is used we will try to get the maximum still available.
  Make sure you have called destroydefault() before you use your own chunks.
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.
  Additionally we will always try to reload resources that were referenced from other reschunks.
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)
  returns: (int count,[resource table])
  returns a table with all loaded resources of the given 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.