close window on game end

This commit is contained in:
2025-05-18 11:36:14 +02:00
parent 0e8ee9eacd
commit 56f2aa3c56
2 changed files with 9 additions and 1 deletions

View File

@@ -431,6 +431,7 @@ public class DDDView extends GameAdapter implements CommandSender {
@Override
public void onGameEnd() {
openPopup("End");
this.window.stop();
}
@Override

View File

@@ -64,6 +64,8 @@ public class Window implements Closeable {
private ImInt detailLevel = new ImInt(10);
private ImBoolean pixelatedFrame = new ImBoolean(true);
private boolean shouldBeClosed = false;
public Window(Renderer renderer, World world, Camera camera) {
this.renderer = new Renderer();
this.cam = camera;
@@ -280,7 +282,7 @@ public class Window implements Closeable {
// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
while (!glfwWindowShouldClose(window)) {
while (!shouldBeClosed && !glfwWindowShouldClose(window)) {
newFrame();
@@ -304,8 +306,13 @@ public class Window implements Closeable {
}
}
public void stop() {
shouldBeClosed = true;
}
@Override
public void close() throws IOException {
shouldBeClosed = true;
this.renderer.close();
}