RenderWindow
Introduction
WebGL rendering window
vtkOpenGLRenderWindow is designed to view/render a vtkRenderWindow.
Methods
activateTexture
| Argument | Type | Required | Description |
|---|---|---|---|
texture | vtkTexture | Yes |
buildPass
Builds myself.
| Argument | Type | Required | Description |
|---|---|---|---|
prepass | Boolean | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
format | String | Yes | |
options | ICaptureOptions | Yes |
copyParentContent
Copy the content of the root parent, if there is one, to the canvas
deactivateTexture
| Argument | Type | Required | Description |
|---|---|---|---|
texture | vtkTexture | Yes |
disableCullFace
displayToLocalDisplay
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes |
displayToNormalizedDisplay
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes |
displayToWorld
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |
enableCullFace
extend
Method used to decorate a given object (publicAPI+model) with vtkOpenGLRenderWindow characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IOpenGLRenderWindowInitialValues | No | (default: {}) |
get2DContext
| Argument | Type | Required | Description |
|---|---|---|---|
options | CanvasRenderingContext2DSettings | Yes |
get3DContext
| Argument | Type | Required | Description |
|---|---|---|---|
options | WebGLContextAttributes | Yes |
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
| Argument | Type | Required | Description |
|---|---|---|---|
vtktype | VtkDataTypes | Yes | |
numComps | Number | Yes | |
useFloat | Boolean | Yes | |
oglNorm16Ext | unknown | Yes | The WebGL EXT_texture_norm16 extension context |
useHalfFloat | Boolean | Yes |
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
| Argument | Type | Required | Description |
|---|---|---|---|
x1 | Number | Yes | |
y1 | Number | Yes | |
x2 | Number | Yes | |
y2 | Number | Yes |
getRootOpenGLRenderWindow
Returns the last ancestor of type vtkOpenGLRenderWindow if there is one If there is no parent vtkOpenGLRenderWindow, returns undefined
getSize
getTextureUnitForTexture
| Argument | Type | Required | Description |
|---|---|---|---|
texture | vtkTexture | Yes |
getViewportCenter
Get the center of the viewport.
| Argument | Type | Required | Description |
|---|---|---|---|
viewport | vtkRenderer | Yes | The viewport vtk element. |
getViewportSize
Get the viewport size.
| Argument | Type | Required | Description |
|---|---|---|---|
viewport | vtkRenderer | Yes | The 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.
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | The x coordinate. |
y | Number | Yes | The y coordinate. |
viewport | vtkRenderer | Yes | The viewport vtk element. |
makeCurrent
newInstance
Method used to create a new instance of vtkOpenGLRenderWindow.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IOpenGLRenderWindowInitialValues | No | for pre-setting some of its content |
normalizedDisplayToDisplay
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes |
normalizedDisplayToViewport
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |
normalizedViewportToViewport
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes |
popMonitorGLContextCount
| Argument | Type | Required | Description |
|---|---|---|---|
cb | Yes |
pushMonitorGLContextCount
| Argument | Type | Required | Description |
|---|---|---|---|
cb | Yes |
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
| Argument | Type | Required | Description |
|---|---|---|---|
img | HTMLImageElement | Yes | The background image. |
setCanvas
Set the webgl canvas.
setContainer
| Argument | Type | Required | Description |
|---|---|---|---|
el | HTMLElement | Yes | The 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.
| Argument | Type | Required | Description |
|---|---|---|---|
vtkObj | Object | Yes | VTK data object / array with resources on the GPU |
gObj | Object | Yes | Container object that maintains a handle to the graphics resource on the GPU |
hash | String | Yes | String hash that can be used by mappers to decide whether to discard or re-allocate the cached resource. |
setSize
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
size | Vector2 | Yes |
setUseBackgroundImage
| Argument | Type | Required | Description |
|---|---|---|---|
value | Boolean | Yes |
setViewStream
| Argument | Type | Required | Description |
|---|---|---|---|
stream | vtkViewStream | Yes | The vtkViewStream instance. |
traverseAllPasses
viewToWorld
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |
viewportToNormalizedDisplay
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |
viewportToNormalizedViewport
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |
worldToDisplay
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |
worldToView
| Argument | Type | Required | Description |
|---|---|---|---|
x | Number | Yes | |
y | Number | Yes | |
z | Number | Yes | |
renderer | vtkRenderer | Yes | The vtkRenderer instance. |