![]() |
• Resource Manager | ||||||||||||||||||||||||
|
API Links
Developer Links
|
Resource::GetDefined in:
Returns a pointer to a resource object.
C4Resources.hPrototype
Parameters
Description
The Get function returns a pointer to a resource object of the type corresponding to the template parameter of the Resource class. If the resource object already exists, then its reference count is incremented and a pointer to the existing object is returned. Otherwise, a new resource object is created and the resource data is loaded into memory (unless the kResourceDeferLoad flag is specified). If the resource data does not exist on disk, then the return value is nullptr.Each successful call to the Get function should be balanced by a matching call to the Resource::Release function.The flags parameter may be 0 or the following value.
kResourceDeferLoad flag is specified, then the resource data is not loaded, but a resource object is created and returned. Note that in this case, the return value is never nullptr, so it's not possible to determine whether the resource data exists based on the return value. The resource data can subsequently be loaded outside of the resource object using the functions of the ResourceLoader object returned by the Resource::OpenLoader function. The resource data can also be loaded (in its entirety) into the Resource object by calling the Resource::Load function.If the catalog parameter is nullptr, then the resource is loaded from the virtual catalog.When a resource is loaded from the virtual catalog and the location parameter is not nullptr, then the path stored in the ResourceLocation object is set to the path to the folder containing the resource file. If the resource was loaded from a pack file, then the path is set to that of the pack file without the extension. The resource location is not set if the kResourceDeferLoad flag is specified in the flags parameter.
Special Considerations
The Get function is normally not called directly using the Resource class template. Higher-level classes normally make calls to the Get function as part of a larger initialization procedure. The following list names some of those functions and the type of resources that they create.
See Also
|