Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7b3f79

Browse files
committed
Use range-based for loop for deleting swap chain image views
1 parent 546a4bc commit b7b3f79

22 files changed

Lines changed: 44 additions & 44 deletions

03_Drawing_a_triangle/01_Presentation/02_Image_views.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ a similar loop to destroy them again at the end of the program:
111111

112112
```c++
113113
void cleanup() {
114-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
115-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
114+
for (auto imageView : swapChainImageViews) {
115+
vkDestroyImageView(device, imageView, nullptr);
116116
}
117117

118118
...

code/command_buffers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ class HelloTriangleApplication {
134134
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
135135
vkDestroyRenderPass(device, renderPass, nullptr);
136136

137-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
138-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
137+
for (auto imageView : swapChainImageViews) {
138+
vkDestroyImageView(device, imageView, nullptr);
139139
}
140140

141141
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/depth_buffering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ class HelloTriangleApplication {
250250
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
251251
vkDestroyRenderPass(device, renderPass, nullptr);
252252

253-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
254-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
253+
for (auto imageView : swapChainImageViews) {
254+
vkDestroyImageView(device, imageView, nullptr);
255255
}
256256

257257
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/descriptor_layout.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ class HelloTriangleApplication {
212212
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
213213
vkDestroyRenderPass(device, renderPass, nullptr);
214214

215-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
216-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
215+
for (auto imageView : swapChainImageViews) {
216+
vkDestroyImageView(device, imageView, nullptr);
217217
}
218218

219219
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/descriptor_set.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ class HelloTriangleApplication {
217217
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
218218
vkDestroyRenderPass(device, renderPass, nullptr);
219219

220-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
221-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
220+
for (auto imageView : swapChainImageViews) {
221+
vkDestroyImageView(device, imageView, nullptr);
222222
}
223223

224224
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/fixed_functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class HelloTriangleApplication {
116116
void cleanup() {
117117
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
118118

119-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
120-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
119+
for (auto imageView : swapChainImageViews) {
120+
vkDestroyImageView(device, imageView, nullptr);
121121
}
122122

123123
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/framebuffers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class HelloTriangleApplication {
127127
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
128128
vkDestroyRenderPass(device, renderPass, nullptr);
129129

130-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
131-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
130+
for (auto imageView : swapChainImageViews) {
131+
vkDestroyImageView(device, imageView, nullptr);
132132
}
133133

134134
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/graphics_pipeline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class HelloTriangleApplication {
111111
}
112112

113113
void cleanup() {
114-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
115-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
114+
for (auto imageView : swapChainImageViews) {
115+
vkDestroyImageView(device, imageView, nullptr);
116116
}
117117

118118
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/graphics_pipeline_complete.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ class HelloTriangleApplication {
121121
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
122122
vkDestroyRenderPass(device, renderPass, nullptr);
123123

124-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
125-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
124+
for (auto imageView : swapChainImageViews) {
125+
vkDestroyImageView(device, imageView, nullptr);
126126
}
127127

128128
vkDestroySwapchainKHR(device, swapChain, nullptr);

code/hello_triangle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ class HelloTriangleApplication {
144144
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
145145
vkDestroyRenderPass(device, renderPass, nullptr);
146146

147-
for (size_t i = 0; i < swapChainImageViews.size(); i++) {
148-
vkDestroyImageView(device, swapChainImageViews[i], nullptr);
147+
for (auto imageView : swapChainImageViews) {
148+
vkDestroyImageView(device, imageView, nullptr);
149149
}
150150

151151
vkDestroySwapchainKHR(device, swapChain, nullptr);

0 commit comments

Comments
 (0)