Skip to content

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.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
dataArrayYesThe data array to use for the texture.
preferSizeOverAccuracyYesWhether to prefer texture size over accuracy.

Returns ​

TypeDescription
booleanTrue 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.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
numCompsYesThe number of components in the texture.
dataTypeYesThe data type of the texture.
dataYesThe raw data for the texture.
preferSizeOverAccuracy=falseNoWhether to prefer texture size over accuracy. Defaults to false.
rangesNoThe precomputed ranges of the data (optional). Provided to prevent computation of the data ranges.

Returns ​

TypeDescription
booleanTrue if the texture was successfully created, false otherwise.

create2DFromImage ​

Creates a 2D texture from an image.

ArgumentTypeRequiredDescription
imageYesThe image to use for the texture.

Returns ​

TypeDescription
booleanTrue if the texture was successfully created, false otherwise.

create2DFromImageBitmap ​

Creates a 2D texture from an ImageBitmap.

ArgumentTypeRequiredDescription
imageBitmapYesThe ImageBitmap to use for the texture.

Returns ​

TypeDescription
booleanTrue if the texture was successfully created, false otherwise.

create2DFromRaw ​

Creates a 2D texture from raw data.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
numCompsYesThe number of components in the texture.
dataTypeYesThe data type of the texture.
dataYesThe raw data for the texture.
flipYesWhether to flip the texture vertically. Defaults to false.

Returns ​

TypeDescription
booleanTrue 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.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
depthYesThe depth of the texture.
dataArrayYesThe data array to use for the texture.
preferSizeOverAccuracyYesWhether to prefer texture size over accuracy.
updatedExtentsYesOnly update the specified extents (default: [])

Returns ​

TypeDescription
booleanTrue 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.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
depthYesThe depth of the texture.
numCompsYesThe number of components in the texture.
dataTypeYesThe data type of the texture.
dataYesThe raw data for the texture.
preferSizeOverAccuracyYesWhether to prefer texture size over accuracy.
rangesNoThe precomputed ranges of the data (optional). Provided to
updatedExtentsYesOnly update the specified extents (default: []) prevent computation of the data ranges.

Returns ​

TypeDescription
booleanTrue if the texture was successfully created, false otherwise.

create3DFromRaw ​

Creates a 3D texture from raw data.

updatedExtents support assumes WebGL2 3D texture uploads.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
depthYesThe depth of the texture.
numCompsYesThe number of components in the texture.
dataTypeYesThe data type of the texture.
dataYesThe raw data for the texture.
updatedExtentsYesOnly update the specified extents (default: [])

Returns ​

TypeDescription
booleanTrue if the texture was successfully created, false otherwise.

createCubeFromRaw ​

Creates a cube texture from raw data.

ArgumentTypeRequiredDescription
widthYesThe width of each face of the cube texture.
heightYesThe height of each face of the cube texture.
numCompsYesThe number of components in the texture.
dataTypeYesThe data type of the texture.
dataYesThe raw data for the texture.

Returns ​

TypeDescription
booleanTrue if the cube texture was successfully created, false otherwise.

createDepthFromRaw ​

Creates a 2D depth texture from raw data.

ArgumentTypeRequiredDescription
widthYesThe width of the texture.
heightYesThe height of the texture.
dataTypeYesThe data type of the texture.
dataYesThe raw data for the texture.

Returns ​

TypeDescription
booleanTrue 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).

ArgumentTypeRequiredDescription
useHalfFloatYes- whether to use half float

extend ​

Extends the publicAPI with the given model and initial values.

ArgumentTypeRequiredDescription
publicAPIYesThe API to extend.
modelYesThe model to use.
initialValuesYesThe 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.

ArgumentTypeRequiredDescription
vtkScalarTypeYesThe VTK scalar type.

Returns ​

TypeDescription
The default data type.

getDefaultFormat ​

Gets the default format for the texture based on the VTK data type and number of components.

ArgumentTypeRequiredDescription
vtktypeYesThe VTK data type.
numCompsYesThe number of components in the texture.

Returns ​

TypeDescription
The default format.

getDefaultInternalFormat ​

Gets the default internal format for the texture based on the VTK data type and number of components.

ArgumentTypeRequiredDescription
vtktypeYesThe VTK data type.
numCompsYesThe number of components in the texture.

Returns ​

TypeDescription
The default internal format.

getFormat ​

Gets the format for the texture based on the VTK data type and number of components.

ArgumentTypeRequiredDescription
vtktypeYesThe VTK data type.
numCompsYesThe number of components in the texture.

Returns ​

TypeDescription
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.

ArgumentTypeRequiredDescription
vtktypeYesThe VTK data type.
numCompsYesThe number of components in the texture.

Returns ​

TypeDescription
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.

ArgumentTypeRequiredDescription
ctxYesThe OpenGL context.

Returns ​

TypeDescription
numberThe 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.

ArgumentTypeRequiredDescription
vtkScalarTypeYesThe VTK scalar type.
forceUpdateYesWhether to force the update of the data type.

Returns ​

TypeDescription
The OpenGL data type.

getOpenGLFilterMode ​

Gets the OpenGL filter mode for the texture.

ArgumentTypeRequiredDescription
emodeYesThe filter mode.

Returns ​

TypeDescription
The OpenGL filter mode.

getOpenGLWrapMode ​

Gets the OpenGL wrap mode for the texture.

ArgumentTypeRequiredDescription
vtktypeYesThe wrap type.

Returns ​

TypeDescription
The OpenGL wrap mode.

getShiftAndScale ​

Gets the shift and scale values for the texture.

Returns ​

TypeDescription
The shift and scale values.

getTarget ​

Gets the OpenGL texture target.

getTextureUnit ​

Gets the texture unit number that this texture is bound to.

Returns ​

TypeDescription
numberThe 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 ​

TypeDescription
booleanTrue if the texture is bound, false otherwise.

newInstance ​

Creates a new instance of vtkOpenGLTexture with the given initial values.

ArgumentTypeRequiredDescription
initialValuesYesThe initial values to use.

Returns ​

TypeDescription
The new instance.

releaseGraphicsResources ​

Releases the graphics resources used by the texture within the given render window. Deleting the texture releases them too.

ArgumentTypeRequiredDescription
renWinNoThe 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.

ArgumentTypeRequiredDescription
renWinYesThe 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.

ArgumentTypeRequiredDescription
formatYesThe format to set.

setGenerateMipmap ​

Sets whether mipmaps are generated for the texture.

ArgumentTypeRequiredDescription
generateMipmapYesWhether to generate mipmaps.

setInternalFormat ​

Sets the internal format for the texture.

ArgumentTypeRequiredDescription
iformatYesThe internal format to set.

setKeyMatrixTime ​

Sets the time stamp used to track matrix updates.

ArgumentTypeRequiredDescription
keyMatrixTimeYesThe time stamp to set.

setMagnificationFilter ​

Sets the magnification filter.

ArgumentTypeRequiredDescription
magnificationFilterYesThe filter to set.

setMinificationFilter ​

Sets the minification filter.

ArgumentTypeRequiredDescription
minificationFilterYesThe filter to set.

setOglNorm16Ext ​

Sets the EXT_texture_norm16 extension object.

ArgumentTypeRequiredDescription
oglNorm16ExtYesThe extension object.

setOpenGLDataType ​

Sets the OpenGL data type for the texture.

ArgumentTypeRequiredDescription
openGLDataTypeYesThe 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.

ArgumentTypeRequiredDescription
renWinYesThe render window to set.

setWrapR ​

Sets the wrap mode along R.

ArgumentTypeRequiredDescription
wrapRYesThe wrap mode to set.

setWrapS ​

Sets the wrap mode along S.

ArgumentTypeRequiredDescription
wrapSYesThe wrap mode to set.

setWrapT ​

Sets the wrap mode along T.

ArgumentTypeRequiredDescription
wrapTYesThe 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.

ArgumentTypeRequiredDescription
dataTypestringYes- The original data type of the input data.
dataArrayYes- The input data array that needs to be updated.
depth=falsebooleanNo- Indicates whether the data is a 3D array.
imageExtentsArray<Extent>Yesonly consider these image extents (default: [])

Returns ​

TypeDescription
ArrayThe 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.

ArgumentTypeRequiredDescription
dataTypeYesThe VTK data type of the texture data.
numCompsYesThe number of components in the texture.

Returns ​

TypeDescription
booleanTrue if a scaling was applied for that data type.

useHalfFloat ​

Whether half float is both enabled and usable for the current data range.

Returns ​

TypeDescription
booleanTrue when half float is in use.