Call Window.init_mgl_context and reorder Window.__init__

This commit is contained in:
Grant Sanderson 2021-02-10 14:48:00 -08:00
parent 6e2dcae4d7
commit 1798875396
2 changed files with 9 additions and 6 deletions

View file

@ -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

View file

@ -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"]]