Resource Loader. More...
#include <deResourceLoader.h>
Public Types | |
| enum | eResourceTypes { ertAnimation, ertFont, ertImage, ertModel, ertRig, ertSkin, ertSound, ERT_COUNT } |
Resource types. More... | |
Public Member Functions | |
Constructors and Destructors | |
| deResourceLoader (deEngine *engine) | |
| Creates a new resource loader. | |
| ~deResourceLoader () | |
| Cleans up the resource loader. | |
Management | |
| void | Update () |
| Called once a frame to update tasks. | |
| void | AddLoadRequest (const char *path, int resourceType) |
| Add request for loading a resource. | |
| bool | NextFinishedRequest (deResourceLoaderInfo &info) |
| Retrieves informations about the next finished request. | |
| bool | GetPauseLoading () const |
| Determines if loading is paused. | |
| void | PauseLoading () |
| Pause loading. | |
| void | ResumeLoading () |
| Resumes loading. | |
Resource Loader.
Loads resources asynchronously. To load a resource a scripting module places a load request. Requests are processed using a pool of worker threads and once finished are promoted to the retrieval queue. The scripting module has to query the resource loader during each frame update for new entries in the retrieval queue. Once there are no more entries in the queue the scripting module can carry on with the fram update. Requests for the same resource are grouped together and placed in the retrieval queue only once. The scripting module is responsible to track multiple requests for the same resource. A resource is uniquely identified by the path and resource type. This informations are also returned in retrieval queries and can be used to match up with one or more requests made by the game scripts. The pause loading flag indicates if loading of new resources is put at hold. This is used during crash recovery breaks to avoid threads loading resources in the background causing havok. Changing the flag to false blocks until all threads still loading a resource have finished.
| deResourceLoader::deResourceLoader | ( | deEngine * | engine ) |
Creates a new resource loader.
| deResourceLoader::~deResourceLoader | ( | ) |
Cleans up the resource loader.
| void deResourceLoader::AddLoadRequest | ( | const char * | path, |
| int | resourceType | ||
| ) |
Add request for loading a resource.
| bool deResourceLoader::GetPauseLoading | ( | ) | const [inline] |
Determines if loading is paused.
| bool deResourceLoader::NextFinishedRequest | ( | deResourceLoaderInfo & | info ) |
Retrieves informations about the next finished request.
Returns true if a finished request has been retrieved or false if there are no more finished requests. After returing true the requests has been removed.
| void deResourceLoader::PauseLoading | ( | ) |
Pause loading.
This call blocks until all threads with loading in progress have finished.
| void deResourceLoader::ResumeLoading | ( | ) |
Resumes loading.
| void deResourceLoader::Update | ( | ) |
Called once a frame to update tasks.
Assigns tasks to waiting threads and promotes finished tasks to the retrieval queue. Called by the game engine before the scripting module does frame updates.
1.7.2