Examples
import { createTexture } from '@wimaengine/render-webgl'
// `gl` is an existing WebGLRenderingContext and `image` is a TexImageSource.
const texture = createTexture(gl, image, 1) // truthy flipY flips the upload verticallyFunction
createTexture(gl: WebGLRenderingContext, img: TexImageSource, flipY: number): WebGLTextureCreates a 2D WebGL texture from an image source and uploads its pixels.
The helper calls WebGLRenderingContext#createTexture,
optionally enables WebGLRenderingContext#pixelStorei
with UNPACK_FLIP_Y_WEBGL, and binds the result with
WebGLRenderingContext#bindTexture. It uploads img with
WebGLRenderingContext#texImage2D using RGBA and
UNSIGNED_BYTE, sets linear magnification and linear-mipmap-nearest
minification filters, and generates mipmaps. When flipY is truthy, the
unpack flag is set back to false after the upload; the previous context
value is not saved or restored. The created texture remains bound to
TEXTURE_2D when the function completes.
import { createTexture } from '@wimaengine/render-webgl'
// `gl` is an existing WebGLRenderingContext and `image` is a TexImageSource.
const texture = createTexture(gl, image, 1) // truthy flipY flips the upload vertically