WgpuCanvasInterface¶
- class wgpu.gui.WgpuCanvasInterface(*args, **kwargs)¶
Bases:
objectThe 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
WgpuCanvasBase.- get_context(kind='webgpu')¶
Get the
GPUCanvasContextobject corresponding to this canvas.The context is used to obtain a texture to render to, and to present that texture to the canvas. This class provides a default implementation to get the appropriate context.
The
kindargument is a remnant from the WebGPU spec and must always be “webgpu”.
- get_display_id()¶
Get the native display id (Linux only).
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.