Added RAII vulkan instance destructor
This commit is contained in:
parent
66af7fc1e8
commit
c3b623384f
3 changed files with 20 additions and 5 deletions
|
|
@ -15,6 +15,8 @@ private:
|
||||||
|
|
||||||
void createGraphicsPipeline(const std::string &vertFilepath,
|
void createGraphicsPipeline(const std::string &vertFilepath,
|
||||||
const std::string &fragFilepath);
|
const std::string &fragFilepath);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace yave
|
} // namespace yave
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
#include "yave_vulkan_instance.hpp"
|
#include "yave_vulkan_instance.hpp"
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
namespace yave {
|
namespace yave {
|
||||||
|
|
||||||
YaveVulkanInstance::YaveVulkanInstance() { createInstance(); }
|
YaveVulkanInstance::YaveVulkanInstance() { createInstance(); }
|
||||||
|
YaveVulkanInstance::~YaveVulkanInstance() { destroyInstance(); }
|
||||||
|
|
||||||
void YaveVulkanInstance::createInstance() {
|
void YaveVulkanInstance::createInstance() {
|
||||||
VkApplicationInfo appInfo{};
|
VkApplicationInfo appInfo{};
|
||||||
|
|
@ -32,4 +34,8 @@ void YaveVulkanInstance::createInstance() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YaveVulkanInstance::destroyInstance() {
|
||||||
|
vkDestroyInstance(this->instance, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace yave
|
} // namespace yave
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,15 @@ class YaveVulkanInstance {
|
||||||
|
|
||||||
void createInstance();
|
void createInstance();
|
||||||
|
|
||||||
public:
|
void destroyInstance();
|
||||||
YaveVulkanInstance();
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Delete Copy constructors
|
||||||
|
// This class should match one to one with vulkan instances
|
||||||
|
YaveVulkanInstance(const YaveVulkanInstance&) = delete;
|
||||||
|
YaveVulkanInstance &operator=(const YaveVulkanInstance &) = delete;
|
||||||
|
|
||||||
|
YaveVulkanInstance();
|
||||||
|
~YaveVulkanInstance();
|
||||||
};
|
};
|
||||||
} // namespace yave
|
} // namespace yave
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue