Added support for desktop full screen with pillarboxing and letterboxing
and started adding some comments to the code
This commit is contained in:
1 parent
ffaa6e5ae7
commit
e110b1f2fd
10 files changed
+351
-77
No files matched your search
+22
-1
@@ -46,6 +46,10 @@ struct asset_manager {
|
||||
};
|
||||
|
||||
size_t hash_path(const char *path) {
|
||||
/**
|
||||
* Converts a string into a numerical index using a simple hashing algorithm
|
||||
*/
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
for (size_t j = 0; path[j]; ++j) {
|
||||
@@ -125,6 +129,11 @@ void remove_id_node(IDNodeList *node_list, AssetID id) {
|
||||
|
||||
AssetID get_asset_id_from_id_node(AssetManager *am, IDNodeList *node_list,
|
||||
const char *path) {
|
||||
/**
|
||||
* Checks to see if an asset with the same path exists and returns the ID of
|
||||
* that asset if it exists, or an INVALID_ID otherwise
|
||||
*/
|
||||
|
||||
if (node_list->node_count == 0) {
|
||||
return INVALID_ID;
|
||||
}
|
||||
@@ -184,9 +193,14 @@ AssetID load_asset_to_manager(AssetManager *am, const char *path,
|
||||
}
|
||||
|
||||
++(am->user_counter[existing_id]);
|
||||
|
||||
return existing_id;
|
||||
}
|
||||
|
||||
if (am->count + 1 == MAX_ASSET_COUNT && am->deleted_count == 0) {
|
||||
return INVALID_ID;
|
||||
}
|
||||
|
||||
Asset asset = {};
|
||||
bool loaded = true;
|
||||
|
||||
@@ -363,7 +377,14 @@ void destroy_asset_manager(AssetManager **am) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < (*am)->count; ++i) {
|
||||
// TODO (Abdelrahman): Figure out if there is a better way to remove all of
|
||||
// the existing assets without having to loop for the maximum number of
|
||||
// assets allowed.
|
||||
for (size_t i = 0; i < MAX_ASSET_COUNT; ++i) {
|
||||
if (!(*am)->assets[i].path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(*am)->user_counter[i] = 0;
|
||||
|
||||
size_t hash_index = hash_path((*am)->assets[i].path);
|
||||
|
||||
Reference in new issue
Block a user