Reference navigation
On this page
Renderer
Render protein and annotation objects with a reusable GPU renderer.
from proteinmotion.renderer import RendererConstructor
Renderer(
width=1920,
height=1080,
*,
msaa=4,
supersampling=1,
require_metal=None,
readback_format='rgba',
backend=None,
adapter_name=None,
)Parameters
| Parameter | Default | Description |
|---|---|---|
width | 1920 | Image width in pixels. |
height | 1080 | Image height in pixels. |
msaakeyword only | 4 | Multisample count: 1 or 4. |
supersamplingkeyword only | 1 | Draw each frame at this multiple of the width and height (1, 2, 3, or 4), then average down to the requested size. |
require_metalkeyword only | None | Require the Metal backend. None defaults to Metal on macOS unless a backend is explicitly selected; otherwise prefers a discrete GPU and Vulkan. |
readback_formatkeyword only | 'rgba' | "rgba" for image arrays or "nv12" for video encoding. |
backendkeyword only | None | Native GPU backend: Vulkan, D3D12, Metal, OpenGL or auto. None uses PROTEINMOTION_GPU_BACKEND or the platform default. Vulkan is the tested Windows path. |
adapter_namekeyword only | None | Case-insensitive GPU name/vendor substring. None uses PROTEINMOTION_GPU_ADAPTER or selects a discrete GPU when available. |
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