Skip to content

RenderWindow

Introduction

WebGL rendering window

vtkOpenGLRenderWindow is designed to view/render a vtkRenderWindow.

Methods

activateTexture

ArgumentTypeRequiredDescription
texturevtkTextureYes

buildPass

Builds myself.

ArgumentTypeRequiredDescription
prepassBooleanYes

captureNextImage

Capture a screenshot of the contents of this renderwindow. The options object can include a size array ([w, h]) or a scale floating point value, as well as a resetCamera boolean. If size is provided, the captured screenshot will be of the given size (and resetCamera could be useful in this case if the aspect ratio of size does not match the current renderwindow size). Otherwise, if scale is provided, it will be multiplied by the current renderwindow size to compute the screenshot size. If no size or scale are provided, the current renderwindow size is assumed. The default format is "image/png". Returns a promise that resolves to the captured screenshot.

ArgumentTypeRequiredDescription
formatStringYes
optionsICaptureOptionsYes

copyParentContent

Copy the content of the root parent, if there is one, to the canvas

deactivateTexture

ArgumentTypeRequiredDescription
texturevtkTextureYes

disableCullFace

displayToLocalDisplay

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes

displayToNormalizedDisplay

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes

displayToWorld

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.

enableCullFace

extend

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

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

get2DContext

ArgumentTypeRequiredDescription
optionsCanvasRenderingContext2DSettingsYes

get3DContext

ArgumentTypeRequiredDescription
optionsWebGLContextAttributesYes

getCanvas

Get the webgl canvas.

getComputedDevicePixelRatio

Scales the size of a browser CSS pixel to a rendered canvas pixel. const renderedPixelWidth = cssPixelWidth * apiRenderWindow.getComputedDevicePixelRatio() Use to scale rendered objects to a consistent perceived size or DOM pixel position.

Rather than using window.devicePixelRatio directly, the device pixel ratio is inferred from the container CSS pixel size and rendered image pixel size. The user directly sets the rendered pixel size.

getContainer

Get the container element.

getContainerSize

Get the container size.

getContext2D

The context 2D is created during initialization instead of the WebGL context when there is a parent render window

getDefaultTextureInternalFormat

ArgumentTypeRequiredDescription
vtktypeVtkDataTypesYes
numCompsNumberYes
useFloatBooleanYes
oglNorm16ExtunknownYesThe WebGL EXT_texture_norm16 extension context
useHalfFloatBooleanYes

getFramebufferSize

Get the frame buffer size.

getGLInformations

getGraphicsMemoryInfo

Get approximate graphics memory usage, in bytes, for the context. This is a simple computation that analyzes how much memory is allocated on the GPU for textures, VBOs, etc. to give an application a view of its graphics memory consumption. Note that this ignores page resources.

getPixelData

ArgumentTypeRequiredDescription
x1NumberYes
y1NumberYes
x2NumberYes
y2NumberYes

getRootOpenGLRenderWindow

Returns the last ancestor of type vtkOpenGLRenderWindow if there is one If there is no parent vtkOpenGLRenderWindow, returns undefined

getSize

getTextureUnitForTexture

ArgumentTypeRequiredDescription
texturevtkTextureYes

getViewportCenter

Get the center of the viewport.

ArgumentTypeRequiredDescription
viewportvtkRendererYesThe viewport vtk element.

getViewportSize

Get the viewport size.

ArgumentTypeRequiredDescription
viewportvtkRendererYesThe viewport vtk element.

initialize

Initialize the rendering window. This will setup all system-specific resources. This method and Finalize() must be symmetric and it should be possible to call them multiple times, even changing WindowId in-between. This is what WindowRemap does.

isInViewport

Check if a point is in the viewport.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
viewportvtkRendererYesThe viewport vtk element.

makeCurrent

newInstance

Method used to create a new instance of vtkOpenGLRenderWindow.

ArgumentTypeRequiredDescription
initialValuesIOpenGLRenderWindowInitialValuesNofor pre-setting some of its content

normalizedDisplayToDisplay

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes

normalizedDisplayToViewport

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.

normalizedViewportToViewport

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes

popMonitorGLContextCount

ArgumentTypeRequiredDescription
cbYes

pushMonitorGLContextCount

ArgumentTypeRequiredDescription
cbYes

resizeFromChildRenderWindows

Resize this render window using the size of its children The new size of the renderwindow is the size of the bounding box containing all the child render windows

restoreContext

setBackgroundImage

ArgumentTypeRequiredDescription
imgHTMLImageElementYesThe background image.

setCanvas

Set the webgl canvas.

setContainer

ArgumentTypeRequiredDescription
elHTMLElementYesThe container element.

setContext2D

setGraphicsResourceForObject

Set graphics resources for vtk objects to be cached at the context level. This provides mappers with a convenient API to re-use allocated GPU resources without duplication.

ArgumentTypeRequiredDescription
vtkObjObjectYesVTK data object / array with resources on the GPU
gObjObjectYesContainer object that maintains a handle to the graphics resource on the GPU
hashStringYesString hash that can be used by mappers to decide whether to discard or re-allocate the cached resource.

setSize

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes

setSize

Sets the pixel width and height of the rendered image.

WebGL and WebGPU render windows apply these values to the width and height attribute of the canvas element.

To match the device resolution in browser environments, multiply the container size by window.devicePixelRatio `apiSpecificRenderWindow.setSize(Math.floor(containerWidth * devicePixelRatio), Math.floor(containerHeight * devicePixelRatio)); See the VTK.js FullscreenRenderWindow class for an example.

ArgumentTypeRequiredDescription
sizeVector2Yes

setUseBackgroundImage

ArgumentTypeRequiredDescription
valueBooleanYes

setViewStream

ArgumentTypeRequiredDescription
streamvtkViewStreamYesThe vtkViewStream instance.

traverseAllPasses

viewToWorld

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.

viewportToNormalizedDisplay

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.

viewportToNormalizedViewport

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.

worldToDisplay

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.

worldToView

ArgumentTypeRequiredDescription
xNumberYes
yNumberYes
zNumberYes
renderervtkRendererYesThe vtkRenderer instance.