Handle Game Window closing by closing connection and being prepared for a new Connection

This commit is contained in:
Lukas 2020-12-09 15:13:04 +01:00
parent 4f26204355
commit 7466f01589
2 changed files with 9 additions and 0 deletions

View File

@ -76,6 +76,11 @@ public class GameWindow {
glPopMatrix();
glfwSwapBuffers(openGLWindow.getWindowId());
}
// The window was closed, close everything
currentConnection.disconnect();
currentConnection = null;
running = false;
openGLWindow.close();
}
public static void pause() {

View File

@ -49,6 +49,10 @@ public class OpenGLWindow {
gluPerspective(fovY, width / (float) height, 0.1f, 500f);
}
public void close() {
glfwDestroyWindow(windowId);
}
public void init() {
GLFWErrorCallback.createPrint(System.err).set();