summaryrefslogtreecommitdiff
path: root/src/asset-manager.hpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-05-20 21:08:19 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-05-20 21:08:19 -0400
commit40d69e7e40a18865a31af2f55efcde369d36dbbb (patch)
tree95a2cbbe40192183d13f846f3444b32d7e12b0e8 /src/asset-manager.hpp
parentead9e484db969a880470d625b1884aced296e722 (diff)
pke: serialization overhaul + embedded assets
Diffstat (limited to 'src/asset-manager.hpp')
-rw-r--r--src/asset-manager.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/asset-manager.hpp b/src/asset-manager.hpp
index ec98d08..5106375 100644
--- a/src/asset-manager.hpp
+++ b/src/asset-manager.hpp
@@ -12,6 +12,7 @@ constexpr AssetHandle AssetHandle_MAX = AssetHandle{ pk_handle_MAX_constexpr };
TypeSafeInt_constexpr(AssetLoadingState, uint8_t, 0xFF);
TypeSafeInt_constexpr(AssetType, uint8_t, 0xFF);
+TypeSafeInt_constexpr(AssetFlags, uint8_t, 0xFF);
const int64_t AssetKeyLength = 16;
using AssetKey = char[AssetKeyLength];
@@ -29,6 +30,9 @@ const AssetType PKE_ASSET_TYPE_AUDIO = AssetType {0x08};
const AssetType PKE_ASSET_TYPE_FONT = AssetType {0x10};
const AssetType PKE_ASSET_TYPE_ALL = AssetType {0xFF};
+const AssetFlags PKE_ASSET_FLAGS_NONE = AssetFlags {0x00};
+const AssetFlags PKE_ASSET_FLAGS_MEM_STATIC = AssetFlags {0x01};
+
constexpr int64_t EngineDefinedAssetCount = 8;
extern AssetKey EngineDefinedAssets[EngineDefinedAssetCount];
@@ -37,17 +41,19 @@ struct Asset {
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;
+ const void *ptr = nullptr;
std::future<void> future;
int8_t referenceCount = 0;
AssetLoadingState state = PKE_ASSET_LOADING_STATE_UNLOADED;
AssetType type = PKE_ASSET_TYPE_UNSET;
+ AssetFlags flags = PKE_ASSET_FLAGS_NONE;
};
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);
+AssetHandle AM_Register_Static(AssetKey key, AssetType type, const void *data, int64_t size);
void AM_Release(AssetHandle assetHandle);
const Asset *AM_Get(AssetHandle assetHandle);
const AssetHandle AM_GetHandle(AssetKey key);