HGE:Tutorials:Resource Manager
From GDWiki
[edit] Resource Manager
The resource manager is a way of defining textures, sprites, sounds, and other items that your application makes use of. hgeresourceManager is an HGE helper class that automates creation of complex resource objects and their management in memory.
[edit] Resource script files
Resource script files are used with hgeResourceManager helper class to define complex resources. They are just plain text files containing resource definitions. A resource script file consists of commands separated by whitespace characters ('\t', '\n', '\r' or ' '). If a semicolon (';') is encountered, the rest of the line is treated as a comment and is not parsed. All the commands and names are case sensitive.
The command format is:
ResourceType ResourceName [ : BaseResourceName ] { Parameter1=Value1 Parameter2=Value2 ... ParameterN=ValueN }
Example: specifying a texture
Texture myTexture { file=picture1.png }
For now, just create a blank text file named resource.res and place it in the same directory as the main.cpp file.
[edit] Using the Resource Manager
To use the resource manager, include the hgeresource.h file and declare myRes, which will be used when we need to access our resources.
#include <hgeresource.h> hgeResourceManager* myRes;
Inside WinMain(), but before the hge->System_Start() call, we initialize myRes with the name of the resource file we will be using.
myRes = new hgeResourceManager("resource.res");
Be sure to delete myRes before the hge->System_Shutdown() call.
delete myRes;
Right now, the resource file (resource.res) is empty. An explanation of loading sprites from a resource file will be covered in the next section.
You can download the source file for this tutorial here: Tutorial 2 source
Next Section: Video

