loadTexture()
ts
function loadTexture(
gl,
url,
options?
): Promise<WebGLTexture>;Defined in: loadTexture.js:31
Loads an image and resolves with a texture made from it. options are passed to createTexture. Cross-origin images need CORS headers.
Pass signal to give up: if it's aborted before the image has loaded, no texture is made and the promise rejects with the signal's reason.
Parameters
| Parameter | Type | Description |
|---|---|---|
gl | WebGL2RenderingContext | The WebGL2 context. |
url | string | - |
options? | LoadTextureOptions | See LoadTextureOptions. |
Returns
Promise<WebGLTexture>
Example
ts
const texture = await loadTexture(gl, "noise.png", { wrapS: gl.REPEAT, wrapT: gl.REPEAT });