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

Bases: WgpuCanvasBase

Base class for off-screen canvases.

It provides a custom context that renders to a texture instead of a surface/screen. On each draw the resulting image is passes as a texture to the present() method. Subclasses should (at least) implement present()


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


Get the preferred format for this canvas.

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


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


Method that gets called at the end of each draw event.

The rendered image is represented by the texture argument. Subclasses should overload this method and use the texture to process the rendered image.

The texture is a new object at each draw, but is not explicitly destroyed, so it can be used e.g. as a texture binding (subject to set TextureUsage).