#ifndef PKE_ASSET_MANAGER_HPP #define PKE_ASSET_MANAGER_HPP #include "pk.h" #include #include struct AssetHandle : public pk_handle { }; constexpr AssetHandle AssetHandle_MAX = AssetHandle{ pk_handle_MAX_constexpr }; TypeSafeInt_constexpr(AssetLoadingState, uint8_t, 0xFF); TypeSafeInt_constexpr(AssetType, uint8_t, 0xFF); const int64_t AssetKeyLength = 16; using AssetKey = char[AssetKeyLength]; const AssetLoadingState PKE_ASSET_LOADING_STATE_UNLOADED = AssetLoadingState {0}; const AssetLoadingState PKE_ASSET_LOADING_STATE_LOADING = AssetLoadingState {1}; const AssetLoadingState PKE_ASSET_LOADING_STATE_LOADED = AssetLoadingState {2}; const AssetLoadingState PKE_ASSET_LOADING_STATE_FAILED = AssetLoadingState {3}; const AssetType PKE_ASSET_TYPE_UNSET = AssetType {0x00}; const AssetType PKE_ASSET_TYPE_SHADER = AssetType {0x01}; const AssetType PKE_ASSET_TYPE_MODEL = AssetType {0x02}; const AssetType PKE_ASSET_TYPE_TEXTURE = AssetType {0x04}; const AssetType PKE_ASSET_TYPE_AUDIO = AssetType {0x08}; const AssetType PKE_ASSET_TYPE_FONT = AssetType {0x10}; const AssetType PKE_ASSET_TYPE_ALL = AssetType {0xFF}; constexpr int64_t EngineDefinedAssetCount = 4; extern AssetKey EngineDefinedAssets[EngineDefinedAssetCount]; struct Asset { AssetHandle handle{}; AssetKey key = {'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'}; const char *basePath = nullptr; int64_t size = 0; void *ptr = nullptr; std::future future; int8_t referenceCount = 0; AssetLoadingState state = PKE_ASSET_LOADING_STATE_UNLOADED; AssetType type = PKE_ASSET_TYPE_UNSET; }; void AM_Init(); AssetHandle AM_Register(AssetKey key, AssetType type, const void *data, int64_t size, std::size_t alignment); AssetHandle AM_Register(const char *path, AssetType type); AssetHandle AM_Register(AssetKey key, AssetType type, const char *path); void AM_Release(AssetHandle assetHandle); const Asset *AM_Get(AssetHandle assetHandle); const AssetHandle AM_GetHandle(AssetKey key); uint64_t AM_GetBucketCount(); Asset *AM_GetAssets(pk_handle_bucket_index_T bucketIndex, pk_handle_item_index_T &itemCount); void AM_Teardown(); void AM_DebugPrint(); #endif /* PKE_ASSET_MANAGER_HPP */