pygfx.utils.viewport.Viewport

class pygfx.utils.viewport.Viewport(renderer, rect=None)

Bases: object

A rectangular area on a renderer.

Parameters:
  • renderer (Renderer) – The renderer on which the viewport should be defined.

  • rect (tuple, [4]) – The viewport rect (x, y, w, h). If None, it is set to the full size of the renderer’s canvas.

classmethod from_viewport_or_renderer(x)

Convenience method. Some parts of pygfx that accept a viewport might just as well accept a renderer.

property renderer

A reference to the renderer that this is a viewport of.

property logical_size

The logical size of the rectangular area described by this viewport.

property rect

The viewport rect (x, y, w, h). Can be set to None to set it to the full renderer size.

is_inside(x, y)

Get whether the given position is inside the viewport rect.

render(scene, camera, flush=False)

A shorthand for renderer.render(scene, camera) at the appropriate viewport. Does not flush by default.

Examples

Ambient occlusion

Ambient occlusion

Audio Visualizer

Audio Visualizer

Gizmo to transform world objects

Gizmo to transform world objects

Lightmap

Lightmap

Map Screen to World

Map Screen to World

Camera linking 1

Camera linking 1

Camera linking 2

Camera linking 2

Subplots 2

Subplots 2

Subplots Video

Subplots Video

A Tool to Compare Two Images of Identical Shapes

A Tool to Compare Two Images of Identical Shapes

Pytorch Integration

Pytorch Integration

Culling

Culling