![]() TGE Version 1.5.2 | |||||||||||||||||||||||
| |||||||||||||||||||||||
ResourceInstance Class Reference#include <resManager.h>
Inheritance diagram for ResourceInstance: ![]() Detailed DescriptionThe base class for all resources.This must be subclassed to implement a resource that can be managed. Creating a new resource type is very simple. First, you need a function which can create a new instance of the resource given a stream:
ResourceInstance* constructBitmapBMP(Stream &stream) { GBitmap *bmp = new GBitmap; if(bmp->readMSBmp(stream)) return bmp; else { delete bmp; return NULL; } } Then you need to register the extension of your resource type with the resource manager:
ResourceManager->registerExtension(".bmp", constructBitmapBMP); And, of course, you need to provide a subclass of ResourceInstance:
class GBitmap : ResourceInstance { ... whatever you need for your resource goes in here ... } ResourceInstance imposes very few requirements on you as the resource type implementor. All you "have" to provide is a destructor to deallocate whatever storage your resource might allocate. The ResourceManager will ensure that there is only one instance of the ResourceInstance for each file, and that it is only destroyed when no more references to it remain.
Constructor & Destructor Documentation
Field DocumentationPointer to the ResourceObject that stores all our book-keeping data.
|