summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-09-08 17:01:22 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-09-08 17:01:22 -0400
commit2003fa27db17094f472cbad5b0d3ff42aea9df9c (patch)
tree15726b942f6cf30f57858bdf571c3080d752aa07
parent08cdf72330276a4b4883fea41c3ada1087800a41 (diff)
EntityType cleanup
-rw-r--r--src/entities.cpp15
-rw-r--r--src/entities.hpp5
2 files changed, 18 insertions, 2 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index fb2bc60..2887074 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -17,6 +17,7 @@ void EntityType_Load(EntityType &et) {
// TODO grBinds.vkDescriptorSet
cgltf_options options{};
+ // TODO allocator
cgltf_data *gltfData = nullptr;
cgltf_result result = cgltf_parse(&options, asset->ptr, asset->size, &gltfData);
assert(result == cgltf_result_success);
@@ -36,6 +37,20 @@ void EntityType_Load(EntityType &et) {
vkAllocateMemory(vkDevice, &vkMemoryAllocateInfo, vkAllocator, &grBinds.deviceMemory);
// TODO bind buffers to memory
+
+ // cleanup
+ cgltf_free(gltfData);
}
+}
+void EntityType_Teardown() {
+ long entityTypeCount = globalEntityTypes.Count();
+ for (long i = 0; i < entityTypeCount; ++i) {
+ if (globalEntityTypes[i].modelFile == nullptr) continue;
+ auto *grBinds = ECS_GetGrBinds(globalEntityTypes[i].entityHandle);
+ vkDestroyPipelineLayout(vkDevice, grBinds->vkPipelineLayout, vkAllocator);
+ vkDestroyBuffer(vkDevice, grBinds->vertexBuffer, vkAllocator);
+ vkDestroyBuffer(vkDevice, grBinds->vertexBuffer, vkAllocator);
+ vkDestroyBuffer(vkDevice, grBinds->vertexBuffer, vkAllocator);
+ }
}
diff --git a/src/entities.hpp b/src/entities.hpp
index 5e80616..005c83c 100644
--- a/src/entities.hpp
+++ b/src/entities.hpp
@@ -9,13 +9,14 @@
#include "window.hpp"
struct EntityType {
- char *modelFile = nullptr;
- char entityTypeCode[16] = {'\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'};
+ const char *modelFile = nullptr;
+ const char *entityTypeCode = nullptr;
EntityHandle entityHandle = EntityHandle_MAX;
VkPipelineLayoutCreateInfo *vkPipelineLayoutCreateInfo = nullptr;
};
void EntityType_Init();
void EntityType_Load(EntityType et);
+void EntityType_Teardown();
#endif /* PKE_ENTITIES_HPP */