updateTexture()
ts
function updateTexture(
gl,
texture,
source,
options?
): WebGLTexture;Defined in: updateTexture.js:35
Uploads new contents to a texture made by createTexture: an image source, such as the current frame of a video or a canvas that has been drawn to, or a typed array with width and height (which may differ from before). Mipmaps are regenerated if the texture's filtering uses them.
Pass the same format, type and flipY the texture was made with if they weren't the defaults.
Parameters
| Parameter | Type | Description |
|---|---|---|
gl | WebGL2RenderingContext | The WebGL2 context. |
texture | WebGLTexture | - |
source | ArrayBufferView<ArrayBufferLike> | TexImageSource | null | The new contents. |
options? | UpdateTextureOptions | See UpdateTextureOptions. |
Returns
WebGLTexture
The same texture.
Example
ts
// Every frame
updateTexture(gl, texture, video, { flipY: true });