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 is currently incompatible with webgl1, since there's no extent scaling.
| 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 is currently incompatible with webgl1, since there's no extent scaling.
| 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 is currently incompatible with webgl1, since there's no extent scaling.
| 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. |
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. |
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. |
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. |
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. |
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. |
getTextureUnit
Gets the texture unit number that this texture is bound to.
Returns
| Type | Description |
|---|---|
| number | The texture unit number. |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
renWin | Yes | The render window whose resources should be released. |
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.
setInternalFormat
Sets the internal format for the texture.
| Argument | Type | Required | Description |
|---|---|---|---|
iformat | Yes | The internal format to set. |
setOpenGLRenderWindow
Sets the OpenGL render window in which the texture will be used.
| Argument | Type | Required | Description |
|---|---|---|---|
renWin | Yes | The 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.
| 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. |
Returns
| Type | Description |
|---|---|
| Array | The updated data array that matches the OpenGL data type. |