mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 15:57:44 +00:00
A little more window initialization
This commit is contained in:
parent
7789038409
commit
8db7756d2e
1 changed files with 10 additions and 3 deletions
|
|
@ -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):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue