Skip to content

Commit 54324ac

Browse files
committed
Don't terminate GLFW when last window is closed
1 parent 9da3380 commit 54324ac

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/flitter/render/window/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def release():
439439

440440
class Window(ProgramNode):
441441
WINDOW_FRAGMENT_SOURCE = TemplateLoader.get_template('window.frag')
442-
Windows = []
442+
Windows = None
443443

444444
def __init__(self, screen=0, fullscreen=False, vsync=False, offscreen=False, **kwargs):
445445
super().__init__(None)
@@ -470,8 +470,6 @@ def release(self):
470470
if self.window is not None:
471471
glfw.destroy_window(self.window)
472472
Window.Windows.remove(self)
473-
if not Window.Windows:
474-
glfw.terminate()
475473
logger.debug("{} closed", self.name)
476474
self.window = None
477475
self.engine = None
@@ -488,11 +486,12 @@ def create(self, engine, node, resized, *, opengl_es=False, **kwargs):
488486
title = node.get('title', 1, str, "Flitter")
489487
if self.window is None:
490488
self.engine = engine
491-
if not Window.Windows:
489+
if Window.Windows is None:
492490
ok = glfw.init()
493491
if not ok:
494492
raise RuntimeError("Unable to initialize GLFW")
495493
logger.debug("GLFW version: {}", glfw.get_version_string().decode('utf8'))
494+
Window.Windows = []
496495
glfw.window_hint(glfw.CONTEXT_CREATION_API, glfw.EGL_CONTEXT_API if opengl_es else glfw.NATIVE_CONTEXT_API)
497496
glfw.window_hint(glfw.CLIENT_API, glfw.OPENGL_ES_API if opengl_es else glfw.OPENGL_API)
498497
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)

0 commit comments

Comments
 (0)