A little more window initialization

This commit is contained in:
Grant Sanderson 2020-02-13 10:50:38 -08:00
parent 7789038409
commit 8db7756d2e

View file

@ -1,26 +1,33 @@
import moderngl_window as mglw import moderngl_window as mglw
from moderngl_window.context.pyglet.window import Window as PygletWindow from moderngl_window.context.pyglet.window import Window as PygletWindow
from moderngl_window.timers.clock import Timer
from manimlib.constants import DEFAULT_PIXEL_WIDTH from manimlib.constants import DEFAULT_PIXEL_WIDTH
from manimlib.constants import DEFAULT_PIXEL_HEIGHT from manimlib.constants import DEFAULT_PIXEL_HEIGHT
from manimlib.utils.config_ops import digest_config
class Window(PygletWindow): class Window(PygletWindow):
title = ""
size = (DEFAULT_PIXEL_WIDTH, DEFAULT_PIXEL_HEIGHT) size = (DEFAULT_PIXEL_WIDTH, DEFAULT_PIXEL_HEIGHT)
fullscreen = False fullscreen = False
resizable = True resizable = True
gl_version = (3, 3) gl_version = (3, 3)
aspect_ratio = None
vsync = True vsync = True
samples = 1 samples = 1
cursor = True cursor = True
def __init__(self, scene, **kwargs): def __init__(self, scene, **kwargs):
digest_config(self, kwargs)
super().__init__(**kwargs) super().__init__(**kwargs)
self.scene = scene self.scene = scene
# self.print_context_info() self.title = str(scene)
# Put at the top of the screen
self.position = (self.position[0], 0)
mglw.activate_context(window=self) mglw.activate_context(window=self)
self.timer = Timer()
self.config = mglw.WindowConfig(ctx=self.ctx, wnd=self, timer=self.timer)
self.timer.start()
# Delegate event handling to scene # Delegate event handling to scene
def pixel_coords_to_space_coords(self, px, py, relative=False): def pixel_coords_to_space_coords(self, px, py, relative=False):