From 17988753966fea964e85c34c114af8ce2d5468c3 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 10 Feb 2021 14:48:00 -0800 Subject: [PATCH] Call Window.init_mgl_context and reorder Window.__init__ --- manimlib/scene/scene.py | 3 ++- manimlib/window.py | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index ac3915fa..60cd5fad 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -8,6 +8,7 @@ from functools import wraps from tqdm import tqdm as ProgressDisplay import numpy as np import time +import moderngl from IPython.terminal.embed import InteractiveShellEmbed from manimlib.animation.animation import prepare_animation @@ -44,7 +45,7 @@ class Scene(object): def __init__(self, **kwargs): digest_config(self, kwargs) if self.preview: - self.window = Window(self, **self.window_config) + self.window = Window(scene=self, **self.window_config) self.camera_config["ctx"] = self.window.ctx else: self.window = None diff --git a/manimlib/window.py b/manimlib/window.py index e24adbfb..50c1b0aa 100644 --- a/manimlib/window.py +++ b/manimlib/window.py @@ -17,6 +17,13 @@ class Window(PygletWindow): def __init__(self, scene, **kwargs): super().__init__(**kwargs) digest_config(self, kwargs) + + self.init_mgl_context() + mglw.activate_context(window=self) + self.timer = Timer() + self.config = mglw.WindowConfig(ctx=self.ctx, wnd=self, timer=self.timer) + self.timer.start() + self.scene = scene self.title = str(scene) self.pressed_keys = set() @@ -31,11 +38,6 @@ class Window(PygletWindow): if "size" in kwargs: self.size = kwargs["size"] - mglw.activate_context(window=self) - self.timer = Timer() - self.config = mglw.WindowConfig(ctx=self.ctx, wnd=self, timer=self.timer) - self.timer.start() - def find_initial_position(self): custom_position = get_customization()["window_position"] monitor = get_monitors()[get_customization()["window_monitor"]]