@@ -58,18 +58,12 @@ Nous allons déplacer le code de suppression depuis `cleanup` jusqu'à `cleanupS
5858
5959``` c++ 
6060void  cleanupSwapChain () {
61-  for (size_t i = 0; i <  swapChainFramebuffers.size(); i++ ) { 
62-  vkDestroyFramebuffer (device, swapChainFramebuffers [ i ] , nullptr);
61+  for (auto framebuffer :  swapChainFramebuffers) { 
62+  vkDestroyFramebuffer (device, framebuffer , nullptr);
6363 }
6464
65-  vkFreeCommandBuffers (device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data());
66- 
67-  vkDestroyPipeline (device, graphicsPipeline, nullptr);
68-  vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
69-  vkDestroyRenderPass(device, renderPass, nullptr);
70- 
71-  for (size_t i = 0; i < swapChainImageViews.size(); i++) { 
72-  vkDestroyImageView (device, swapChainImageViews[ i] , nullptr);
65+  for (auto imageView : swapChainImageViews) { 
66+  vkDestroyImageView (device, imageView, nullptr);
7367 }
7468
7569 vkDestroySwapchainKHR (device, swapChain, nullptr);
@@ -82,6 +76,11 @@ Nous pouvons ensuite appeler cette nouvelle fonction depuis `cleanup` pour évit
8276void  cleanup () {
8377 cleanupSwapChain ();
8478
79+  vkDestroyPipeline (device, graphicsPipeline, nullptr);
80+  vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
81+ 
82+  vkDestroyRenderPass (device, renderPass, nullptr);
83+ 
8584 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { 
8685 vkDestroySemaphore (device, renderFinishedSemaphores[ i] , nullptr);
8786 vkDestroySemaphore(device, imageAvailableSemaphores[ i] , nullptr);
0 commit comments