Skip to content

Commit

Permalink
Small code reorganisation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanhogg committed Sep 18, 2024
1 parent 9797483 commit 0349059
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/flitter/render/window/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ def release(self):

def create(self, engine, node, resized, *, opengl_es=False, **kwargs):
super().create(engine, node, resized, opengl_es=opengl_es, **kwargs)
self._keys = {}
self._pointer_state = None
new_window = False
screen = node.get('screen', 1, int, self.default_screen)
fullscreen = node.get('fullscreen', 1, bool, self.default_fullscreen) if self._visible else False
Expand Down Expand Up @@ -492,6 +494,9 @@ def create(self, engine, node, resized, *, opengl_es=False, **kwargs):
glfw.window_hint(glfw.CENTER_CURSOR, glfw.FALSE)
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
self.window = glfw.create_window(self.width, self.height, title, None, Window.Windows[0].window if Window.Windows else None)
glfw.set_key_callback(self.window, self.key_callback)
glfw.set_cursor_pos_callback(self.window, self.pointer_movement_callback)
glfw.set_mouse_button_callback(self.window, self.pointer_button_callback)
self._title = title
Window.Windows.append(self)
new_window = True
Expand Down Expand Up @@ -534,21 +539,15 @@ def create(self, engine, node, resized, *, opengl_es=False, **kwargs):
glfw.set_window_title(self.window, title)
self._title = title
glfw.make_context_current(self.window)
self._keys = {}
self._pointer_state = None
if new_window:
self.glctx = moderngl.create_context(require=300 if opengl_es else 330, context=GLFWLoader)
self.glctx.gc_mode = 'context_gc'
if self._visible:
logger.debug("{} opened on screen {}", self.name, screen)
else:
logger.debug("{} opened off-screen", self.name)
self.glctx = moderngl.create_context(require=300 if opengl_es else 330, context=GLFWLoader)
self.glctx.gc_mode = 'context_gc'
logger.debug("OpenGL info: {GL_RENDERER} {GL_VERSION}", **self.glctx.info)
logger.trace("{!r}", self.glctx.info)
if self._visible:
glfw.set_key_callback(self.window, self.key_callback)
glfw.set_cursor_pos_callback(self.window, self.pointer_movement_callback)
glfw.set_mouse_button_callback(self.window, self.pointer_button_callback)
zero = self.glctx.texture((1, 1), 4, dtype='f1')
zero.write(bytes([0, 0, 0, 0]))
if opengl_es:
Expand Down

0 comments on commit 0349059

Please sign in to comment.