Reference navigation
On this page
CLASS · v0.9.1
Renderer
Render protein and annotation objects with a reusable GPU renderer.
from proteinmotion.renderer import RendererConstructor
Renderer(width=1920, height=1080, *, msaa=4, require_metal=None, readback_format='rgba')Parameters
| Parameter | Default | Description |
|---|---|---|
width | 1920 | Image width in pixels. |
height | 1080 | Image height in pixels. |
msaakeyword only | 4 | Multisample count: 1 or 4. |
require_metalkeyword only | None | Require the Metal backend. None requires Metal on macOS and requests a high-performance adapter elsewhere. |
readback_formatkeyword only | 'rgba' | "rgba" for image arrays or "nv12" for video encoding. |
Notes
Use a with block to release resources. draw() submits GPU work without readback. render() returns one completed frame. enqueue() and drain() overlap GPU rendering and CPU encoding.
Attributes
| Name | Description |
|---|---|
adapter_info | GPU adapter and backend information. |
Methods and properties
| Name | Description |
|---|---|
| draw()method | Draw a GPU frame without copying pixels to the CPU. |
| enqueue()method | Submit a frame and retrieve the oldest completed readback when the pipeline is full. |
| drain()method | Yield all remaining queued frame arrays in submission order. |
| render()method | Draw one frame and wait for its pixel readback. |
| close()method | Release GPU buffers and renderer resources. |
| __enter__()method | Enter a with Renderer(...) context. |
| __exit__()method | Close renderer resources on context exit. |
Renderer.draw(proteins, camera, background)Draw a GPU frame without copying pixels to the CPU.
| Parameter | Default | Description |
|---|---|---|
proteins | Required | Protein or annotation objects to add or render. |
camera | Required | Camera used to project or frame objects. |
background | Required | Three RGB floats in [0, 1], such as scene.background. |
Returns: None
Renderer.enqueue(proteins, camera, background)Submit a frame and retrieve the oldest completed readback when the pipeline is full.
| Parameter | Default | Description |
|---|---|---|
proteins | Required | Protein or annotation objects to add or render. |
camera | Required | Camera used to project or frame objects. |
background | Required | Three RGB floats in [0, 1], such as scene.background. |
Returns: Frame array, or None while the readback pipeline fills.
Renderer.drain()Yield all remaining queued frame arrays in submission order.
Returns: Iterator of frame arrays.
Renderer.render(proteins, camera, background)Draw one frame and wait for its pixel readback.
| Parameter | Default | Description |
|---|---|---|
proteins | Required | Protein or annotation objects to add or render. |
camera | Required | Camera used to project or frame objects. |
background | Required | Three RGB floats in [0, 1], such as scene.background. |
Returns: RGBA uint8 array or NV12 array, according to readback_format.
Renderer.close()Release GPU buffers and renderer resources.
Returns: None
Renderer.__enter__()Enter a with Renderer(...) context.
Returns: The renderer.
Renderer.__exit__(*args)Close renderer resources on context exit.
| Parameter | Default | Description |
|---|---|---|
*args | — | Exception information supplied by the context manager. |
Returns: None