From 2003fa27db17094f472cbad5b0d3ff42aea9df9c Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Fri, 8 Sep 2023 17:01:22 -0400 Subject: EntityType cleanup --- src/entities.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/entities.cpp') 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); + } } -- cgit v1.2.3