Skip to content

Textures

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 ​

ParameterTypeDescription
glWebGL2RenderingContextThe WebGL2 context.
textureWebGLTexture-
sourceArrayBufferView<ArrayBufferLike> | TexImageSource | nullThe new contents.
options?UpdateTextureOptionsSee UpdateTextureOptions.

Returns ​

WebGLTexture

The same texture.

Example ​

ts
// Every frame
updateTexture(gl, texture, video, { flipY: true });