wgpu.gui.WgpuOffscreenCanvas

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

Bases: WgpuCanvasBase

Base class for off-screen canvases.

It provides a custom presentation context that renders to a tetxure instead of a surface/screen. The resulting texture view is passed to the present() method.

get_context(kind='gpupresent')

Get the GPUCanvasContext object to obtain a texture to render to.

get_preferred_format()

Get the preferred format for this canvas. This method can be overloaded to control the used texture format. The default is “rgba8unorm-srgb”.

get_window_id()

This canvas does not correspond to an on-screen window.

present(texture_view)

Method that gets called at the end of each draw event. Subclasses should provide the approproate implementation.