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

Skip to content

Commit 382c7a3

Browse files
committed
Fix glfwDestroyWindow never being called
1 parent 0a6d0db commit 382c7a3

31 files changed

Lines changed: 67 additions & 2 deletions

03_Drawing_a_triangle/00_Setup/00_Base_code.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,15 @@ void mainLoop() {
305305
while (!glfwWindowShouldClose(window)) {
306306
glfwPollEvents();
307307
}
308+
309+
glfwDestroyWindow(window);
308310
}
309311
```
310312

311313
This code should be fairly self-explanatory. It loops and checks for events like
312314
pressing the X button until the window has been closed by the user. This is also
313-
the loop where we'll later call a function to render a single frame.
315+
the loop where we'll later call a function to render a single frame. Once the
316+
window is closed, we need to clean up resources by destroying it.
314317

315318
When you run the program now you should see a window titled `Vulkan` show up
316319
until the application is terminated by closing the window. Now that we have the

03_Drawing_a_triangle/03_Drawing/02_Rendering_and_presentation.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ void mainLoop() {
1010
glfwPollEvents();
1111
drawFrame();
1212
}
13+
14+
glfwDestroyWindow(window);
1315
}
1416

1517
...
@@ -319,7 +321,7 @@ may still be going on. Cleaning up resources while that is happening is a bad
319321
idea.
320322
321323
To fix that problem, we should wait for the logical device to finish operations
322-
before exiting `mainLoop`:
324+
before exiting `mainLoop` and destroying the window:
323325
324326
```c++
325327
void mainLoop() {
@@ -329,6 +331,8 @@ void mainLoop() {
329331
}
330332
331333
vkDeviceWaitIdle(device);
334+
335+
glfwDestroyWindow(window);
332336
}
333337
```
334338

05_Uniform_buffers/00_Descriptor_layout_and_buffer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ void mainLoop() {
265265
}
266266

267267
vkDeviceWaitIdle(device);
268+
269+
glfwDestroyWindow(window);
268270
}
269271

270272
...

code/base_code.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class HelloTriangleApplication {
9494
while (!glfwWindowShouldClose(window)) {
9595
glfwPollEvents();
9696
}
97+
98+
glfwDestroyWindow(window);
9799
}
98100
};
99101

code/command_buffers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ class HelloTriangleApplication {
179179
while (!glfwWindowShouldClose(window)) {
180180
glfwPollEvents();
181181
}
182+
183+
glfwDestroyWindow(window);
182184
}
183185

184186
void createInstance() {

code/depth_buffering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ class HelloTriangleApplication {
293293
}
294294

295295
vkDeviceWaitIdle(device);
296+
297+
glfwDestroyWindow(window);
296298
}
297299

298300
static void onWindowResized(GLFWwindow* window, int width, int height) {

code/descriptor_layout.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ class HelloTriangleApplication {
259259
}
260260

261261
vkDeviceWaitIdle(device);
262+
263+
glfwDestroyWindow(window);
262264
}
263265

264266
static void onWindowResized(GLFWwindow* window, int width, int height) {

code/descriptor_set.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ class HelloTriangleApplication {
264264
}
265265

266266
vkDeviceWaitIdle(device);
267+
268+
glfwDestroyWindow(window);
267269
}
268270

269271
static void onWindowResized(GLFWwindow* window, int width, int height) {

code/fixed_functions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ class HelloTriangleApplication {
171171
while (!glfwWindowShouldClose(window)) {
172172
glfwPollEvents();
173173
}
174+
175+
glfwDestroyWindow(window);
174176
}
175177

176178
void createInstance() {

code/framebuffers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class HelloTriangleApplication {
174174
while (!glfwWindowShouldClose(window)) {
175175
glfwPollEvents();
176176
}
177+
178+
glfwDestroyWindow(window);
177179
}
178180

179181
void createInstance() {

0 commit comments

Comments
 (0)