Add load_asset_from_pack function

This commit is contained in:
abdelrahman committed 2023-11-04 22:29:07 +00:00
1 parent c60a9e6507
commit d85bfc0f01
2 files changed
+20

No files matched your search

+3
View File
@@ -8,6 +8,7 @@
#include "SDL_pixels.h"
#include "Window.h"
#include "aliases.h"
#include "pak.h"
#include "reusable_ids.h"
#include <stdbool.h>
@@ -46,6 +47,8 @@ void remove_object(ObjectID *id);
// ASSET MANAGEMENT API
AssetID load_asset_from_file(const char *path, AssetType type);
AssetID load_asset_from_pack(asset_pack_t *pack, const char *filename,
AssetType type);
void unload_asset(AssetID *id);
#ifdef __ANDROID__
+17
View File
@@ -207,6 +207,10 @@ void remove_object(ObjectID *id) {
}
AssetID load_asset_from_file(const char *path, AssetType type) {
if (!path) {
return INVALID_ID;
}
return type == ASSET_TYPE_IMAGE
? load_asset_to_manager(GameEngine.asset_manager, path, type,
GameEngine.window.renderer, NULL)
@@ -214,6 +218,19 @@ AssetID load_asset_from_file(const char *path, AssetType type) {
NULL);
}
AssetID load_asset_from_pack(asset_pack_t *pack, const char *filename,
AssetType type) {
if (!pack || !filename) {
return INVALID_ID;
}
return type == ASSET_TYPE_IMAGE
? load_asset_to_manager(GameEngine.asset_manager, filename, type,
GameEngine.window.renderer, pack)
: load_asset_to_manager(GameEngine.asset_manager, filename, type,
NULL, pack);
}
void unload_asset(AssetID *id) {
if (*id < 0) {
return;