carb::assets::CreateContextFn

Defined in carb/assets/AssetsTypes.h

using carb::assets::CreateContextFn = LoadContext *(*)(carb::datasource::IDataSource *dataSource, carb::datasource::Connection *connection, const char *path, const uint8_t *data, size_t size, const LoadParameters *loadParameters)

Loader function (member of LoaderDesc) that informs the asset type that loading a file has started and creates any load-specific context data necessary.

This function gives the programmer the option to do initial work that may be repetitive in the function calls that load the file.

The created context only exists during the loading of the asset, after the asset is loaded this context is destroyed with DestroyContextFn.

Note

This callback is optional, if it isn’t provided, in future callbacks loadContext will be nullptr. If this function is provided, DestroyContextFn should also be provided to destroy the context.

Note

This function is called in Task Context (from carb::tasking::ITasking), therefore the called function is free to await any fiber-aware I/O functions without bottlenecking the system.

Parameters
  • dataSource – The datasource the asset is being loaded from.

  • connection – The connection the asset is being loaded from.

  • path – The path of the file that is being loaded.

  • data – The data read at the asset’s uri path.

  • size – The size of the data read in bytes.

  • loadParameters – The load parameters passed to IAssets::loadAsset(), or nullptr.

Returns

A derivative of LoadContext that is passed to LoadAssetFn and CreateDependenciesFn.