diff --git a/include/vkcv/Core.hpp b/include/vkcv/Core.hpp index cf75b8e754513da774ec1841c8c4cc700b99ee2d..7d20685fc99751ebad0e2961744275b295badc15 100644 --- a/include/vkcv/Core.hpp +++ b/include/vkcv/Core.hpp @@ -81,12 +81,14 @@ namespace vkcv uint32_t m_currentSwapchainImageIndex; std::vector<vk::Framebuffer> m_TemporaryFramebuffers; + std::function<void(int, int)> m_resizeHandle; + /** * recreates the swapchain * @param[in] width new window width * @param[in] height new window hight */ - static void recreateSwapchain(int width, int height); + static void recreateSwapchain( const vk::Device& device ,int width, int height); public: /** diff --git a/projects/first_mesh/src/main.cpp b/projects/first_mesh/src/main.cpp index 107cd432e1bc902692bb5b1fa694120ddf24038b..6a4b1d01262149c86540a4e3b958665f3c931aee 100644 --- a/projects/first_mesh/src/main.cpp +++ b/projects/first_mesh/src/main.cpp @@ -14,7 +14,7 @@ int main(int argc, const char** argv) { applicationName, windowWidth, windowHeight, - false + true ); vkcv::CameraManager cameraManager(window, windowWidth, windowHeight); diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index 0b0d3a24f0398a5efa17a4c33110adabbb97c15e..486c4d5b2c56ac14ee159c9ed6892e5e1183f7d2 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -74,10 +74,6 @@ namespace vkcv const auto commandResources = createCommandResources(context.getDevice(), queueFamilySet); const auto defaultSyncResources = createSyncResources(context.getDevice()); - window.e_resize.add([&](int width, int height){ - recreateSwapchain(width,height); - }); - return Core(std::move(context) , window, swapChain, imageViews, commandResources, defaultSyncResources); } @@ -105,6 +101,8 @@ namespace vkcv m_BufferManager->init(); m_ImageManager->m_core = this; + + m_resizeHandle = window.e_resize.add( [&](int width, int height) { recreateSwapchain( this->getContext().getDevice(),width ,height ); }); } Core::~Core() noexcept { @@ -308,9 +306,8 @@ namespace vkcv return m_swapchain.getSurfaceFormat().format; } - void Core::recreateSwapchain(int width, int height) { - /* boilerplate for #34 */ - std::cout << "Resized to : " << width << " , " << height << std::endl; + void Core::recreateSwapchain( const vk::Device& device, int width, int height) { + device.waitIdle(); } void Core::submitCommands(const SubmitInfo &submitInfo, const RecordCommandFunction& record, const FinishCommandFunction& finish)