Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix opengl scene selection (#1758)

Ryan McCauleyd70b742c96e5
diff --git a/manim/cli/render/commands.py b/manim/cli/render/commands.py
index f0ddc29b0..cd065d9d3 100644
--- a/manim/cli/render/commands.py
+++ b/manim/cli/render/commands.py
@@ -99,21 +99,21 @@ def render(
if config.renderer == "opengl":
from manim.renderer.opengl_renderer import OpenGLRenderer
- for SceneClass in scene_classes_from_file(file):
- try:
- renderer = OpenGLRenderer()
- while True:
- scene_classes = scene_classes_from_file(file)
- SceneClass = scene_classes[0]
+ try:
+ renderer = OpenGLRenderer()
+ keep_running = True
+ while keep_running:
+ for SceneClass in scene_classes_from_file(file):
scene = SceneClass(renderer)
status = scene.render()
if status:
continue
else:
+ keep_running = False
break
- except Exception:
- error_console.print_exception()
- sys.exit(1)
+ except Exception:
+ error_console.print_exception()
+ sys.exit(1)
elif config.renderer == "webgl":
try:
from manim.grpc.impl import frame_server_impl
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index 1c2fca5f6..70f62f7e8 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -48,6 +48,8 @@ class SceneFileWriter:
"""
+ force_output_as_scene_name = False
+
def __init__(self, renderer, scene_name, **kwargs):
self.renderer = renderer
self.stream_lock = False
@@ -74,7 +76,9 @@ class SceneFileWriter:
else:
module_name = ""
- if config["output_file"] and not config["write_all"]:
+ if SceneFileWriter.force_output_as_scene_name:
+ default_name = Path(scene_name)
+ elif config["output_file"] and not config["write_all"]:
default_name = config.get_dir("output_file")
else:
default_name = Path(scene_name)
diff --git a/manim/utils/module_ops.py b/manim/utils/module_ops.py
index 861e110fa..da663ed3f 100644
--- a/manim/utils/module_ops.py
+++ b/manim/utils/module_ops.py
@@ -8,6 +8,7 @@ import warnings
from pathlib import Path
from .. import config, console, constants, logger
+from ..scene.scene_file_writer import SceneFileWriter
def get_module(file_name: Path):
@@ -93,7 +94,7 @@ def get_scenes_to_render(scene_classes):
def prompt_user_for_choice(scene_classes):
num_to_class = {}
- config["write_all"] = True
+ SceneFileWriter.force_output_as_scene_name = True
for count, scene_class in enumerate(scene_classes):
count += 1 # start with 1 instead of 0
name = scene_class.__name__