Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add config to enable opengl wireframe (#2041)

Ryan McCauley32eda9d66a5d
diff --git a/docs/source/tutorials/configuration.rst b/docs/source/tutorials/configuration.rst
index 868f0abcd..f6e9fb52b 100644
--- a/docs/source/tutorials/configuration.rst
+++ b/docs/source/tutorials/configuration.rst
@@ -353,7 +353,7 @@ A list of all config options
'tex_template', 'tex_template_file', 'text_dir', 'top', 'transparent',
'upto_animation_number', 'use_opengl_renderer', 'use_webgl_renderer',
'verbosity', 'video_dir', 'webgl_renderer_path', 'window_position',
- 'window_monitor', 'window_size', 'write_all', 'write_to_movie']
+ 'window_monitor', 'window_size', 'write_all', 'write_to_movie', 'enable_wireframe']
A list of all CLI flags
diff --git a/manim/_config/default.cfg b/manim/_config/default.cfg
index 976d2ba56..1b555f9d7 100644
--- a/manim/_config/default.cfg
+++ b/manim/_config/default.cfg
@@ -144,6 +144,9 @@ disable_caching = False
# Disable the warning when there are too much submobjects to hash.
disable_caching_warning = False
+# --enable_wireframe
+enable_wireframe = False
+
# Default tex_template
# --tex_template
tex_template =
diff --git a/manim/_config/utils.py b/manim/_config/utils.py
index 371a530fe..417b5f882 100644
--- a/manim/_config/utils.py
+++ b/manim/_config/utils.py
@@ -245,6 +245,7 @@ class ManimConfig(MutableMapping):
"custom_folders",
"disable_caching",
"disable_caching_warning",
+ "enable_wireframe",
"ffmpeg_loglevel",
"format",
"flush_cache",
@@ -539,6 +540,7 @@ class ManimConfig(MutableMapping):
"fullscreen",
"use_projection_fill_shaders",
"use_projection_stroke_shaders",
+ "enable_wireframe",
]:
setattr(self, key, parser["CLI"].getboolean(key, fallback=False))
@@ -687,6 +689,7 @@ class ManimConfig(MutableMapping):
"use_projection_fill_shaders",
"use_projection_stroke_shaders",
"zero_pad",
+ "enable_wireframe",
]:
if hasattr(args, key):
attr = getattr(args, key)
@@ -882,6 +885,12 @@ class ManimConfig(MutableMapping):
doc="Whether to save the rendered scene in .gif format (-i).",
)
+ enable_wireframe = property(
+ lambda self: self._d["enable_wireframe"],
+ lambda self, val: self._set_boolean("enable_wireframe", val),
+ doc="Enable wireframe debugging mode in opengl.",
+ )
+
@property
def verbosity(self):
"""Logger verbosity; "DEBUG", "INFO", "WARNING", "ERROR", or "CRITICAL" (-v)."""
diff --git a/manim/cli/render/global_options.py b/manim/cli/render/global_options.py
index 6f477c975..a72eb001f 100644
--- a/manim/cli/render/global_options.py
+++ b/manim/cli/render/global_options.py
@@ -78,4 +78,10 @@ global_options = option_group(
help="Expand the window to its maximum possible size.",
default=None,
),
+ option(
+ "--enable_wireframe",
+ is_flag=True,
+ help="Enable wireframe debugging mode in opengl.",
+ default=None,
+ ),
)
diff --git a/manim/renderer/opengl_renderer.py b/manim/renderer/opengl_renderer.py
index 5cadf7c3a..6acdbc1a0 100644
--- a/manim/renderer/opengl_renderer.py
+++ b/manim/renderer/opengl_renderer.py
@@ -260,6 +260,7 @@ class OpenGLRenderer:
self.frame_buffer_object = self.get_frame_buffer_object(self.context, 0)
self.frame_buffer_object.use()
self.context.enable(moderngl.BLEND)
+ self.context.wireframe = config["enable_wireframe"]
self.context.blend_func = (
moderngl.SRC_ALPHA,
moderngl.ONE_MINUS_SRC_ALPHA,