-
Notifications
You must be signed in to change notification settings - Fork 1
Architecture
Tagin T edited this page Sep 4, 2026
·
1 revision
real-time-manim is split into three layers. Python owns animation logic and
mobject state; a native C/C++ DLL owns the GPU; ctypes is the boundary between
them.
flowchart TB
subgraph Python["Python layer (real_time_manim)"]
SC[Manim Scene]
W[MLWindow]
SH[ShapeMixin / TextMixin senders]
AN[animations package]
RC[record.py<br/>fast_record_scene / record_scene]
UT[util.py<br/>LaTeX cache / media cleanup]
end
SC -->|bind .scene / play| W
W --> AN
W --> SH
SH -- per-shape typed command --> FFI["ctypes FFI"]
RC -. auto-record around scene .-> W
UT -. cache SVGs .-> AN
subgraph Native["native layer (vulkan_core.dll)"]
PLAT[platform.c<br/>Win32 window + buffers + queue]
VINIT[vulkan_init.c<br/>instance · device · swapchain]
VDRAW[vulkan_draw.c<br/>vertex gen + submit]
DR[draw/<br/>rect · circle · line · text · bezier · polygon · arc]
end
FFI --> PLAT
PLAT --> VINIT --> VDRAW --> DR --> GPU[(Vulkan GPU)]
sequenceDiagram
participant S as Scene
participant W as MLWindow
participant D as DLL
participant V as Vulkan
participant O as Output
S->>W: play animations
loop each frame
W->>W: advance time, interpolate alpha
W->>W: sync scene, traverse mobjects
W->>D: clear shapes, send each mobject
D->>V: Render_DrawScene builds vertices and draws
V->>O: present frame
end
W-->>O: if recording, SaveScreenshot to ffmpeg
| Layer | Files | Responsibility |
|---|---|---|
| Scene / mobjects | ManimCE | Authoring animations; geometric state |
| Bridge |
vulkan_bind.py (MLWindow) |
Open window, advance time, play animations, traverse and dispatch mobjects each frame |
| Senders |
vulkan_shapes.py, vulkan_text.py
|
Turn each Manim type into a typed shape command (center, size, color, rotation) |
| Helpers |
record.py, util.py
|
One-call recording; LaTeX cache & cleanup |
| Animations | real_time_manim/animations/* |
Implementations matching Manim semantics (_vulkan_progress, _transforming, opacity/rotation tracking) |
| Boundary | ctypes |
Marshals structs/strings into vulkan_core.dll
|
| Native | native/*.c |
Win32 window, Vulkan setup, vertex generation, GPU submission, font rasterization |
The Python layer never touches the GPU directly — every frame ends in a native draw call. This keeps Python focused on what to draw and the DLL on how.
Simple primitives (rect, circle, line) are emitted as dedicated vertices rather than tessellated through a generic bezier path. This avoids per-mobject tessellation overhead and lets the GPU batch simple shapes cheaply — one reason scenes stay real-time. Transforms and complex geometry fall back to a bezier path renderer. See Internals.