Texture
Introduction
vtkOpenGLTexture static API.
Methods
activate
Activates the texture, making it the current texture for subsequent OpenGL operations.
bind
Binds the texture to the current OpenGL context.
create2DFilterableFromDataArray
Creates a 2D filterable texture from a data array, with a preference for size over accuracy if necessary.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
dataArray | Yes | The data array to use for the texture. | |
preferSizeOverAccuracy | Yes | Whether to prefer texture size over accuracy. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create2DFilterableFromRaw
Creates a 2D filterable texture from raw data, with a preference for size over accuracy if necessary.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
numComps | Yes | The number of components in the texture. | |
dataType | Yes | The data type of the texture. | |
data | Yes | The raw data for the texture. | |
preferSizeOverAccuracy=false | No | Whether to prefer texture size over accuracy. Defaults to false. | |
ranges | No | The precomputed ranges of the data (optional). Provided to prevent computation of the data ranges. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create2DFromImage
Creates a 2D texture from an image.
| Argument | Type | Required | Description |
|---|---|---|---|
image | Yes | The image to use for the texture. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create2DFromImageBitmap
Creates a 2D texture from an ImageBitmap.
| Argument | Type | Required | Description |
|---|---|---|---|
imageBitmap | Yes | The ImageBitmap to use for the texture. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create2DFromRaw
Creates a 2D texture from raw data.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
numComps | Yes | The number of components in the texture. | |
dataType | Yes | The data type of the texture. | |
data | Yes | The raw data for the texture. | |
flip | Yes | Whether to flip the texture vertically. Defaults to false. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create3DFilterableFromDataArray
Creates a 3D filterable texture from a data array, with a preference for size over accuracy if necessary.
updatedExtents support assumes WebGL2 3D texture uploads.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
depth | Yes | The depth of the texture. | |
dataArray | Yes | The data array to use for the texture. | |
preferSizeOverAccuracy | Yes | Whether to prefer texture size over accuracy. | |
updatedExtents | Yes | Only update the specified extents (default: []) |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create3DFilterableFromRaw
Creates a 3D filterable texture from raw data, with a preference for size over accuracy if necessary.
updatedExtents support assumes WebGL2 3D texture uploads.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
depth | Yes | The depth of the texture. | |
numComps | Yes | The number of components in the texture. | |
dataType | Yes | The data type of the texture. | |
data | Yes | The raw data for the texture. | |
preferSizeOverAccuracy | Yes | Whether to prefer texture size over accuracy. | |
ranges | No | The precomputed ranges of the data (optional). Provided to | |
updatedExtents | Yes | Only update the specified extents (default: []) prevent computation of the data ranges. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
create3DFromRaw
Creates a 3D texture from raw data.
updatedExtents support assumes WebGL2 3D texture uploads.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
depth | Yes | The depth of the texture. | |
numComps | Yes | The number of components in the texture. | |
dataType | Yes | The data type of the texture. | |
data | Yes | The raw data for the texture. | |
updatedExtents | Yes | Only update the specified extents (default: []) |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
createCubeFromRaw
Creates a cube texture from raw data.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of each face of the cube texture. | |
height | Yes | The height of each face of the cube texture. | |
numComps | Yes | The number of components in the texture. | |
dataType | Yes | The data type of the texture. | |
data | Yes | The raw data for the texture. |
Returns
| Type | Description |
|---|---|
| boolean | True if the cube texture was successfully created, false otherwise. |
createDepthFromRaw
Creates a 2D depth texture from raw data.
| Argument | Type | Required | Description |
|---|---|---|---|
width | Yes | The width of the texture. | |
height | Yes | The height of the texture. | |
dataType | Yes | The data type of the texture. | |
data | Yes | The raw data for the texture. |
Returns
| Type | Description |
|---|---|
| boolean | True if the texture was successfully created, false otherwise. |
createTexture
Creates the texture in the OpenGL context.
deactivate
Deactivates the texture, making it no longer the current texture for subsequent OpenGL operations.
destroyTexture
Destroys the texture and frees up any resources it's using.
enableUseHalfFloat
Public API to disable half float usage. Half float is automatically enabled when creating the texture, but users may want to disable it in certain cases (e.g., streaming data where the full range is not yet available).
| Argument | Type | Required | Description |
|---|---|---|---|
useHalfFloat | Yes | - whether to use half float |
extend
Extends the publicAPI with the given model and initial values.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | The API to extend. | |
model | Yes | The model to use. | |
initialValues | Yes | The initial values to apply. |
getAllocatedGPUMemoryInBytes
Gets the amount of GPU memory allocated for this texture, in bytes.
getComponents
Gets the number of components of the texture.
getDefaultDataType
Gets the default data type for the texture based on the VTK scalar type.
| Argument | Type | Required | Description |
|---|---|---|---|
vtkScalarType | Yes | The VTK scalar type. |
Returns
| Type | Description |
|---|---|
| The default data type. |
getDefaultFormat
Gets the default format for the texture based on the VTK data type and number of components.
| Argument | Type | Required | Description |
|---|---|---|---|
vtktype | Yes | The VTK data type. | |
numComps | Yes | The number of components in the texture. |
Returns
| Type | Description |
|---|---|
| The default format. |
getDefaultInternalFormat
Gets the default internal format for the texture based on the VTK data type and number of components.
| Argument | Type | Required | Description |
|---|---|---|---|
vtktype | Yes | The VTK data type. | |
numComps | Yes | The number of components in the texture. |
Returns
| Type | Description |
|---|---|
| The default internal format. |
getFormat
Gets the format for the texture based on the VTK data type and number of components.
| Argument | Type | Required | Description |
|---|---|---|---|
vtktype | Yes | The VTK data type. | |
numComps | Yes | The number of components in the texture. |
Returns
| Type | Description |
|---|---|
| The format. |
getGenerateMipmap
Gets whether mipmaps are generated for the texture.
getHandle
Gets the underlying WebGL texture object, or 0 when no texture is allocated.
getHeight
Gets the height of the texture.
getInternalFormat
Gets the internal format for the texture based on the VTK data type and number of components.
| Argument | Type | Required | Description |
|---|---|---|---|
vtktype | Yes | The VTK data type. | |
numComps | Yes | The number of components in the texture. |
Returns
| Type | Description |
|---|---|
| The internal format. |
getKeyMatrixTime
Gets the time stamp used to track matrix updates.
getMagnificationFilter
Gets the magnification filter.
getMaximumTextureSize
Gets the maximum texture size supported by the OpenGL context.
| Argument | Type | Required | Description |
|---|---|---|---|
ctx | Yes | The OpenGL context. |
Returns
| Type | Description |
|---|---|
| number | The maximum texture size. |
getMinificationFilter
Gets the minification filter.
getOglNorm16Ext
Gets the EXT_texture_norm16 extension object, if available.
getOpenGLDataType
Gets the OpenGL data type for the texture based on the VTK scalar type and whether to force an update.
| Argument | Type | Required | Description |
|---|---|---|---|
vtkScalarType | Yes | The VTK scalar type. | |
forceUpdate | Yes | Whether to force the update of the data type. |
Returns
| Type | Description |
|---|---|
| The OpenGL data type. |
getOpenGLFilterMode
Gets the OpenGL filter mode for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
emode | Yes | The filter mode. |
Returns
| Type | Description |
|---|---|
| The OpenGL filter mode. |
getOpenGLWrapMode
Gets the OpenGL wrap mode for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
vtktype | Yes | The wrap type. |
Returns
| Type | Description |
|---|---|
| The OpenGL wrap mode. |
getShiftAndScale
Gets the shift and scale values for the texture.
Returns
| Type | Description |
|---|---|
| The shift and scale values. |
getTarget
Gets the OpenGL texture target.
getTextureUnit
Gets the texture unit number that this texture is bound to.
Returns
| Type | Description |
|---|---|
| number | The texture unit number. |
getVolumeInfo
Gets the scale and offset mapping texture values back to data values.
getWidth
Gets the width of the texture.
getWrapR
Gets the wrap mode along R.
getWrapS
Gets the wrap mode along S.
getWrapT
Gets the wrap mode along T.
isBound
Checks if the texture is currently bound to the OpenGL context.
Returns
| Type | Description |
|---|---|
| boolean | True if the texture is bound, false otherwise. |
newInstance
Creates a new instance of vtkOpenGLTexture with the given initial values.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | Yes | The initial values to use. |
Returns
| Type | Description |
|---|---|
| The new instance. |
releaseGraphicsResources
Releases the graphics resources used by the texture within the given render window. Deleting the texture releases them too.
| Argument | Type | Required | Description |
|---|---|---|---|
renWin | No | The render window whose resources should be released. Defaults to the render window the texture was last used with. |
render
Renders the texture within the given render window.
| Argument | Type | Required | Description |
|---|---|---|---|
renWin | Yes | The render window in which to render the texture. |
resetFormatAndType
Resets the texture format and type to their default values.
sendParameters
Sends the texture parameters to the OpenGL context.
setFormat
Sets the format for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
format | Yes | The format to set. |
setGenerateMipmap
Sets whether mipmaps are generated for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
generateMipmap | Yes | Whether to generate mipmaps. |
setInternalFormat
Sets the internal format for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
iformat | Yes | The internal format to set. |
setKeyMatrixTime
Sets the time stamp used to track matrix updates.
| Argument | Type | Required | Description |
|---|---|---|---|
keyMatrixTime | Yes | The time stamp to set. |
setMagnificationFilter
Sets the magnification filter.
| Argument | Type | Required | Description |
|---|---|---|---|
magnificationFilter | Yes | The filter to set. |
setMinificationFilter
Sets the minification filter.
| Argument | Type | Required | Description |
|---|---|---|---|
minificationFilter | Yes | The filter to set. |
setOglNorm16Ext
Sets the EXT_texture_norm16 extension object.
| Argument | Type | Required | Description |
|---|---|---|---|
oglNorm16Ext | Yes | The extension object. |
setOpenGLDataType
Sets the OpenGL data type for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
openGLDataType | Yes | The OpenGL data type to set. |
setOpenGLRenderWindow
Sets the OpenGL render window in which the texture will be used. Changing it releases the texture allocated in the previous one.
| Argument | Type | Required | Description |
|---|---|---|---|
renWin | Yes | The render window to set. |
setWrapR
Sets the wrap mode along R.
| Argument | Type | Required | Description |
|---|---|---|---|
wrapR | Yes | The wrap mode to set. |
setWrapS
Sets the wrap mode along S.
| Argument | Type | Required | Description |
|---|---|---|---|
wrapS | Yes | The wrap mode to set. |
setWrapT
Sets the wrap mode along T.
| Argument | Type | Required | Description |
|---|---|---|---|
wrapT | Yes | The wrap mode to set. |
updateArrayDataTypeForGL
Updates the data array to match the required data type for OpenGL.
This function takes the input data and converts it to the appropriate format required by the OpenGL texture, based on the specified data type.
| Argument | Type | Required | Description |
|---|---|---|---|
dataType | string | Yes | - The original data type of the input data. |
data | Array | Yes | - The input data array that needs to be updated. |
depth=false | boolean | No | - Indicates whether the data is a 3D array. |
imageExtents | Array<Extent> | Yes | only consider these image extents (default: []) |
Returns
| Type | Description |
|---|---|
| Array | The updated data array that matches the OpenGL data type. |
updateVolumeInfoForGL
Recomputes the scale and offset stored in the volume info for the given data type and number of components.
| Argument | Type | Required | Description |
|---|---|---|---|
dataType | Yes | The VTK data type of the texture data. | |
numComps | Yes | The number of components in the texture. |
Returns
| Type | Description |
|---|---|
| boolean | True if a scaling was applied for that data type. |
useHalfFloat
Whether half float is both enabled and usable for the current data range.
Returns
| Type | Description |
|---|---|
| boolean | True when half float is in use. |