Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Animation Loop #3785

Merged
merged 7 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions example_scenes/new_test_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@
from manim.mobject.text.text_mobject import Text
from manim.renderer.opengl_renderer import OpenGLRenderer


def progress_through_animations(animations):
dt = t - last_t
last_t = t
for animation in animations:
animation.update_mobjects(dt)
alpha = t / animation.run_time
animation.interpolate(alpha)
self.update_frame(dt)
self.emit_frame()


if __name__ == "__main__":
with tempconfig({"renderer": "opengl"}):
win = Window(
Expand Down
2 changes: 1 addition & 1 deletion example_scenes/test_new_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def construct(self) -> None:


with tempconfig({"renderer": "opengl", "preview": True, "parallel": False}):
Test().render()
Manager(Test).render()
1 change: 1 addition & 0 deletions manim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
from .mobject.types.vectorized_mobject import *
from .mobject.value_tracker import *
from .mobject.vector_field import *
from .renderer.render_manager import *
from .scene.scene import *
from .scene.scene_file_writer import *
from .scene.section import *
Expand Down
2 changes: 1 addition & 1 deletion manim/cli/render/render_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def validate_resolution(ctx, param, value):
case_sensitive=False,
),
help="Select a renderer for your Scene.",
default="cairo",
default="opengl",
),
option(
"-g",
Expand Down
1 change: 0 additions & 1 deletion manim/renderer/cairo_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from manim.utils.hashing import get_hash_from_play_call

from .. import config, logger
from ..camera.cairo_camera import CairoCamera as Camera
from ..mobject.mobject import Mobject
from ..scene.scene_file_writer import SceneFileWriter
from ..utils.exceptions import EndSceneEarlyException
Expand Down
12 changes: 9 additions & 3 deletions manim/renderer/opengl_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject
from manim.renderer.buffers.buffer import STD140BufferFormat
from manim.renderer.opengl_shader_program import load_shader_program_by_folder
from manim.renderer.renderer import ImageType, Renderer, RendererData
from manim.renderer.renderer import ImageType, Renderer, RendererData, RendererProtocol
from manim.utils.iterables import listify
from manim.utils.space_ops import cross2d, earclip_triangulation, z_to_vector

Expand Down Expand Up @@ -203,14 +203,14 @@ def bind_to_uniform_block(uniform_buffer_object: gl.Buffer, idx: int = 0):
uniform_buffer_object.bind_to_uniform_block(idx)


class OpenGLRenderer(Renderer):
class OpenGLRenderer(Renderer, RendererProtocol):
pixel_array_dtype = np.uint8

def __init__(
self,
pixel_width: int = config.pixel_width,
pixel_height: int = config.pixel_height,
samples=4,
samples: int = 4,
background_color: c.ManimColor = color.BLACK,
background_opacity: float = 1.0,
background_image: str | None = None,
Expand Down Expand Up @@ -407,6 +407,12 @@ def render_program(self, prog, data, indices=None):
vao.release()
# return data, data_size

def render_image(self, mob):
raise NotImplementedError # TODO

def render_previous(self, camera: Camera) -> None:
raise NotImplementedError

def render_vmobject(self, mob: OpenGLVMobject) -> None: # type: ignore
self.stencil_buffer_fbo.use()
self.stencil_buffer_fbo.clear()
Expand Down
3 changes: 0 additions & 3 deletions manim/renderer/opengl_renderer_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

from .. import __version__, config

if TYPE_CHECKING:
import manim.scene as m_scene


class Window(FunWindow):
fullscreen: bool = False
Expand Down
11 changes: 5 additions & 6 deletions manim/renderer/opengl_shader_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ def load_shader_program_by_folder(ctx: gl.Context, folder_name: str):
raise RuntimeError("Loading Shader Program Error")
if geometry_code is None:
return ctx.program(vertex_shader=vertex_code, fragment_shader=fragment_code)
elif geometry_code is not None:
return ctx.program(
vertex_shader=vertex_code,
geometry_shader=geometry_code,
fragment_shader=fragment_code,
)
return ctx.program(
vertex_shader=vertex_code,
geometry_shader=geometry_code,
fragment_shader=fragment_code,
)
Loading
Loading