From 57496aea2c3e782415509e0274d9e1494a3c5f67 Mon Sep 17 00:00:00 2001 From: Lillian Salehi Date: Wed, 16 Oct 2024 07:28:13 -0500 Subject: [PATCH] fix cleanup function, at todo for broken indice buffer. --- src/entrypoint.cpp | 12 ++++++------ src/graphics/buffers.cpp | 2 +- src/graphics/model.cpp | 11 +++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/entrypoint.cpp b/src/entrypoint.cpp index 738671b..24171c0 100644 --- a/src/entrypoint.cpp +++ b/src/entrypoint.cpp @@ -1,4 +1,5 @@ #include "entrypoint.h" +#include "global.h" VkInstance vulkaninstance; @@ -83,14 +84,13 @@ void mainLoop() { void cleanup() { render_present::Render::cleanupSwapChain(); - texture_libs::Texture::createTextureSampler(); - texture_libs::Texture::destroyTextureImage(); - buffers_libs::Buffers::destroyUniformBuffer(); - buffers_libs::Buffers::destroyDescriptorPool(); - vkDestroyDescriptorSetLayout(Global::device, Global::descriptorSetLayout, nullptr); graphics_pipeline::Graphics::destroyGraphicsPipeline(); graphics_pipeline::Graphics::destroyRenderPass(); - + buffers_libs::Buffers::destroyUniformBuffer(); + buffers_libs::Buffers::destroyDescriptorPool(); + texture_libs::Texture::destroyTextureSampler(); + texture_libs::Texture::destroyTextureImage(); + vkDestroyDescriptorSetLayout(Global::device, Global::descriptorSetLayout, nullptr); buffers_libs::Buffers::destroyBuffers(); render_present::Render::destroyFenceSemaphores(); graphics_pipeline::Graphics::destroyCommandPool(); diff --git a/src/graphics/buffers.cpp b/src/graphics/buffers.cpp index b109bea..8ba41b3 100644 --- a/src/graphics/buffers.cpp +++ b/src/graphics/buffers.cpp @@ -200,7 +200,7 @@ namespace buffers_libs { Global::UniformBufferObject ubo{}; ubo.time = time; // Modify the model projection transformation to rotate around the Z over time. - ubo.model = glm::rotate(glm::mat4(1.0f), glm::radians(30.0f), glm::vec3(0.0f, 0.0f, 1.0f)); + ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(30.0f), glm::vec3(0.0f, 0.0f, 1.0f)); // Modify the view transformation to look at the object from above at a 45 degree angle. // This takes the eye position, center position, and the up direction. ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)); diff --git a/src/graphics/model.cpp b/src/graphics/model.cpp index c35b1a2..2618eb9 100644 --- a/src/graphics/model.cpp +++ b/src/graphics/model.cpp @@ -23,11 +23,14 @@ namespace modellib { if(!reader.Error().empty()) { throw std::runtime_error(reader.Error()); } + if(!reader.Warning().empty()) { + throw std::runtime_error(reader.Warning()); + } } auto& attrib = reader.GetAttrib(); auto& shapes = reader.GetShapes(); - auto& materials = reader.GetMaterials(); + //auto& materials = reader.GetMaterials(); for (const auto& shape : shapes) { for (const auto& index : shape.mesh.indices) { @@ -38,19 +41,19 @@ namespace modellib { attrib.vertices[3 * index.vertex_index + 1], attrib.vertices[3 * index.vertex_index + 2] }; - + + //TODO: Major fix here, running anything but the viking room OBJ crashes on texcoord assignment! vertex.texCoord = { attrib.texcoords[2 * index.texcoord_index + 0], 1.0f - attrib.texcoords[2 * index.texcoord_index + 1] }; - vertex.color = {1.0f, 1.0f, 1.0f}; if (uniqueVertices.count(vertex) == 0) { uniqueVertices[vertex] = static_cast(Global::vertices.size()); Global::vertices.push_back(vertex); } - + Global::indices.push_back(uniqueVertices[vertex]); } }