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 is currently incompatible with webgl1, since there's no extent scaling.

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 is currently incompatible with webgl1, since there's no extent scaling.

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 is currently incompatible with webgl1, since there's no extent scaling.

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.

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.

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.

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.

getMaximumTextureSize

Gets the maximum texture size supported by the OpenGL context.

ArgumentTypeRequiredDescription
ctxYesThe OpenGL context.

Returns

TypeDescription
numberThe maximum texture size.

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.

getTextureUnit

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

Returns

TypeDescription
numberThe texture unit number.

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.

ArgumentTypeRequiredDescription
renWinYesThe render window whose resources should be released.

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.

setInternalFormat

Sets the internal format for the texture.

ArgumentTypeRequiredDescription
iformatYesThe internal format to set.

setOpenGLRenderWindow

Sets the OpenGL render window in which the texture will be used.

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

Returns

TypeDescription
ArrayThe updated data array that matches the OpenGL data type.