wgpu.gui.WgpuCanvasInterface

class wgpu.gui.WgpuCanvasInterface(*args, **kwargs)

Bases: object

The minimal interface to be a valid canvas.

Any object that implements these methods is a canvas that wgpu can work with. The object does not even have to derive from this class.

In most cases it’s more convenient to subclass gui.WgpuCanvasBase.

get_context(kind='gpupresent')

Get the GPUCanvasContext object corresponding to this canvas, which can be used to e.g. obtain a texture to render to.

get_display_id()

Get the native display id on Linux. This is needed in addition to the window id to obtain a surface id. The default implementation calls into the X11 lib to get the display id.

get_physical_size()

Get the physical size of the canvas in integer pixels.

get_window_id()

Get the native window id. This is used to obtain a surface id, so that wgpu can render to the region of the screen occupied by the canvas.