Namespace: dmResource
Language: C++
Type: Defold C++
File: resource_gen.hpp
Source: engine/resource/src/dmsdk/resource/resource_gen.hpp
Include: dmsdk/resource/resource_gen.hpp
Functions for managing 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 (HResourceFactory) - 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 (ResourceResult) - RESULT_OK on successType: MACRO Declare and register new resource type to the engine. This macro is used to declare the resource type callback functions used by the engine to communicate with the extension.
Examples
Register a new type:
#include
#include
static ResourceResult MyResourceTypeScriptCreate(const ResourceCreateParams* params) {}
static ResourceResult MyResourceTypeScriptDestroy(const ResourceDestroyParams* params) {}
static ResourceResult MyResourceTypeScriptRecreate(const ResourceRereateParams* params) {}
struct MyContext
{
// ...
};
static ResourceResult RegisterResourceTypeBlob(HResourceTypeRegisterContext ctx, HResourceType type)
{
// The engine.cpp creates the contexts for our built in types.
// Here we register a custom type
MyContext* context = new MyContext;
ResourceTypeSetContext(type, (void*)context);
ResourceTypeSetCreateFn(type, MyResourceTypeScriptCreate);
ResourceTypeSetDestroyFn(type, MyResourceTypeScriptDestroy);
ResourceTypeSetRecreateFn(type, MyResourceTypeScriptRecreate);
}
static ResourceResult DeregisterResourceTypeBlob(ResourceTypeRegisterContext& ctx)
{
MyContext** context = (MyContext*)ResourceTypeGetContext(type);
delete *context;
}
DM_DECLARE_RESOURCE_TYPE(ResourceTypeBlob, "blobc", RegisterResourceTypeBlob, DeregisterResourceTypeBlob);
Type: FUNCTION Function called when a resource has been reloaded.
Type: TYPEDEF Encrypts a resource in-place
Parameters
buffer (void*) - The input/output bufferbuffer_len (uint32_t) - The size of the buffer (in bytes)Returns
RESULT_OK - on successType: FUNCTION Function called when a resource has been reloaded.
Type: FUNCTION Get a resource from factory
Parameters
factory (HResourceFactory) - Factory handlename (const char*) - Resource nameresource (void**) - Created resourceReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Get a resource from factory
Parameters
factory (HResourceFactory) - Factory handlename (dmhash_t) - Resource nameresource (void**) - Created resourceReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Get resource descriptor from resource (name)
Parameters
factory (HResourceFactory) - Factory handlepath (dmhash_t) - Resource pathdescriptor (HResourceDescriptor*) - Returned resource descriptorReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Get resource descriptor from resource (name)
Parameters
factory (HResourceFactory) - Factory handlepath_hash (dmhash_t) - Resource path hashdescriptor (HResourceDescriptor*) - Returned resource descriptorReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Returns the canonical path hash of a resource
Parameters
factory (HResourceFactory) - Factory handleresource (void*) - The resource pointerhash (dmhash_t*) - (out) The path hash of the resourceReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Get raw resource data. Unregistered resources can be loaded with this function. If successful, the returned resource data must be deallocated with free()
Parameters
factory (HResourceFactory) - Factory handlename (dmhash_t) - Resource nameresource (void**) - Created resourceresource_size (uint32_t*) - Resource sizeReturns
result (ResourceResult) - RESULT_OK on successType: TYPEDEF Holds information about a currently loaded resource.
Type: TYPEDEF Resource factory handle. Holds references to all currently loaded resources.
Type: TYPEDEF Holds information about preloading resources
Type: TYPEDEF Holds information about a currently loaded resource.
Type: TYPEDEF Resource factory handle. Holds references to all currently loaded resources.
Type: TYPEDEF Holds information about preloading resources
Type: TYPEDEF Represents a resource type, with a context and type functions for creation and destroying a resource.
Type: TYPEDEF Holds the resource types, as well as extra in engine contexts that can be shared across type functions.
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
preloader (dmResource::HResourcePreloadHintInfo) - Preloader handlepath (const char*) - Resource pathReturns
result (bool) - if successfully invoking preloader.Type: FUNCTION Release resource
Notes
Parameters
factory (HResourceFactory) - Factory handleresource (void*) - Resource pointerType: FUNCTION Removes a previously registered file from the resource system
Parameters
factory (HResourceFactory) - Factory handlepath (const char*) - The path of the resourceReturns
result (ResourceResult) - RESULT_OK on successType: 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 (HResourceFactory) - 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 (ResourceResult) - RESULT_OK on successType: FUNCTION Parameters to ResourceCreate function of the resource type
Type: FUNCTION Parameters to ResourceDestroy function of the resource type
Type: FUNCTION Get a resource from factory
Parameters
factory (HResourceFactory) - Factory handlename (const char*) - Resource nameresource (void**) - Created resourceReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Get a resource from factory
Parameters
factory (HResourceFactory) - Factory handlename (dmhash_t) - Resource nameresource (void**) - Created resourceReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Returns the canonical path hash of a resource
Parameters
factory (HResourceFactory) - Factory handleresource (void*) - The resource pointerhash (dmhash_t*) - (out) The path hash of the resourceReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Get raw resource data. Unregistered resources can be loaded with this function. If successful, the returned resource data must be deallocated with free()
Parameters
factory (HResourceFactory) - Factory handlename (dmhash_t) - Resource nameresource (void**) - Created resourceresource_size (uint32_t*) - Resource sizeReturns
result (ResourceResult) - RESULT_OK on successType: FUNCTION Parameters to ResourcePostCreate function of the resource type
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
preloader (dmResource::HResourcePreloadHintInfo) - Preloader handlepath (const char*) - Resource pathReturns
result (bool) - if successfully invoking preloader.Type: FUNCTION Parameters to ResourcePreload function of the resource type
Type: FUNCTION Parameters to ResourceRecreate function of the resource type
Type: FUNCTION Registers a custom resource decryption function
Parameters
decrypt_resource (dmResource::FDecryptResource) - The decryption functionType: FUNCTION Release resource
Notes
Parameters
factory (HResourceFactory) - Factory handleresource (void*) - Resource pointerType: FUNCTION Parameters to ResourceReloaded function of the resource type
Type: FUNCTION Parameters to ResourceReloaded function of the resource type
Type: FUNCTION Removes a previously registered file from the resource system
Parameters
factory (HResourceFactory) - Factory handlepath (const char*) - The path of the resourceReturns
result (ResourceResult) - RESULT_OK on successType: ENUM ResourceResult
Members
RESOURCE_RESULT_OKRESOURCE_RESULT_INVALID_DATARESOURCE_RESULT_DDF_ERRORRESOURCE_RESULT_RESOURCE_NOT_FOUNDRESOURCE_RESULT_MISSING_FILE_EXTENSIONRESOURCE_RESULT_ALREADY_REGISTEREDRESOURCE_RESULT_INVALRESOURCE_RESULT_UNKNOWN_RESOURCE_TYPERESOURCE_RESULT_OUT_OF_MEMORYRESOURCE_RESULT_IO_ERRORRESOURCE_RESULT_NOT_LOADEDRESOURCE_RESULT_OUT_OF_RESOURCESRESOURCE_RESULT_STREAMBUFFER_TOO_SMALLRESOURCE_RESULT_FORMAT_ERRORRESOURCE_RESULT_CONSTANT_ERRORRESOURCE_RESULT_NOT_SUPPORTEDRESOURCE_RESULT_RESOURCE_LOOP_ERRORRESOURCE_RESULT_PENDINGRESOURCE_RESULT_INVALID_FILE_EXTENSIONRESOURCE_RESULT_VERSION_MISMATCHRESOURCE_RESULT_SIGNATURE_MISMATCHRESOURCE_RESULT_UNKNOWN_ERRORType: FUNCTION Resource type creator desc byte size declaration. The registered description data passeed to ResourceRegisterTypeCreatorDesc must be of at least this size.
Type: ENUM ResourceResult
Members
RESOURCE_RESULT_OKRESOURCE_RESULT_INVALID_DATARESOURCE_RESULT_DDF_ERRORRESOURCE_RESULT_RESOURCE_NOT_FOUNDRESOURCE_RESULT_MISSING_FILE_EXTENSIONRESOURCE_RESULT_ALREADY_REGISTEREDRESOURCE_RESULT_INVALRESOURCE_RESULT_UNKNOWN_RESOURCE_TYPERESOURCE_RESULT_OUT_OF_MEMORYRESOURCE_RESULT_IO_ERRORRESOURCE_RESULT_NOT_LOADEDRESOURCE_RESULT_OUT_OF_RESOURCESRESOURCE_RESULT_STREAMBUFFER_TOO_SMALLRESOURCE_RESULT_FORMAT_ERRORRESOURCE_RESULT_CONSTANT_ERRORRESOURCE_RESULT_NOT_SUPPORTEDRESOURCE_RESULT_RESOURCE_LOOP_ERRORRESOURCE_RESULT_PENDINGRESOURCE_RESULT_INVALID_FILE_EXTENSIONRESOURCE_RESULT_VERSION_MISMATCHRESOURCE_RESULT_SIGNATURE_MISMATCHRESOURCE_RESULT_UNKNOWN_ERROR