Namespace: dmResource
Language: C++
Type: Defold C++
File: resource.hpp
Source: engine/resource/src/dmsdk/resource/resource.hpp
Include: dmsdk/resource/resource.hpp
Functions for managing resource and resource types
Type: FUNCTION Adds a file to the resource system Any request for this path will go through any existing mounts first. If you wish to provide file overrides, please use the LiveUpdate feature for that. The file isn’t persisted between sessions.
Parameters
factory (dmResource::HFactory) - Factory handlepath (const char*) - The path of the resourcesize (uint32_t) - The size of the resource (in bytes)resource (const void*) - The resource payloadReturns
RESULT_OK (dmResource::Result) - on success.Type: FUNCTION Creates and inserts a resource into the factory
Notes
Parameters
factory (dmResource::HFactory) - Factory handlename (dmhash_t) - Resource namedata - Resource datadata_size - Resource data sizeresource (void**) - (out) Created resourceReturns
result (dmResource::Result) - RESULT_OK on successType: TYPEDEF Decrypts a file
Notes
Parameters
buffer (void*) - The input/output bufferbuffer_len (uint32_t) - The size of the buffer (in bytes)Returns
RESULT_OK - on successType: FUNCTION Get a resource from factory
Parameters
factory (dmResource::HFactory) - Factory handlepath (const char*) - Resource pathresource (void**) - (out) Created resourceReturns
result (dmResource::Result) - RESULT_OK on successType: FUNCTION Get a loaded resource from factory
Parameters
factory (dmResource::HFactory) - Factory handlepath_hash (const char*) - Resource path hashresource (void**) - (out) Created resourceReturns
result (dmResource::Result) - RESULT_OK on successType: FUNCTION Gets the normalized resource path: “/my//icon.texturec” -> “/my/icon.texturec”. “my/icon.texturec” -> “/my/icon.texturec”.
Parameters
path (const char*) - the relative dir of the resourcebuf (char*) - (out) the output of the normalizationbuf_len (uint32_t) - the size of the output bufferReturns
length (uint32_t) - the length of the output stringType: FUNCTION Returns the canonical path hash of a resource
Parameters
factory (dmResource::HFactory) - Factory handleresource (const void*) - Resourcehash (uint64_t*) - Returned hashReturns
RESULT_OK - on successType: FUNCTION Get type from extension
Parameters
factory (dmResource::HFactory) - Factory handleextension (const char*) - File extension, without leading “.” character. E.g. “ttf”type (HResourceType*) - returned type is successfulReturns
result (dmResult::Result) - RESULT_OK on successType: FUNCTION Get type from extension hash
Parameters
factory (dmResource::HFactory) - Factory handleextension_hash (const char*) - Hash of file extension, without leading “.” character. E.g. hash(“ttf”)type (HResourceType*) - returned type is successfulReturns
result (dmResult::Result) - RESULT_OK on successType: FUNCTION Get (load) a resource from factory
Parameters
factory (dmResource::HFactory) - Factory handlepath (const char*) - Resource pathext (const char*) - Resource extension. Must match the extension of the pathresource (void**) - (out) Created resourceReturns
result (dmResource::Result) - RESULT_OK on success.
RESULT_INVALID_FILE_EXTENSION if the path extension doesn’t match the required extension.Type: FUNCTION Get a loaded resource from factory
Parameters
factory (dmResource::HFactory) - Factory handlepath_hash (const char*) - Resource path hashext_hash (const char*) - Resource extension hash. Must match the extension of the path.resource (void**) - (out) Created resourceReturns
result (dmResource::Result) - RESULT_OK on success.
RESULT_INVALID_FILE_EXTENSION if the path extension doesn’t match the required extension.Type: FUNCTION Hint the preloader what to load before Create is called on the resource. The resources are not guaranteed to be loaded before Create is called. This function can be called from a worker thread.
Parameters
factory (dmResource::HResourcePreloadHintInfo) - Preloader handlename (const char*) - Resource nameReturns
result (bool) - if successfully invoking preloader.Type: FUNCTION Registers a custom resource decryption function
Parameters
decrypt_resource (dmResource::FDecryptResource) - The decryption functionType: FUNCTION Function called when a resource has been reloaded.
Parameters
factory (dmResource::HFactory) - Handle of the factory to which the callback will be registeredcallback (dmResource::FResourceReloadedCallback) - Callback function to registeruser_data (void*) - User data that toType: FUNCTION
Notes
Type: FUNCTION Release resource
Parameters
factory (dmResource::HFactory) - Factory handleresource (void*) - Resource pointerType: FUNCTION Removes a previously registered file from the resource system
Parameters
factory (dmResource::HFactory) - Factory handlepath (const char*) - The path of the resourceReturns
RESULT_OK (dmResource::Result) - on success.Type: FUNCTION Setup function pointers and context for a resource type
Notes