Skip to content

RenderWindow ​

Introduction ​

WebGPU rendering window

vtkWebGPURenderWindow is designed to view/render a vtkRenderWindow with the WebGPU backend. It owns the canvas, the adapter and the device, and it reacquires them when the device is lost.

Methods ​

buildPass ​

Builds myself: adopt the renderers of the renderable as children and, on the second visit, create the command encoder of the frame.

ArgumentTypeRequiredDescription
prepassBooleanYes

captureNextImage ​

Capture a screenshot of the contents of this render window. The options object can include a size array ([w, h]) or a scale floating point value, as well as a resetCamera boolean. Returns a promise that resolves to the captured screenshot, or null when the render window was already deleted.

ArgumentTypeRequiredDescription
formatStringYes
optionsIWebGPUCaptureOptionsYes

colorBufferWidth ​

The width, in texels, of the readback buffer. Rounded up so that a row is a multiple of 256 bytes, as WebGPU requires.

colorValues ​

The RGBA values of the image, tightly packed at width texels per row.

create3DContextAsync ​

Request the adapter and the device, watch the device for loss, and get the WebGPU context of the canvas. Resolves once the context is ready, or early when the render window was deleted while waiting.

createSelector ​

Create a hardware selector bound to this render window.

extend ​

Method used to decorate a given object (publicAPI+model) with vtkWebGPURenderWindow characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIWebGPURenderWindowInitialValuesNo(default: {})

getCanvas ​

Get the canvas rendered into.

getCommandEncoder ​

Get the command encoder of the frame being built.

getContainer ​

Get the container element.

getContainerSize ​

Get the size of the container element, falling back to the size of the render window when there is no container.

getContext ​

Get the WebGPU context of the canvas.

getCurrentTexture ​

Get the texture the canvas context is presenting this frame.

getCursor ​

Get the CSS cursor of the container.

getDevice ​

Get the device this render window renders with.

getDeviceLostInfo ​

Get the information of the last device loss, or null when the device was never lost or was reacquired.

getFramebufferSize ​

Get the frame buffer size.

getInitialized ​

Whether the device and the canvas context are ready.

getMultiSample ​

Get the number of samples per pixel.

getNotifyStartCaptureImage ​

Whether the image ready event fires once the frame is done.

getPixelsAsync ​

Read the color texture of the forward pass back into a tightly packed RGBA array.

getPresentationFormat ​

Get the texture format the canvas context is configured with.

getPropFromID ​

Get the view node of the prop holding an id, or null when none does.

ArgumentTypeRequiredDescription
idNumberYes

getRenderPasses ​

Get the render passes traversed on every render.

getSize ​

getSizeByReference ​

getUniquePropID ​

Get an id no other prop of this render window uses, for hardware selection.

getUseBackgroundImage ​

Whether the background image is attached to the container.

getUseOffScreen ​

Whether the canvas is hidden.

getViewNodeFactory ​

Get the factory creating the WebGPU view nodes of this render window.

getWebGPUConfiguration ​

Get the configuration that supplies the adapter and device.

getXrSupported ​

initialize ​

Start acquiring the adapter, the device and the canvas context, unless that is already under way. The initialized event fires once they are available.

invokeDeviceLost ​

Call any registered callbacks with the reason the device was lost.

ArgumentTypeRequiredDescription
eventIWebGPUDeviceLostEventYes

invokeImageReady ​

Call any registered callbacks with the captured image URL.

ArgumentTypeRequiredDescription
imageURLStringYes

invokeInitialized ​

Call any registered callbacks once the device and the context are ready.

invokeWindowResizeEvent ​

Call any registered callbacks whenever setSize() changes the size.

ArgumentTypeRequiredDescription
sizeIWebGPUWindowResizeEventYes

newInstance ​

Method used to create a new instance of vtkWebGPURenderWindow.

ArgumentTypeRequiredDescription
initialValuesIWebGPURenderWindowInitialValuesNofor pre-setting some of its content

onDeviceLost ​

Register a callback to be called whenever the device is lost.

ArgumentTypeRequiredDescription
callbackYes

onImageReady ​

Register a callback to be called whenever a captured image becomes ready.

ArgumentTypeRequiredDescription
callbackYes

onInitialized ​

Register a callback to be called once the device and the context are ready.

ArgumentTypeRequiredDescription
callbackYes

onWindowResizeEvent ​

Register a callback to be called whenever setSize() changes the size.

ArgumentTypeRequiredDescription
callbackYes

recoverable ​

False when the device was lost because it was destroyed, in which case no new device is acquired.

recreateSwapChain ​

Reconfigure the canvas context for the current device and size.

releaseGraphicsResources ​

Release the resources of the render passes and of every view node, and drop the adapter, device and context. The render window initializes again on the next traversal.

setBackgroundImage ​

ArgumentTypeRequiredDescription
imgHTMLImageElementYesThe background image.

setCanvas ​

ArgumentTypeRequiredDescription
canvasHTMLCanvasElementYes

setContainer ​

Move the canvas into a container element.

ArgumentTypeRequiredDescription
elHTMLElementYesThe container element.

setContext ​

ArgumentTypeRequiredDescription
contextGPUCanvasContextYes

setCursor ​

ArgumentTypeRequiredDescription
cursorStringYes

setInitialized ​

ArgumentTypeRequiredDescription
initializedBooleanYes

setMultiSample ​

Set the number of samples per pixel. Supported values are 1 and 4.

setNotifyStartCaptureImage ​

ArgumentTypeRequiredDescription
notifyStartCaptureImageBooleanYes

setRenderPasses ​

ArgumentTypeRequiredDescription
renderPassesArray[vtkRenderPass]Yes

setSize ​

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes

setSize ​

Sets the pixel width and height of the rendered image, and fires the windowResizeEvent when they changed.

ArgumentTypeRequiredDescription
sizeVector2Yes

setSizeFrom ​

ArgumentTypeRequiredDescription
sizeVector2Yes

setUseBackgroundImage ​

Add or remove the background image from the container.

ArgumentTypeRequiredDescription
valueBooleanYes

setUseOffScreen ​

ArgumentTypeRequiredDescription
useOffScreenBooleanYes

setViewStream ​

ArgumentTypeRequiredDescription
streamvtkViewStreamYesThe vtkViewStream instance.

setWebGPUConfiguration ​

Set the configuration before initialization. Passing null creates an internally owned configuration.

traverseAllPasses ​

Traverse the render passes, submitting the command encoder of the frame when they are done. Queues the traversal until the device is available when the render window is not initialized yet.