Skip to content

Commit

Permalink
Added unload map function appart from the destroy one
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed May 19, 2024
1 parent d312aad commit c1a4cee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/sk_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ void sk_map_add_element(sk_darray *es,

void sk_map_load(sk_map *m);

void sk_map_unload(sk_map *m);

void sk_map_draw(sk_map *m);
12 changes: 9 additions & 3 deletions src/sk_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ sk_map sk_map_create(sk_map_kind kind) {
}

void sk_map_destroy(sk_map *m) {
for (u32 i = 0; i < m->elements.curr_len; ++i) {
sk_map_element_destroy(&((sk_map_element *) m->elements.data)[i]);
}
sk_map_unload(m);
sk_darray_destroy(&m->elements);
UnloadShader(m->pbr_shader);
}
Expand Down Expand Up @@ -94,6 +92,14 @@ void sk_map_load(sk_map *m) {
(Vector3) { 0, 2.5f, -16 });
}

void sk_map_unload(sk_map *m) {
sk_map_element e = {0};
while (m->elements.curr_len) {
if (!sk_darray_pop(&m->elements, &e)) SK_LOG_ERROR("sk_map_unload :: unable to delete element");
sk_map_element_destroy(&e);
}
}

void sk_map_draw(sk_map *m) {
for (u32 i = 0; i < m->elements.curr_len; ++i) {
sk_map_element_draw(&((sk_map_element *) m->elements.data)[i]);
Expand Down

0 comments on commit c1a4cee

Please sign in to comment.