SilverLining
|
This class is used whenever SilverLining needs to load textures, data files, or shaders from mass storage; you may extend this class to override our default use of POSIX filesystem calls with your own resource management if you wish. More...
#include <ResourceLoader.h>
Public Member Functions | |
ResourceLoader () | |
Constructor. | |
virtual | ~ResourceLoader () |
Virtual destructor; frees the memory of the resource path string. | |
void SILVERLINING_API | SetResourceDirPath (const char *path) |
Sets the path to the SilverLining resources folder, which will be pre-pended to all resource filenames passed into LoadResource(). | |
const char *SILVERLINING_API | GetResourceDirPath () const |
Retrieves the path set by SetResourceDirPath(). | |
void SILVERLINING_API | SetRendererDLLDirPath (const char *path) |
Sets the path to the SilverLining renderer DLL's, normally located within the VC*/win32 or VC*/x64 subdiretories of the resources directory. | |
const char *SILVERLINING_API | GetRendererDLLDirPath () const |
Retrieves the path set by SetRendererDLLDirPath(), or the default resources path if it was not called. | |
virtual bool SILVERLINING_API | LoadResource (const char *pathName, char *&data, unsigned int &dataLen, bool text) |
Load a resource from mass storage; the default implementation uses the POSIX functions fopen(), fread(), and fclose() to do this, but you may override this method to load resources however you wish. | |
virtual void SILVERLINING_API | FreeResource (char *data) |
Frees the resource data memory that was returned from LoadResource(). | |
virtual bool SILVERLINING_API | GetFilesInDirectory (const char *pathName, SL_VECTOR(SL_STRING)&dirContents) |
Retrieves a list of file names within the directory path specified (relative to the resource path specified with SetResourceDirPath(). | |
virtual bool SILVERLINING_API | ResourceTimeStamp (const char *fileName, time_t &timeStamp, const char *resourcePathToUse) |
Time stamp of the resource in question. | |
This class is used whenever SilverLining needs to load textures, data files, or shaders from mass storage; you may extend this class to override our default use of POSIX filesystem calls with your own resource management if you wish.
If you have your own system of packed files, you can include SilverLining's resources directory into it and implement your own ResourceLoader to access our resources within your pack files.
Custom ResourceLoader classes should be passed into Atmosphere::SetResourceLoader() after constructing the Atmosphere class. The Atmosphere maintains a static instance of ResourceLoader that is shared across all Atmosphere objects.
If you choose to implement your own resource management scheme, you'll need to take care with the rendering DLL's found under the VC6, VC7, VC8, and VC9 directories of the SilverLining resource folder. Windows can only load DLL's directly from a file, so you'll need to exclude these DLL's from your pack files and leave them loose in the resources directory. Alternately, you may eliminate the DLL's by statically linking the renderer you want into the SilverLining libraries themselves. See the "Overview of SilverLining" section of the documentation for more information.
|
virtual |
Frees the resource data memory that was returned from LoadResource().
The data pointer will be invalid following this call.
|
virtual |
Retrieves a list of file names within the directory path specified (relative to the resource path specified with SetResourceDirPath().
pathName | The path to the directory underneath the resources directory. The path to the resources directory will be pre-pended to this path. |
dirContents | A reference that will receive a vector of strings of the file names found inside this path, if any. |
|
virtual |
Load a resource from mass storage; the default implementation uses the POSIX functions fopen(), fread(), and fclose() to do this, but you may override this method to load resources however you wish.
The caller is responsible for calling FreeResource() when it's done consuming the resource data in order to free its memory.
pathName | The path to the desired resource, relative to the location of the resources folder previously specified in SetResourceDirPath(). |
data | A reference to a char * that will return the resource's data upon a successful load. |
dataLen | A reference to an unsigned int that will return the number of bytes loaded upon a successful load. |
text | True if the resource is a text file, such as a shader. If true, a terminating null character will be appended to the resulting data and the file will be opened in text mode. |
void SILVERLINING_API SilverLining::ResourceLoader::SetRendererDLLDirPath | ( | const char * | path | ) |
Sets the path to the SilverLining renderer DLL's, normally located within the VC*/win32 or VC*/x64 subdiretories of the resources directory.
If you want to build and manage your own renderer DLL's in a separate location, call this to specify their location. To retain default behavior, do not call this at all.
void SILVERLINING_API SilverLining::ResourceLoader::SetResourceDirPath | ( | const char * | path | ) |
Sets the path to the SilverLining resources folder, which will be pre-pended to all resource filenames passed into LoadResource().
This path is also used to locate the renderer DLL's inside the SilverLining resources folder. It should be called after constructing the ResourceLoader and before calling LoadResource().