Skip to content

Commit e7f39a9

Browse files
committed
Fixed windows minimized bug
1 parent 4673762 commit e7f39a9

File tree

7 files changed

+18
-2
lines changed

7 files changed

+18
-2
lines changed

bookcontents/chapter-07/chapter-07.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,9 @@ We have coded all the elements required to support the proper rendering of 3D mo
687687
public class Render {
688688
...
689689
public void render(Window window, Scene scene) {
690+
if (window.getWidth() <= 0 && window.getHeight() <= 0) {
691+
return;
692+
}
690693
if (window.isResized() || this.swapChain.acquireNextImage()) {
691694
window.resetResized();
692695
resize(window);
@@ -718,7 +721,7 @@ public class Render {
718721
}
719722
```
720723

721-
In the `render` method, we first check if the window has been resized or the current swap chain image has not been acquired (because that the size of the window has changed). In this case, we reset the flag that signals that the window has been resized, call the `resize` method and update the projection matrix to adapt it to the new surface dimensions. If we cannot present the image, we just signal the window resize flag and we'll wait for the next loop to perform the process described above.
724+
In the `render` method, we first check if the size of the window is `0`. This means that the window has been minimized. In this case we do not render anything. After, we check if the window has been resized or the current swap chain image has not been acquired (because that the size of the window has changed). In this case, we reset the flag that signals that the window has been resized, call the `resize` method and update the projection matrix to adapt it to the new surface dimensions. If we cannot present the image, we just signal the window resize flag and we'll wait for the next loop to perform the process described above.
722725

723726
The new `resize` method, waits for the device and graphics queue to be idle, clean ups the swap chain resources and creates a new one. This implies the creation of new swap chain images adapted to new window size. It also invokes the `resize` method form the `ForwardRenderActivity` class. Let's review the changes required in that class.
724727

bookcontents/chapter-08/chapter-08.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,7 @@ public class Render {
14121412
}
14131413

14141414
public void render(Window window, Scene scene) {
1415+
...
14151416
if (window.isResized() || swapChain.acquireNextImage()) {
14161417
...
14171418
resize(window, scene);

booksamples/chapter-07/src/main/java/org/vulkanb/eng/graph/Render.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public void loadMeshes(MeshData[] meshDataList) {
6363
}
6464

6565
public void render(Window window, Scene scene) {
66+
if (window.getWidth() <= 0 && window.getHeight() <= 0) {
67+
return;
68+
}
6669
if (window.isResized() || swapChain.acquireNextImage()) {
6770
window.resetResized();
6871
resize(window);

booksamples/chapter-08/src/main/java/org/vulkanb/eng/graph/Render.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public void loadMeshes(MeshData[] meshDataList) {
6868
}
6969

7070
public void render(Window window, Scene scene) {
71+
if (window.getWidth() <= 0 && window.getHeight() <= 0) {
72+
return;
73+
}
7174
if (window.isResized() || swapChain.acquireNextImage()) {
7275
window.resetResized();
7376
resize(window, scene);

booksamples/chapter-09/src/main/java/org/vulkanb/eng/graph/Render.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public void loadMeshes(MeshData[] meshDataList) {
7171
}
7272

7373
public void render(Window window, Scene scene) {
74+
if (window.getWidth() <= 0 && window.getHeight() <= 0) {
75+
return;
76+
}
7477
if (window.isResized() || swapChain.acquireNextImage()) {
7578
window.resetResized();
7679
resize(window, scene);

booksamples/chapter-10/src/main/java/org/vulkanb/eng/graph/Render.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public void loadMeshes(MeshData[] meshDataList) {
7676
}
7777

7878
public void render(Window window, Scene scene) {
79+
if (window.getWidth() <= 0 && window.getHeight() <= 0) {
80+
return;
81+
}
7982
if (window.isResized() || swapChain.acquireNextImage()) {
8083
window.resetResized();
8184
resize(window, scene);

booksamples/chapter-10/src/main/java/org/vulkanb/eng/graph/geometry/GeometryRenderActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,4 @@ private void updateTextureDescriptorSet(Texture texture) {
311311
descriptorSetMap.put(textureFileName, textureDescriptorSet);
312312
}
313313
}
314-
}
314+
}

0 commit comments

Comments
 (0)